Bug 1515953 - don't load the Thunderbird custom elements in the dummy.xul document. r=arshad
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Fri, 25 Jan 2019 14:19:10 +0200
changeset 34302 bffe1c0bac89d31eb8154176efbe27ef11aab997
parent 34301 0c2445d753759cf438e37127b79de0dfabb5f5c0
child 34303 655c34c266f6c7a5b5e4656b79c82c34fbb7b526
push id389
push userclokep@gmail.com
push dateMon, 18 Mar 2019 19:01:53 +0000
reviewersarshad
bugs1515953
Bug 1515953 - don't load the Thunderbird custom elements in the dummy.xul document. r=arshad This was causing TypeError "class heritage customElements.get(...) is not an object or null" In the document chrome://extensions/content/dummy.xul no toolkit Custom Elements are set up, so we can't inherit there. OTOH, we don't want to either, so that's ok.
mail/base/content/customElements.js
--- a/mail/base/content/customElements.js
+++ b/mail/base/content/customElements.js
@@ -1,17 +1,24 @@
 /* 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/. */
 
 "use strict";
 
+// This is loaded into chrome windows with the subscript loader. Wrap in
+// a block to prevent accidentally leaking globals onto `window`.
+(() => {
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
-for (let script of [
-  "chrome://chat/content/conversation-browser.js",
-  "chrome://messenger/content/mailWidgets.js",
-  "chrome://messenger/content/generalBindings.js",
-  "chrome://messenger/content/statuspanel.js",
-  "chrome://messenger/content/foldersummary.js",
-]) {
-  Services.scriptloader.loadSubScript(script, window);
+const isDummyDocument = document.documentURI == "chrome://extensions/content/dummy.xul";
+if (!isDummyDocument) {
+  for (let script of [
+    "chrome://chat/content/conversation-browser.js",
+    "chrome://messenger/content/mailWidgets.js",
+    "chrome://messenger/content/generalBindings.js",
+    "chrome://messenger/content/statuspanel.js",
+    "chrome://messenger/content/foldersummary.js",
+  ]) {
+    Services.scriptloader.loadSubScript(script, window);
+  }
 }
+})();