Bug 1229474 - only create widgets in browser windows, r=jaws
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 02 Dec 2015 16:11:56 +0000
changeset 275640 42354cbc1237d0d6dfab64a98e421c83fa612355
parent 275639 4a9a6f9a2cf4e1243ed9d0224acd0edec3841f5b
child 275641 28a8a1833628265ef48db5f1f16b1e1617d86eea
push id29763
push userryanvm@gmail.com
push dateSat, 05 Dec 2015 20:09:55 +0000
treeherdermozilla-central@094bf2eff9d7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1229474
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1229474 - only create widgets in browser windows, r=jaws
browser/components/customizableui/CustomizableUI.jsm
--- a/browser/components/customizableui/CustomizableUI.jsm
+++ b/browser/components/customizableui/CustomizableUI.jsm
@@ -34,16 +34,19 @@ const kNSXUL = "http://www.mozilla.org/k
 const kSpecialWidgetPfx = "customizableui-special-";
 
 const kPrefCustomizationState        = "browser.uiCustomization.state";
 const kPrefCustomizationAutoAdd      = "browser.uiCustomization.autoAdd";
 const kPrefCustomizationDebug        = "browser.uiCustomization.debug";
 const kPrefDrawInTitlebar            = "browser.tabs.drawInTitlebar";
 const kPrefWebIDEInNavbar            = "devtools.webide.widget.inNavbarByDefault";
 
+const kExpectedWindowURL = "chrome://browser/content/browser.xul";
+
+
 /**
  * The keys are the handlers that are fired when the event type (the value)
  * is fired on the subview. A widget that provides a subview has the option
  * of providing onViewShowing and onViewHiding event handlers.
  */
 const kSubviewEvents = [
   "ViewShowing",
   "ViewHiding"
@@ -1295,16 +1298,19 @@ var CustomizableUIInternal = {
           return node;
         }
       }
     }
     return null;
   },
 
   buildWidget: function(aDocument, aWidget) {
+    if (aDocument.documentURI != kExpectedWindowURL) {
+      throw new Error("buildWidget was called for a non-browser window!");
+    }
     if (typeof aWidget == "string") {
       aWidget = gPalette.get(aWidget);
     }
     if (!aWidget) {
       throw new Error("buildWidget was passed a non-widget to build.");
     }
 
     LOG("Building " + aWidget.id + " of type " + aWidget.type);