Bug 1490269 - enable Thunderbird specific custom element loading. r=arshad
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Thu, 13 Sep 2018 23:24:42 +0300
changeset 33148 760fa56f28063ce0a99d8b2767ff78a9933c52be
parent 33147 428645c8b28ee2ebbd2e1daa71f8a721f61c0d90
child 33149 63459259f1e91e62aeaaf674f90dc122a57bcad1
push id387
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:30:47 +0000
reviewersarshad
bugs1490269
Bug 1490269 - enable Thunderbird specific custom element loading. r=arshad
common/content/customElements.js
common/jar.mn
mail/components/mailGlue.js
new file mode 100644
--- /dev/null
+++ b/common/content/customElements.js
@@ -0,0 +1,13 @@
+/* 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";
+
+ChromeUtils.import("resource://gre/modules/Services.jsm");
+
+for (let script of [
+]) {
+  Services.scriptloader.loadSubScript(script, window);
+}
+
--- a/common/jar.mn
+++ b/common/jar.mn
@@ -1,3 +1,4 @@
 messenger.jar:
     content/messenger/overlayBindings.css (content/overlayBindings.css)
     content/messenger/overlayBindings.xml (content/overlayBindings.xml)
+    content/messenger/customElements.js   (content/customElements.js)
--- a/mail/components/mailGlue.js
+++ b/mail/components/mailGlue.js
@@ -124,16 +124,28 @@ MailGlue.prototype = {
     case "chrome-document-global-created":
       // Set up lwt, but only if the "lightweightthemes" attr is set on the root
       // (i.e. in messenger.xul).
       aSubject.addEventListener("DOMContentLoaded", () => {
         if (aSubject.document.documentElement.hasAttribute("lightweightthemes")) {
           new LightweightThemeConsumer(aSubject.document);
         }
       }, {once: true});
+
+      // Set up our custom elements.
+      aSubject.addEventListener("DOMDocElementInserted", () => {
+        let doc = aSubject.document;
+        if (doc.nodePrincipal.isSystemPrincipal && (
+            doc.contentType == "application/vnd.mozilla.xul+xml" ||
+            doc.contentType == "application/xhtml+xml"
+        )) {
+          Services.scriptloader.loadSubScript(
+            "chrome://messenger/content/customElements.js", doc.ownerGlobal);
+        }
+      }, {once: true});
       break;
     }
   },
 
   //nsIMailGlue implementation
   sanitize: function MG_sanitize(aParentWindow) {
     this._sanitizer.sanitize(aParentWindow);
   },