mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1134501 - UITour: Force page into Reader View automatically whenever the ReaderView/ReadingList tour page is loaded. r=gijs
This commit is contained in:
parent
baa0201878
commit
28f9f304bc
@ -251,6 +251,8 @@ pref("browser.uitour.loglevel", "Error");
|
||||
pref("browser.uitour.requireSecure", true);
|
||||
pref("browser.uitour.themeOrigin", "https://addons.mozilla.org/%LOCALE%/firefox/themes/");
|
||||
pref("browser.uitour.url", "https://www.mozilla.org/%LOCALE%/firefox/%VERSION%/tour/");
|
||||
// This is used as a regexp match against the page's URL.
|
||||
pref("browser.uitour.readerViewTrigger", "^https:\/\/www\.mozilla\.org\/[^\/]+\/firefox\/reading\/start");
|
||||
|
||||
pref("browser.customizemode.tip0.shown", false);
|
||||
pref("browser.customizemode.tip0.learnMoreUrl", "https://support.mozilla.org/1/firefox/%VERSION%/%OS%/%LOCALE%/customize");
|
||||
|
@ -4203,6 +4203,7 @@ var XULBrowserWindow = {
|
||||
|
||||
BookmarkingUI.onLocationChange();
|
||||
SocialUI.updateState(location);
|
||||
UITour.onLocationChange(location);
|
||||
}
|
||||
|
||||
// Utility functions for disabling find
|
||||
|
@ -285,9 +285,13 @@ if (typeof Mozilla == 'undefined') {
|
||||
_sendEvent('forceShowReaderIcon');
|
||||
};
|
||||
|
||||
Mozilla.UITour.toggleReaderMode = function(feature) {
|
||||
_sendEvent('toggleReaderMode');
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
// Make this library Require-able.
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = Mozilla.UITour;
|
||||
module.exports = Mozilla.UITour;
|
||||
}
|
||||
|
@ -27,12 +27,15 @@ XPCOMUtils.defineLazyModuleGetter(this, "BrowserUITelemetry",
|
||||
"resource:///modules/BrowserUITelemetry.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Metrics",
|
||||
"resource://gre/modules/Metrics.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "ReaderMode",
|
||||
"resource://gre/modules/ReaderMode.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";
|
||||
const PREF_SEENPAGEIDS = "browser.uitour.seenPageIDs";
|
||||
const PREF_READERVIEW_TRIGGER = "browser.uitour.readerViewTrigger";
|
||||
|
||||
const BACKGROUND_PAGE_ACTIONS_ALLOWED = new Set([
|
||||
"endUrlbarCapture",
|
||||
@ -190,6 +193,7 @@ this.UITour = {
|
||||
}],
|
||||
["privateWindow", {query: "#privatebrowsing-button"}],
|
||||
["quit", {query: "#PanelUI-quit"}],
|
||||
["readerMode-urlBar", {query: "#reader-mode-button"}],
|
||||
["search", {
|
||||
infoPanelOffsetX: 18,
|
||||
infoPanelPosition: "after_start",
|
||||
@ -344,6 +348,22 @@ this.UITour = {
|
||||
JSON.stringify([...this.seenPageIDs]));
|
||||
},
|
||||
|
||||
get _readerViewTriggerRegEx() {
|
||||
delete this._readerViewTriggerRegEx;
|
||||
let readerViewUITourTrigger = Services.prefs.getCharPref(PREF_READERVIEW_TRIGGER);
|
||||
return this._readerViewTriggerRegEx = new RegExp(readerViewUITourTrigger, "i");
|
||||
},
|
||||
|
||||
onLocationChange: function(aLocation) {
|
||||
// The ReadingList/ReaderView tour page is expected to run in Reader View,
|
||||
// which disables JavaScript on the page. To get around that, we
|
||||
// automatically start a pre-defined tour on page load.
|
||||
let originalUrl = ReaderMode.getOriginalUrl(aLocation);
|
||||
if (this._readerViewTriggerRegEx.test(originalUrl)) {
|
||||
this.startSubTour("readinglist");
|
||||
}
|
||||
},
|
||||
|
||||
onPageEvent: function(aMessage, aEvent) {
|
||||
let browser = aMessage.target;
|
||||
let window = browser.ownerDocument.defaultView;
|
||||
@ -685,6 +705,13 @@ this.UITour = {
|
||||
ReaderParent.forceShowReaderIcon(browser);
|
||||
break;
|
||||
}
|
||||
|
||||
case "toggleReaderMode": {
|
||||
let targetPromise = this.getTarget(window, "readerMode-urlBar");
|
||||
targetPromise.then(target => {
|
||||
ReaderParent.toggleReaderMode({target: target.node});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.tourBrowsersByWindow.has(window)) {
|
||||
@ -1720,6 +1747,20 @@ this.UITour = {
|
||||
});
|
||||
},
|
||||
|
||||
startSubTour: function (aFeature) {
|
||||
if (aFeature != "string") {
|
||||
log.error("startSubTour: No feature option specified");
|
||||
return;
|
||||
}
|
||||
|
||||
if (aFeature == "readinglist") {
|
||||
ReaderParent.showReaderModeInfoPanel(browser);
|
||||
} else {
|
||||
log.error("startSubTour: Unknown feature option specified");
|
||||
return;
|
||||
}
|
||||
},
|
||||
|
||||
addNavBarWidget: function (aTarget, aMessageManager, aCallbackID) {
|
||||
if (aTarget.node) {
|
||||
log.error("addNavBarWidget: can't add a widget already present:", aTarget);
|
||||
|
@ -9,30 +9,32 @@ support-files =
|
||||
[browser_UITour.js]
|
||||
skip-if = os == "linux" || e10s # Intermittent failures, bug 951965
|
||||
[browser_UITour2.js]
|
||||
skip-if = e10s # Bug 941428 - UITour.jsm not e10s friendly
|
||||
skip-if = e10s # Bug 1073247 - UITour.jsm not e10s friendly
|
||||
# [browser_UITour3.js] Bug 1113038
|
||||
# skip-if = os == "linux" || e10s # Linux: Bug 986760, Bug 989101; e10s: Bug 941428 - UITour.jsm not e10s friendly
|
||||
# skip-if = os == "linux" || e10s # Linux: Bug 986760, Bug 989101; e10s: Bug 1073247 - UITour.jsm not e10s friendly
|
||||
[browser_UITour_availableTargets.js]
|
||||
skip-if = e10s # Bug 941428 - UITour.jsm not e10s friendly
|
||||
skip-if = e10s # Bug 1073247 - UITour.jsm not e10s friendly
|
||||
[browser_UITour_detach_tab.js]
|
||||
skip-if = e10s # Bug 941428 - UITour.jsm not e10s friendly
|
||||
skip-if = e10s # Bug 1073247 - UITour.jsm not e10s friendly
|
||||
[browser_UITour_annotation_size_attributes.js]
|
||||
skip-if = e10s # Bug 941428 - UITour.jsm not e10s friendly.
|
||||
skip-if = e10s # Bug 1073247 - UITour.jsm not e10s friendly.
|
||||
[browser_UITour_forceReaderMode.js]
|
||||
skip-if = e10s # Bug 941428 - UITour.jsm not e10s friendly.
|
||||
skip-if = e10s # Bug 1073247 - UITour.jsm not e10s friendly.
|
||||
[browser_UITour_toggleReaderMode.js]
|
||||
skip-if = e10s # Bug 1073247 - UITour.jsm not e10s friendly
|
||||
[browser_UITour_heartbeat.js]
|
||||
skip-if = e10s # Bug 941428 - UITour.jsm not e10s friendly.
|
||||
skip-if = e10s # Bug 1073247 - UITour.jsm not e10s friendly.
|
||||
[browser_UITour_loop.js]
|
||||
skip-if = os == "linux" || e10s # Bug 941428 - UITour.jsm not e10s friendly.
|
||||
skip-if = os == "linux" || e10s # Bug 1073247 - UITour.jsm not e10s friendly.
|
||||
[browser_UITour_modalDialog.js]
|
||||
skip-if = os != "mac" || e10s # modal dialog disabling only working on OS X.Bug 941428 - UITour.jsm not e10s friendly
|
||||
skip-if = os != "mac" || e10s # modal dialog disabling only working on OS X.Bug 1073247 - UITour.jsm not e10s friendly
|
||||
[browser_UITour_observe.js]
|
||||
skip-if = e10s # Bug 941428 - UITour.jsm not e10s friendly.
|
||||
skip-if = e10s # Bug 1073247 - UITour.jsm not e10s friendly.
|
||||
[browser_UITour_panel_close_annotation.js]
|
||||
skip-if = true # Disabled due to frequent failures, bugs 1026310 and 1032137
|
||||
[browser_UITour_registerPageID.js]
|
||||
skip-if = e10s # Bug 941428 - UITour.jsm not e10s friendly
|
||||
skip-if = e10s # Bug 1073247 - UITour.jsm not e10s friendly
|
||||
[browser_UITour_sync.js]
|
||||
skip-if = e10s # Bug 941428 - UITour.jsm not e10s friendly
|
||||
skip-if = e10s # Bug 1073247 - UITour.jsm not e10s friendly
|
||||
[browser_UITour_resetProfile.js]
|
||||
skip-if = e10s # Bug 941428 - UITour.jsm not e10s friendly
|
||||
skip-if = e10s # Bug 1073247 - UITour.jsm not e10s friendly
|
||||
|
@ -39,6 +39,7 @@ let tests = [
|
||||
"devtools",
|
||||
"privateWindow",
|
||||
"quit",
|
||||
"readerMode-urlBar",
|
||||
"search",
|
||||
"searchIcon",
|
||||
"urlbar",
|
||||
@ -69,6 +70,7 @@ let tests = [
|
||||
"home",
|
||||
"privateWindow",
|
||||
"quit",
|
||||
"readerMode-urlBar",
|
||||
"search",
|
||||
"searchIcon",
|
||||
"urlbar",
|
||||
@ -104,6 +106,7 @@ let tests = [
|
||||
"devtools",
|
||||
"privateWindow",
|
||||
"quit",
|
||||
"readerMode-urlBar",
|
||||
"urlbar",
|
||||
...(hasWebIDE ? ["webide"] : [])
|
||||
]);
|
||||
|
@ -0,0 +1,20 @@
|
||||
"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.currentURI.spec.startsWith("about:reader"), "Should not be in reader mode at start of test.");
|
||||
gContentAPI.toggleReaderMode();
|
||||
yield waitForConditionPromise(() => gBrowser.selectedBrowser.currentURI.spec.startsWith("about:reader"));
|
||||
ok(gBrowser.selectedBrowser.currentURI.spec.startsWith("about:reader"), "Should be in reader mode now.");
|
||||
})
|
||||
];
|
@ -16,6 +16,7 @@ Cu.import("resource://gre/modules/Task.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils","resource://gre/modules/PlacesUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "ReaderMode", "resource://gre/modules/ReaderMode.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "ReadingList", "resource:///modules/readinglist/ReadingList.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "UITour", "resource:///modules/UITour.jsm");
|
||||
|
||||
const gStringBundle = Services.strings.createBundle("chrome://global/locale/aboutReader.properties");
|
||||
|
||||
@ -188,6 +189,23 @@ let ReaderParent = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Shows an info panel from the UITour for Reader Mode.
|
||||
*
|
||||
* @param browser The <browser> that the tour should be started for.
|
||||
*/
|
||||
showReaderModeInfoPanel(browser) {
|
||||
let win = browser.ownerDocument.defaultView;
|
||||
let targetPromise = UITour.getTarget(win, "readerMode-urlBar");
|
||||
targetPromise.then(target => {
|
||||
let browserBundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
|
||||
UITour.showInfo(win, browser.messageManager, target,
|
||||
browserBundle.GetStringFromName("readerView.promo.firstDetectedArticle.title"),
|
||||
browserBundle.GetStringFromName("readerView.promo.firstDetectedArticle.body"),
|
||||
"chrome://browser/skin/reader-tour.png");
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets an article for a given URL. This method will download and parse a document.
|
||||
*
|
||||
|
@ -93,6 +93,7 @@ browser.jar:
|
||||
skin/classic/browser/session-restore.svg (../shared/incontent-icons/session-restore.svg)
|
||||
skin/classic/browser/tab-crashed.svg (../shared/incontent-icons/tab-crashed.svg)
|
||||
skin/classic/browser/welcome-back.svg (../shared/incontent-icons/welcome-back.svg)
|
||||
skin/classic/browser/reader-tour.png (../shared/reader/reader-tour.png)
|
||||
skin/classic/browser/readerMode.svg (../shared/reader/readerMode.svg)
|
||||
skin/classic/browser/readinglist/icons.svg (../shared/readinglist/icons.svg)
|
||||
skin/classic/browser/readinglist/readinglist-icon.svg (../shared/readinglist/readinglist-icon.svg)
|
||||
|
@ -145,6 +145,7 @@ browser.jar:
|
||||
skin/classic/browser/session-restore.svg (../shared/incontent-icons/session-restore.svg)
|
||||
skin/classic/browser/tab-crashed.svg (../shared/incontent-icons/tab-crashed.svg)
|
||||
skin/classic/browser/welcome-back.svg (../shared/incontent-icons/welcome-back.svg)
|
||||
skin/classic/browser/reader-tour.png (../shared/reader/reader-tour.png)
|
||||
skin/classic/browser/readerMode.svg (../shared/reader/readerMode.svg)
|
||||
skin/classic/browser/readinglist/icons.svg (../shared/readinglist/icons.svg)
|
||||
skin/classic/browser/readinglist/readinglist-icon.svg (../shared/readinglist/readinglist-icon.svg)
|
||||
|
BIN
browser/themes/shared/reader/reader-tour.png
Normal file
BIN
browser/themes/shared/reader/reader-tour.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
@ -128,6 +128,7 @@ browser.jar:
|
||||
skin/classic/browser/session-restore.svg (../shared/incontent-icons/session-restore.svg)
|
||||
skin/classic/browser/tab-crashed.svg (../shared/incontent-icons/tab-crashed.svg)
|
||||
skin/classic/browser/welcome-back.svg (../shared/incontent-icons/welcome-back.svg)
|
||||
skin/classic/browser/reader-tour.png (../shared/reader/reader-tour.png)
|
||||
skin/classic/browser/readerMode.svg (../shared/reader/readerMode.svg)
|
||||
skin/classic/browser/readinglist/icons.svg (../shared/readinglist/icons.svg)
|
||||
skin/classic/browser/readinglist/readinglist-icon.svg (../shared/readinglist/readinglist-icon.svg)
|
||||
|
Loading…
Reference in New Issue
Block a user