Bug 1134501 - add way for UITour'd page to force-show the reader mode button, r=margaret

This commit is contained in:
Gijs Kruitbosch 2015-04-13 20:12:57 +01:00
parent ee76ea9658
commit 64126ad6ca
5 changed files with 42 additions and 0 deletions

View File

@ -281,6 +281,10 @@ if (typeof Mozilla == 'undefined') {
});
};
Mozilla.UITour.forceShowReaderIcon = function() {
_sendEvent('forceShowReaderIcon');
};
})();
// Make this library Require-able.

View File

@ -27,6 +27,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "BrowserUITelemetry",
"resource:///modules/BrowserUITelemetry.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Metrics",
"resource://gre/modules/Metrics.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ReaderParent",
"resource:///modules/ReaderParent.jsm");
// See LOG_LEVELS in Console.jsm. Common examples: "All", "Info", "Warn", & "Error".
const PREF_LOG_LEVEL = "browser.uitour.loglevel";
@ -34,6 +36,7 @@ const PREF_SEENPAGEIDS = "browser.uitour.seenPageIDs";
const BACKGROUND_PAGE_ACTIONS_ALLOWED = new Set([
"endUrlbarCapture",
"forceShowReaderIcon",
"getConfiguration",
"getTreatmentTag",
"hideHighlight",
@ -677,6 +680,11 @@ this.UITour = {
this.sendPageCallback(messageManager, data.callbackID);
break;
}
case "forceShowReaderIcon": {
ReaderParent.forceShowReaderIcon(browser);
break;
}
}
if (!this.tourBrowsersByWindow.has(window)) {

View File

@ -18,6 +18,8 @@ skip-if = e10s # Bug 941428 - UITour.jsm not e10s friendly
skip-if = e10s # Bug 941428 - UITour.jsm not e10s friendly
[browser_UITour_annotation_size_attributes.js]
skip-if = e10s # Bug 941428 - UITour.jsm not e10s friendly.
[browser_UITour_forceReaderMode.js]
skip-if = e10s # Bug 941428 - UITour.jsm not e10s friendly.
[browser_UITour_heartbeat.js]
skip-if = e10s # Bug 941428 - UITour.jsm not e10s friendly.
[browser_UITour_loop.js]

View File

@ -0,0 +1,23 @@
"use strict";
let gTestTab;
let gContentAPI;
let gContentWindow;
Components.utils.import("resource:///modules/UITour.jsm");
function test() {
UITourTest();
}
let tests = [
taskify(function*() {
ok(!gBrowser.selectedBrowser.isArticle, "Should not be an article when we start");
ok(document.getElementById("reader-mode-button").hidden, "Button should be hidden.");
gContentAPI.forceShowReaderIcon();
yield waitForConditionPromise(() => gBrowser.selectedBrowser.isArticle);
ok(gBrowser.selectedBrowser.isArticle, "Should suddenly be an article.");
ok(!document.getElementById("reader-mode-button").hidden, "Button should now be visible.");
})
];

View File

@ -159,6 +159,11 @@ let ReaderParent = {
}
},
forceShowReaderIcon: function(browser) {
browser.isArticle = true;
this.updateReaderButton(browser);
},
buttonClick: function(event) {
if (event.button != 0) {
return;