Bug 1283714 - Wait for test document load in test_child_docshell.html to fix an intermittent. r=bz, a=test-only
authorAlexandre Poirot <poirot.alex@gmail.com>
Mon, 23 Apr 2018 08:19:52 -0700
changeset 463544 fa5b3dea75bab5b3ace870e5926439d87c8f79dc
parent 463543 79ff5f305189a9593d6156f2552af68f555d43ff
child 463545 6d6f3196035ca18d2666f746a32ed8a6e04b2dbb
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, test-only
bugs1283714
milestone60.0
Bug 1283714 - Wait for test document load in test_child_docshell.html to fix an intermittent. r=bz, a=test-only MozReview-Commit-ID: 2qfn77LmG3b
dom/ipc/tests/test_child_docshell.html
--- a/dom/ipc/tests/test_child_docshell.html
+++ b/dom/ipc/tests/test_child_docshell.html
@@ -70,17 +70,25 @@ SpecialPowers.pushPrefEnv({'set':[
                                 .QueryInterface(Ci.nsIDocShell);
       sendAsyncMessage("DOMWindowCreatedReceived", {
         stableChromeEventHandler: chromeEventHandler === docShell.chromeEventHandler,
         iframeHasNewDocShell: new_docShell !== docShell,
         iframeHasSameChromeEventHandler: new_docShell.chromeEventHandler === chromeEventHandler
       });
     });
 
-    let i = content.document.createElement("iframe");
-    i.setAttribute("src", "data:text/html,foo");
-    content.document.documentElement.appendChild(i);
+    function go() {
+      let i = content.document.createElement("iframe");
+      i.setAttribute("src", "data:text/html,foo");
+      content.document.documentElement.appendChild(i);
+    }
+
+    if (content.document.readyState == "complete") {
+      go();
+    } else {
+      addEventListener("load", go, { once: true, capture: true });
+    }
   }, false);
 });
 
 </script>
 </body>
 </html>