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 33448 bffe1c0bac89
parent 33447 0c2445d75375
child 33449 655c34c266f6
push id2368
push userclokep@gmail.com
push dateMon, 28 Jan 2019 21:12:50 +0000
treeherdercomm-beta@56d23c07d815 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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);
+  }
 }
+})();