Bug 1283714 - Wait for test document load in test_child_docshell.html to fix an intermittent. r=bz draft
authorAlexandre Poirot <poirot.alex@gmail.com>
Mon, 23 Apr 2018 08:19:52 -0700
changeset 787200 28830629b38d5a15ecd2d00870e710c9b0a0e289
parent 786343 378a8a64401f765bfd0706ff678a4f5db7c05385
push id107683
push userbmo:poirot.alex@gmail.com
push dateTue, 24 Apr 2018 14:54:11 +0000
reviewersbz
bugs1283714
milestone61.0a1
Bug 1283714 - Wait for test document load in test_child_docshell.html to fix an intermittent. r=bz 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
@@ -71,17 +71,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>