Bug 1260043 - removed `doc.hidden` check from markup/utils; r=pbro draft
authorMatteo Ferretti <mferretti@mozilla.com>
Wed, 01 Jun 2016 12:32:26 +0200
changeset 373927 356942a69552582134e0e7286fcc8fc24283d519
parent 373320 6617e62776cdf01627f146087690cfc7c883508a
child 522499 d26ce43e6062a33294f1d7fac8584db62c873bc1
push id19875
push userbmo:zer0@mozilla.com
push dateWed, 01 Jun 2016 12:55:59 +0000
reviewerspbro
bugs1260043
milestone49.0a1
Bug 1260043 - removed `doc.hidden` check from markup/utils; r=pbro MozReview-Commit-ID: BN2P5dfqerK
devtools/server/actors/highlighters/utils/markup.js
--- a/devtools/server/actors/highlighters/utils/markup.js
+++ b/devtools/server/actors/highlighters/utils/markup.js
@@ -260,37 +260,29 @@ CanvasFrameAnonymousContentHelper.protot
     // Insert the content node only if the page isn't in a XUL window, and if
     // the document still exists.
     if (!this.highlighterEnv.document.documentElement ||
         isXUL(this.highlighterEnv.window)) {
       return;
     }
     let doc = this.highlighterEnv.document;
 
-    // On B2G, for example, when connecting to keyboard just after startup,
-    // we connect to a hidden document, which doesn't accept
-    // insertAnonymousContent call yet.
-    if (doc.hidden) {
-      // In such scenario, just wait for the document to be visible
-      // before injecting anonymous content.
-      let onVisibilityChange = () => {
-        doc.removeEventListener("visibilitychange", onVisibilityChange);
-        this._insert();
-      };
-      doc.addEventListener("visibilitychange", onVisibilityChange);
-      return;
-    }
-
     // For now highlighters.css is injected in content as a ua sheet because
     // <style scoped> doesn't work inside anonymous content (see bug 1086532).
     // If it did, highlighters.css would be injected as an anonymous content
     // node using CanvasFrameAnonymousContentHelper instead.
     installHelperSheet(this.highlighterEnv.window,
       "@import url('" + STYLESHEET_URI + "');");
     let node = this.nodeBuilder();
+
+    // It was stated that hidden documents don't accept
+    // `insertAnonymousContent` calls yet. That doesn't seems the case anymore,
+    // at least on desktop. Therefore, removing the code that was dealing with
+    // that scenario, fixes when we're adding anonymous content in a tab that
+    // is not the active one (see bug 1260043 and bug 1260044)
     this._content = doc.insertAnonymousContent(node);
   },
 
   _onNavigate: function (e, {isTopLevel}) {
     if (isTopLevel) {
       this._removeAllListeners();
       this._insert();
       this.anonymousContentDocument = this.highlighterEnv.document;