From 6764c42a9ea7bf9749c4115241d4b1434cd67b55 Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Fri, 15 May 2015 14:25:57 +0100 Subject: [PATCH] Bug 1164942 - do not load pocket's jsm or other scripts until used with extra getter to satisfy tests, r=jaws --HG-- extra : rebase_source : fc6d1273cc9c6dc355638033cd27705ab59747e7 --- browser/base/content/browser.js | 30 ++++++++++++++++++- browser/base/content/browser.xul | 3 -- .../customizableui/CustomizableWidgets.jsm | 9 ++++-- .../customizableui/content/panelUI.js | 2 -- browser/components/pocket/Pocket.jsm | 24 --------------- 5 files changed, 36 insertions(+), 32 deletions(-) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index b63f3e3b0033..7fc903a4a590 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -55,6 +55,35 @@ XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeManager", XPCOMUtils.defineLazyModuleGetter(this, "Pocket", "resource:///modules/Pocket.jsm"); +// Can't use XPCOMUtils for these because the scripts try to define the variables +// on window, and so the defineProperty inside defineLazyGetter fails. +Object.defineProperty(window, "pktApi", { + get: function() { + // Avoid this getter running again: + delete window.pktApi; + Services.scriptloader.loadSubScript("chrome://browser/content/pocket/pktApi.js", window); + return window.pktApi; + }, + configurable: true, + enumerable: true +}); + +function pktUIGetter(prop) { + return { + get: function() { + // Avoid either of these getters running again: + delete window.pktUI; + delete window.pktUIMessaging; + Services.scriptloader.loadSubScript("chrome://browser/content/pocket/main.js", window); + return window[prop]; + }, + configurable: true, + enumerable: true + }; +} +Object.defineProperty(window, "pktUI", pktUIGetter("pktUI")); +Object.defineProperty(window, "pktUIMessaging", pktUIGetter("pktUIMessaging")); + const nsIWebNavigation = Ci.nsIWebNavigation; var gLastBrowserCharset = null; @@ -4171,7 +4200,6 @@ var XULBrowserWindow = { BookmarkingUI.onLocationChange(); SocialUI.updateState(location); UITour.onLocationChange(location); - Pocket.onLocationChange(browser, aLocationURI); } // Utility functions for disabling find diff --git a/browser/base/content/browser.xul b/browser/base/content/browser.xul index e62e99ca8c5e..981c896d5b82 100644 --- a/browser/base/content/browser.xul +++ b/browser/base/content/browser.xul @@ -1307,7 +1307,4 @@ # starting with an empty iframe here in browser.xul from a Ts standpoint. -