Bug 1097423. Fix raciness in the test. r=smaug
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 08 Sep 2016 17:47:30 -0400
changeset 313383 6820b76ed3784fc08ce64375ccdd9c70c90a8db4
parent 313382 bb033983fe8d5128bc3e01df3b56974898e25c57
child 313384 1614e7c150b91a166935053e6b343dbab127902c
push id30679
push usercbook@mozilla.com
push dateFri, 09 Sep 2016 10:03:06 +0000
treeherdermozilla-central@feff79e5b137 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1097423. Fix raciness in the test. r=smaug
--- 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>
+  // 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");
   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.");
-  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);
+  });
+<iframe id="testIframe" src="support/sandbox_allow_script.html" sandbox="allow-same-origin" style="display:none"></iframe>