Backed out changeset 5212e051d039 (bug 1479310) for bc failures on /browser/browser_onboarding_uitour.js.

--HG--
rename : browser/components/uitour/ContentUITour.jsm => browser/components/uitour/content-UITour.js
This commit is contained in:
Brindusan Cristian 2018-08-07 20:49:43 +03:00
parent 90cfc55b47
commit 8c70dfad01
5 changed files with 27 additions and 31 deletions

View file

@ -1319,6 +1319,7 @@ var gBrowserInit = {
let mm = window.getGroupMessageManager("browsers"); let mm = window.getGroupMessageManager("browsers");
mm.loadFrameScript("chrome://browser/content/tab-content.js", true); mm.loadFrameScript("chrome://browser/content/tab-content.js", true);
mm.loadFrameScript("chrome://browser/content/content.js", true); mm.loadFrameScript("chrome://browser/content/content.js", true);
mm.loadFrameScript("chrome://browser/content/content-UITour.js", true);
mm.loadFrameScript("chrome://global/content/content-HybridContentTelemetry.js", true); mm.loadFrameScript("chrome://global/content/content-HybridContentTelemetry.js", true);
window.messageManager.addMessageListener("Browser:LoadURI", RedirectLoad); window.messageManager.addMessageListener("Browser:LoadURI", RedirectLoad);

View file

@ -2,18 +2,14 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var EXPORTED_SYMBOLS = ["UITourListener"]; /* eslint-env mozilla/frame-script */
ChromeUtils.import("resource://gre/modules/Services.jsm"); ChromeUtils.import("resource://gre/modules/Services.jsm");
const PREF_TEST_WHITELIST = "browser.uitour.testingOrigins"; const PREF_TEST_WHITELIST = "browser.uitour.testingOrigins";
const UITOUR_PERMISSION = "uitour"; const UITOUR_PERMISSION = "uitour";
class UITourListener { var UITourListener = {
constructor(mm) {
this.mm = mm;
}
handleEvent(event) { handleEvent(event) {
if (!Services.prefs.getBoolPref("browser.uitour.enabled")) { if (!Services.prefs.getBoolPref("browser.uitour.enabled")) {
return; return;
@ -21,14 +17,14 @@ class UITourListener {
if (!this.ensureTrustedOrigin()) { if (!this.ensureTrustedOrigin()) {
return; return;
} }
this.mm.addMessageListener("UITour:SendPageCallback", this); addMessageListener("UITour:SendPageCallback", this);
this.mm.addMessageListener("UITour:SendPageNotification", this); addMessageListener("UITour:SendPageNotification", this);
this.mm.sendAsyncMessage("UITour:onPageEvent", { sendAsyncMessage("UITour:onPageEvent", {
detail: event.detail, detail: event.detail,
type: event.type, type: event.type,
pageVisibilityState: this.mm.content.document.visibilityState, pageVisibilityState: content.document.visibilityState,
}); });
} },
isTestingOrigin(aURI) { isTestingOrigin(aURI) {
if (Services.prefs.getPrefType(PREF_TEST_WHITELIST) != Services.prefs.PREF_STRING) { if (Services.prefs.getPrefType(PREF_TEST_WHITELIST) != Services.prefs.PREF_STRING) {
@ -47,7 +43,7 @@ class UITourListener {
} }
} }
return false; return false;
} },
// This function is copied from UITour.jsm. // This function is copied from UITour.jsm.
isSafeScheme(aURI) { isSafeScheme(aURI) {
@ -59,11 +55,9 @@ class UITourListener {
return false; return false;
return true; return true;
} },
ensureTrustedOrigin() { ensureTrustedOrigin() {
let {content} = this.mm;
if (content.top != content) if (content.top != content)
return false; return false;
@ -80,7 +74,7 @@ class UITourListener {
return true; return true;
return this.isTestingOrigin(uri); return this.isTestingOrigin(uri);
} },
receiveMessage(aMessage) { receiveMessage(aMessage) {
switch (aMessage.name) { switch (aMessage.name) {
@ -91,19 +85,21 @@ class UITourListener {
this.sendPageEvent("Notification", aMessage.data); this.sendPageEvent("Notification", aMessage.data);
break; break;
} }
} },
sendPageEvent(type, detail) { sendPageEvent(type, detail) {
if (!this.ensureTrustedOrigin()) { if (!this.ensureTrustedOrigin()) {
return; return;
} }
let win = this.mm.content; let doc = content.document;
let eventName = "mozUITour" + type; let eventName = "mozUITour" + type;
let event = new win.CustomEvent(eventName, { let event = new doc.defaultView.CustomEvent(eventName, {
bubbles: true, bubbles: true,
detail: Cu.cloneInto(detail, win), detail: Cu.cloneInto(detail, doc.defaultView)
}); });
win.document.dispatchEvent(event); doc.dispatchEvent(event);
} }
} };
addEventListener("mozUITour", UITourListener, false, true);

View file

@ -0,0 +1,6 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
browser.jar:
content/browser/content-UITour.js

View file

@ -3,10 +3,11 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXTRA_JS_MODULES += [ EXTRA_JS_MODULES += [
'ContentUITour.jsm',
'UITour.jsm', 'UITour.jsm',
] ]
JAR_MANIFESTS += ['jar.mn']
BROWSER_CHROME_MANIFESTS += [ BROWSER_CHROME_MANIFESTS += [
'test/browser.ini', 'test/browser.ini',
] ]

View file

@ -37,12 +37,6 @@ XPCOMUtils.defineLazyProxy(this, "PopupBlocking", () => {
return new tmp.PopupBlocking(global); return new tmp.PopupBlocking(global);
}); });
XPCOMUtils.defineLazyProxy(this, "ShieldFrameListener", () => {
let tmp = {};
ChromeUtils.import("resource://normandy-content/ShieldFrameListener.jsm", tmp);
return new tmp.ShieldFrameListener(global);
});
XPCOMUtils.defineLazyProxy(this, "SelectionSourceContent", XPCOMUtils.defineLazyProxy(this, "SelectionSourceContent",
"resource://gre/modules/SelectionSourceContent.jsm"); "resource://gre/modules/SelectionSourceContent.jsm");
@ -439,5 +433,3 @@ let ExtFind = {
}; };
ExtFind.init(); ExtFind.init();
addEventListener("ShieldPageEvent", ShieldFrameListener, false, true);