From fe2a940ebf336f54cc2548cbd3af6a6fc89e5d40 Mon Sep 17 00:00:00 2001 From: Brindusan Cristian Date: Tue, 7 Aug 2018 20:49:43 +0300 Subject: [PATCH] Backed out changeset 5212e051d039 (bug 1479310) for bc failures on /browser/browser_onboarding_uitour.js. --- browser/base/content/browser.js | 1 + .../{ContentUITour.jsm => content-UITour.js} | 40 +++++++++---------- browser/components/uitour/jar.mn | 6 +++ browser/components/uitour/moz.build | 3 +- toolkit/content/browser-content.js | 8 ---- 5 files changed, 27 insertions(+), 31 deletions(-) rename browser/components/uitour/{ContentUITour.jsm => content-UITour.js} (80%) create mode 100644 browser/components/uitour/jar.mn diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 0abff8b998ba..60aaf7a2d872 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -1319,6 +1319,7 @@ var gBrowserInit = { let mm = window.getGroupMessageManager("browsers"); mm.loadFrameScript("chrome://browser/content/tab-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); window.messageManager.addMessageListener("Browser:LoadURI", RedirectLoad); diff --git a/browser/components/uitour/ContentUITour.jsm b/browser/components/uitour/content-UITour.js similarity index 80% rename from browser/components/uitour/ContentUITour.jsm rename to browser/components/uitour/content-UITour.js index a3a6a7786711..100aa4dc2255 100644 --- a/browser/components/uitour/ContentUITour.jsm +++ b/browser/components/uitour/content-UITour.js @@ -2,18 +2,14 @@ * 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/. */ -var EXPORTED_SYMBOLS = ["UITourListener"]; +/* eslint-env mozilla/frame-script */ ChromeUtils.import("resource://gre/modules/Services.jsm"); const PREF_TEST_WHITELIST = "browser.uitour.testingOrigins"; const UITOUR_PERMISSION = "uitour"; -class UITourListener { - constructor(mm) { - this.mm = mm; - } - +var UITourListener = { handleEvent(event) { if (!Services.prefs.getBoolPref("browser.uitour.enabled")) { return; @@ -21,14 +17,14 @@ class UITourListener { if (!this.ensureTrustedOrigin()) { return; } - this.mm.addMessageListener("UITour:SendPageCallback", this); - this.mm.addMessageListener("UITour:SendPageNotification", this); - this.mm.sendAsyncMessage("UITour:onPageEvent", { + addMessageListener("UITour:SendPageCallback", this); + addMessageListener("UITour:SendPageNotification", this); + sendAsyncMessage("UITour:onPageEvent", { detail: event.detail, type: event.type, - pageVisibilityState: this.mm.content.document.visibilityState, + pageVisibilityState: content.document.visibilityState, }); - } + }, isTestingOrigin(aURI) { if (Services.prefs.getPrefType(PREF_TEST_WHITELIST) != Services.prefs.PREF_STRING) { @@ -47,7 +43,7 @@ class UITourListener { } } return false; - } + }, // This function is copied from UITour.jsm. isSafeScheme(aURI) { @@ -59,11 +55,9 @@ class UITourListener { return false; return true; - } + }, ensureTrustedOrigin() { - let {content} = this.mm; - if (content.top != content) return false; @@ -80,7 +74,7 @@ class UITourListener { return true; return this.isTestingOrigin(uri); - } + }, receiveMessage(aMessage) { switch (aMessage.name) { @@ -91,19 +85,21 @@ class UITourListener { this.sendPageEvent("Notification", aMessage.data); break; } - } + }, sendPageEvent(type, detail) { if (!this.ensureTrustedOrigin()) { return; } - let win = this.mm.content; + let doc = content.document; let eventName = "mozUITour" + type; - let event = new win.CustomEvent(eventName, { + let event = new doc.defaultView.CustomEvent(eventName, { 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); diff --git a/browser/components/uitour/jar.mn b/browser/components/uitour/jar.mn new file mode 100644 index 000000000000..966a69c9667e --- /dev/null +++ b/browser/components/uitour/jar.mn @@ -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 diff --git a/browser/components/uitour/moz.build b/browser/components/uitour/moz.build index 84f6c43b303b..51e6037cc544 100644 --- a/browser/components/uitour/moz.build +++ b/browser/components/uitour/moz.build @@ -3,10 +3,11 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. EXTRA_JS_MODULES += [ - 'ContentUITour.jsm', 'UITour.jsm', ] +JAR_MANIFESTS += ['jar.mn'] + BROWSER_CHROME_MANIFESTS += [ 'test/browser.ini', ] diff --git a/toolkit/content/browser-content.js b/toolkit/content/browser-content.js index 31025d992fa1..7f8b144b7ea2 100644 --- a/toolkit/content/browser-content.js +++ b/toolkit/content/browser-content.js @@ -37,12 +37,6 @@ XPCOMUtils.defineLazyProxy(this, "PopupBlocking", () => { 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", "resource://gre/modules/SelectionSourceContent.jsm"); @@ -439,5 +433,3 @@ let ExtFind = { }; ExtFind.init(); - -addEventListener("ShieldPageEvent", ShieldFrameListener, false, true);