Bug 1477956 - Fix "sheet is undefined" message when multiple overlay extensions are enabled; r=Fallen DONTBUILD
authorGeoff Lankow <geoff@darktrojan.net>
Mon, 03 Sep 2018 21:57:32 +1200
changeset 24638 4da4607269c163cfd28c54cb46e6033db77a7882
parent 24637 b67c87c8e4fe8712e75d85e050b107a21198967a
child 24639 653f80572dacaed519eb8f4586ed5fa8b8e9dc3f
push id14823
push usergeoff@darktrojan.net
push dateMon, 03 Sep 2018 09:58:36 +0000
treeherdercomm-central@4da4607269c1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersFallen
bugs1477956
Bug 1477956 - Fix "sheet is undefined" message when multiple overlay extensions are enabled; r=Fallen DONTBUILD
common/src/Overlays.jsm
--- a/common/src/Overlays.jsm
+++ b/common/src/Overlays.jsm
@@ -197,17 +197,19 @@ class Overlays {
       deferredLoad.push(...this.loadScript(script));
     }
 
     if (this.document.readyState == "complete") {
       let sheet;
       let overlayTrigger = this.document.createElement("overlayTrigger");
       overlayTrigger.addEventListener("bindingattached", () => {
         oconsole.debug("XBL binding attached, continuing with load");
-        sheet.remove();
+        if (sheet) {
+          sheet.remove();
+        }
         overlayTrigger.remove();
 
         setTimeout(() => {
           this._finish();
 
           // Now execute load handlers since we are done loading scripts
           let bubbles = [];
           for (let { listener, useCapture } of deferredLoad) {
@@ -219,17 +221,19 @@ class Overlays {
           }
 
           for (let listener of bubbles) {
             this._fireEventListener(listener);
           }
         }, 0);
       }, { once: true });
       this.document.documentElement.appendChild(overlayTrigger);
-      sheet = this.loadCSS("chrome://messenger/content/overlayBindings.css");
+      if (overlayTrigger.parentNode) {
+        sheet = this.loadCSS("chrome://messenger/content/overlayBindings.css");
+      }
     } else {
       this.document.defaultView.addEventListener("load", this._finish.bind(this), { once: true });
     }
   }
 
   _finish() {
     for (let [deck, selectedIndex] of this._decksToResolve.entries()) {
       deck.setAttribute("selectedIndex", selectedIndex);