Changeset 145473 in webkit


Ignore:
Timestamp:
Mar 11, 2013 9:22:44 PM (11 years ago)
Author:
commit-queue@webkit.org
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 <jamesr@chromium.org> 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:
Location:
trunk/LayoutTests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r145464 r145473  
     12013-03-11  James Robinson  <jamesr@chromium.org>
     2
     3        [chromium] Fix flaky timeouts in platform/chromium/events/fast/events/intercept-postmessage.html
     4        https://bugs.webkit.org/show_bug.cgi?id=112089
     5
     6        Reviewed by Adam Barth.
     7
     8        This test had a few problems. The most serious is it raced a window.postMessage() from an inline <script> in the
     9        <head> with the HTML parser processing the rest of the testcase. If the HTML parser yielded before parsing out
     10        the <pre id="console">, function recvMsg1 would generate an error accessing the undefined pre. The test also
     11        set up a setTimeout with a timeout of 50ms to run after a postMessage handler. There's no need to wait after
     12        yielding for a timeout, these events are processed in order.
     13
     14        * platform/chromium/fast/events/intercept-postmessage.html:
     15
    1162013-03-11  Adam Barth  <abarth@webkit.org>
    217
  • trunk/LayoutTests/platform/chromium/fast/events/intercept-postmessage.html

    r120792 r145473  
     1<!DOCTYPE html>
    12<html>
    2   <head>
    3     <script>
    4       function write(str) {
    5         pre = document.getElementById('console');
    6         text = document.createTextNode(str + '\n');
    7         pre.appendChild(text);
    8       }
     3  <body><pre id="console"></pre></body>
     4  <script>
     5    function write(str) {
     6      pre = document.getElementById('console');
     7      text = document.createTextNode(str + '\n');
     8      pre.appendChild(text);
     9    }
    910
    10       function recvMsg1(e) {
    11         write("RECV1");
    12         window.removeEventListener("message", recvMsg1, false);
     11    function recvMsg1(e) {
     12      write("RECV1");
     13      window.removeEventListener("message", recvMsg1, false);
    1314
    14         if (window.testRunner)
    15           testRunner.interceptPostMessage = true;
     15      if (window.testRunner)
     16        testRunner.interceptPostMessage = true;
    1617
    17         window.addEventListener("message", recvMsg2, false);
    18         window.postMessage("Message 2", "*");
    19      
    20         // Ensure that we're intercepting postMessages before the origin check
    21         window.postMessage("Message 3", "http://example.org");
     18      window.addEventListener("message", recvMsg2, false);
     19      window.postMessage("Message 2", "*");
    2220
    23         // We need to call setTimeout here because we intercept the next event.
    24         // If this test becomes flaky, you may need to increase this timeout.
    25         window.setTimeout("done()", 50);
    26       }
    27 
    28       function recvMsg2(e) {
    29         write("RECV2");
    30       }
    31 
    32       function done() {
    33         if (window.testRunner)
    34           window.testRunner.notifyDone();
    35       }
    36 
    37       window.addEventListener("message", recvMsg1, false);
     21      // Ensure that we're intercepting postMessages before the origin check
     22      window.postMessage("Message 3", "http://example.org");
    3823
    3924      if (window.testRunner) {
    40         window.testRunner.dumpAsText();
    41         window.testRunner.waitUntilDone();
     25        // We need to call setTimeout here because we intercept the next event.
     26        window.setTimeout(function() { testRunner.notifyDone(); });
    4227      }
     28    }
    4329
    44       window.postMessage("Message 1", "*");
    45     </script>
    46   </head>
    47   <body><pre id="console"></pre></body>
     30    function recvMsg2(e) {
     31      write("RECV2");
     32    }
     33
     34    window.addEventListener("message", recvMsg1, false);
     35
     36    if (window.testRunner) {
     37      window.testRunner.dumpAsText();
     38      window.testRunner.waitUntilDone();
     39    }
     40
     41    window.postMessage("Message 1", "*");
     42  </script>
    4843</html>
    4944
Note: See TracChangeset for help on using the changeset viewer.