Bug 1097423 - Fix raciness in the test. r=smaug, a=test-only
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 08 Sep 2016 17:47:30 -0400
changeset 348151 2d86f107aea835f0b56176871a43d144c7fff78c
parent 348150 f35ba1281407025c188ab7f1aa0cf56f0d5e940c
child 348152 d5a7d41af3fa77876118d280cc824713b74a2dcf
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, test-only
bugs1097423
milestone50.0a2
Bug 1097423 - Fix raciness in the test. r=smaug, a=test-only
testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_allow_script.html
--- a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_allow_script.html
+++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_allow_script.html
@@ -2,19 +2,20 @@
 <meta charset="uft-8">
 <title>HTML Test: iframe_sandbox_allow_scripts</title>
 <link rel="author" title="Intel" href="http://www.intel.com/">
 <link rel="help" href="https://html.spec.whatwg.org/multipage/#attr-iframe-sandbox">
 <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-iframe-element">
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 
-<iframe id="testIframe" src="support/sandbox_allow_script.html" sandbox="allow-same-origin" style="display:none"></iframe>
 <div id="log"></div>
 <script>
+  // Set up all our script stuff before the iframe starts loading, so we don't
+  // miss any messages from it.
   var step1 = false;
   var t = async_test("iframe_sandbox_allow_scripts");
 
   setup({timeout:1000});
   window.addEventListener("message", callback1, false);
 
   function run() {
     window.removeEventListener("message", callback1, false);
@@ -30,10 +31,16 @@
   function callback2(e) {
     t.step(function () {
       assert_false(step1, "[allow-scripts] is not set.");
       assert_equals(e.data, "Script executed", "[allow-scripts] is set.");
     });
     t.done();
   }
 
-  setTimeout(run, 500);
+  // Make sure the iframe loads before we mess with it.
+  window.addEventListener("load", function() {
+    // The load event might fire before a message from the child comes in...
+    // Wait a bit to see if that message does come in.
+    setTimeout(run, 500);
+  });
 </script>
+<iframe id="testIframe" src="support/sandbox_allow_script.html" sandbox="allow-same-origin" style="display:none"></iframe>