Title: [145473] trunk/LayoutTests
Revision
145473
Author
[email protected]
Date
2013-03-11 21:22:44 -0700 (Mon, 11 Mar 2013)

Log Message

[chromium] Fix flaky timeouts in platform/chromium/events/fast/events/intercept-postmessage.html
https://bugs.webkit.org/show_bug.cgi?id=112089

Patch by James Robinson <[email protected]> on 2013-03-11
Reviewed by Adam Barth.

This test had a few problems. The most serious is it raced a window.postMessage() from an inline <script> in the
<head> with the HTML parser processing the rest of the testcase. If the HTML parser yielded before parsing out
the <pre id="console">, function recvMsg1 would generate an error accessing the undefined pre. The test also
set up a setTimeout with a timeout of 50ms to run after a postMessage handler. There's no need to wait after
yielding for a timeout, these events are processed in order.

* platform/chromium/fast/events/intercept-postmessage.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (145472 => 145473)


--- trunk/LayoutTests/ChangeLog	2013-03-12 04:02:52 UTC (rev 145472)
+++ trunk/LayoutTests/ChangeLog	2013-03-12 04:22:44 UTC (rev 145473)
@@ -1,3 +1,18 @@
+2013-03-11  James Robinson  <[email protected]>
+
+        [chromium] Fix flaky timeouts in platform/chromium/events/fast/events/intercept-postmessage.html
+        https://bugs.webkit.org/show_bug.cgi?id=112089
+
+        Reviewed by Adam Barth.
+
+        This test had a few problems. The most serious is it raced a window.postMessage() from an inline <script> in the
+        <head> with the HTML parser processing the rest of the testcase. If the HTML parser yielded before parsing out
+        the <pre id="console">, function recvMsg1 would generate an error accessing the undefined pre. The test also
+        set up a setTimeout with a timeout of 50ms to run after a postMessage handler. There's no need to wait after
+        yielding for a timeout, these events are processed in order.
+
+        * platform/chromium/fast/events/intercept-postmessage.html:
+
 2013-03-11  Adam Barth  <[email protected]>
 
         Make BackgroundHTMLParser work with doc.writes that enter or leave foreign content

Modified: trunk/LayoutTests/platform/chromium/fast/events/intercept-postmessage.html (145472 => 145473)


--- trunk/LayoutTests/platform/chromium/fast/events/intercept-postmessage.html	2013-03-12 04:02:52 UTC (rev 145472)
+++ trunk/LayoutTests/platform/chromium/fast/events/intercept-postmessage.html	2013-03-12 04:22:44 UTC (rev 145473)
@@ -1,49 +1,44 @@
+<!DOCTYPE html>
 <html>
-  <head>
-    <script>
-      function write(str) {
-        pre = document.getElementById('console');
-        text = document.createTextNode(str + '\n');
-        pre.appendChild(text);
-      }
+  <body><pre id="console"></pre></body>
+  <script>
+    function write(str) {
+      pre = document.getElementById('console');
+      text = document.createTextNode(str + '\n');
+      pre.appendChild(text);
+    }
 
-      function recvMsg1(e) {
-        write("RECV1");
-        window.removeEventListener("message", recvMsg1, false);
+    function recvMsg1(e) {
+      write("RECV1");
+      window.removeEventListener("message", recvMsg1, false);
 
-        if (window.testRunner)
-          testRunner.interceptPostMessage = true;
+      if (window.testRunner)
+        testRunner.interceptPostMessage = true;
 
-        window.addEventListener("message", recvMsg2, false);
-        window.postMessage("Message 2", "*");
-      
-        // Ensure that we're intercepting postMessages before the origin check
-        window.postMessage("Message 3", "http://example.org"); 
+      window.addEventListener("message", recvMsg2, false);
+      window.postMessage("Message 2", "*");
 
+      // Ensure that we're intercepting postMessages before the origin check
+      window.postMessage("Message 3", "http://example.org");
+
+      if (window.testRunner) {
         // We need to call setTimeout here because we intercept the next event.
-        // If this test becomes flaky, you may need to increase this timeout.
-        window.setTimeout("done()", 50);
+        window.setTimeout(function() { testRunner.notifyDone(); });
       }
+    }
 
-      function recvMsg2(e) {
-        write("RECV2");
-      }
+    function recvMsg2(e) {
+      write("RECV2");
+    }
 
-      function done() {
-        if (window.testRunner)
-          window.testRunner.notifyDone();
-      }
+    window.addEventListener("message", recvMsg1, false);
 
-      window.addEventListener("message", recvMsg1, false);
+    if (window.testRunner) {
+      window.testRunner.dumpAsText();
+      window.testRunner.waitUntilDone();
+    }
 
-      if (window.testRunner) {
-        window.testRunner.dumpAsText();
-        window.testRunner.waitUntilDone();
-      }
-
-      window.postMessage("Message 1", "*");
-    </script>
-  </head>
-  <body><pre id="console"></pre></body>
+    window.postMessage("Message 1", "*");
+  </script>
 </html>
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to