Bug 1452097 [wpt PR 9952] - Make 2 tests immune to legitimate races between cross-origin subframes, a=testonly
authorLukasz Anforowicz <lukasza@chromium.org>
Mon, 09 Apr 2018 14:33:07 +0000
changeset 413452 861650deaddc7dfc160136f40bf3f7c83c504e09
parent 413451 30dcfcdfd6d69d61113270b93ac4582c7e42a6ef
child 413453 617aa7ff212bde9c77dcfece83952e9187f510f3
push id33850
push userapavel@mozilla.com
push dateMon, 16 Apr 2018 09:53:48 +0000
treeherdermozilla-central@6276ec7ebbf3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1452097, 820589, 957587, 542360
milestone61.0a1
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 1452097 [wpt PR 9952] - Make 2 tests immune to legitimate races between cross-origin subframes, a=testonly Automatic update from web-platform-testsMake 2 tests immune to legitimate races between cross-origin subframes Bug: 820589 Change-Id: I16c02746c61f42fafead5f96ae436b331fba4f85 Reviewed-on: https://chromium-review.googlesource.com/957587 Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org> Reviewed-by: Alex Moshchuk <alexmos@chromium.org> Cr-Commit-Position: refs/heads/master@{#542360} wpt-commits: 1f638e87c2b4411c53121108efc7aa19df8bc543 wpt-pr: 9952 wpt-commits: 1f638e87c2b4411c53121108efc7aa19df8bc543 wpt-pr: 9952
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/webmessaging/event.origin.sub.htm
testing/web-platform/tests/webmessaging/postMessage_asterisk_xorigin.sub.htm
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -601727,17 +601727,17 @@
    "483e03e9528f1e80fc1b250caee46f7f256d63c1",
    "testharness"
   ],
   "webmessaging/event.data.sub.htm": [
    "994c26d63d21f6acabc9e5c2af667e1d557040b3",
    "testharness"
   ],
   "webmessaging/event.origin.sub.htm": [
-   "ef14b99d3eac8c17623f3ba531605fa2abda99d7",
+   "591a0bcef635d7158fe9c04fabfeea030dce9c62",
    "testharness"
   ],
   "webmessaging/event.ports.sub.htm": [
    "5602124712a02f09cb3f3d308296f74b9a53b321",
    "testharness"
   ],
   "webmessaging/event.source.htm": [
    "b38e018a06db8f72c0667f09225fee2582e7ab2a",
@@ -601807,17 +601807,17 @@
    "f043db56fee6884bdebb1a4277b2e101117b83bf",
    "testharness"
   ],
   "webmessaging/postMessage_arrays.sub.htm": [
    "65d37966d422765b158d053e2777a0dc31a492d0",
    "testharness"
   ],
   "webmessaging/postMessage_asterisk_xorigin.sub.htm": [
-   "d322154c452e58241091b2e5fc995d0322dfc4dd",
+   "0d77e50f5ccdec34f98694ddcc266a1834250266",
    "testharness"
   ],
   "webmessaging/postMessage_dup_transfer_objects.htm": [
    "f532bee27c9d39bef192cccb6340cc602a2cbf6f",
    "testharness"
   ],
   "webmessaging/postMessage_invalid_targetOrigin.htm": [
    "4b713bede2da936874e780a4b8ea8c0acdfc4a3f",
--- a/testing/web-platform/tests/webmessaging/event.origin.sub.htm
+++ b/testing/web-platform/tests/webmessaging/event.origin.sub.htm
@@ -37,20 +37,30 @@
         {
             TARGET1.contentWindow.postMessage("#1", XORIGIN);
             TARGET2.contentWindow.postMessage("#2", SORIGIN);
         }
     }
 
     window.onmessage = t.step_func(function(e)
     {
-        // testharness.js uses postMessage so we must check what data we want to receive
-        if (e.data.toString() === "#1" || e.data.toString() === "#2") {
-            ActualResult.push(e.data, e.origin);
-            if (ActualResult.length === ExpectedResult.length) {
-                assert_array_equals(ActualResult, ExpectedResult, "ActualResult");
-                t.done();
-            }
+        // Messages from TARGET1 and TARGET2 can come in any order
+        // (since one of them is cross-origin and can run in parallel).
+        // To make the tests immune to message reordering, always
+        // put the response from TARGET1 at the start of the list.
+        if (e.data.toString() === "#1")
+        {
+            ActualResult = [e.data, e.origin].concat(ActualResult);
+        }
+        else if (e.data.toString() === "#2")
+        {
+            ActualResult = ActualResult.concat([e.data, e.origin]);
+        }
+
+        if (ActualResult.length >= ExpectedResult.length)
+        {
+            assert_array_equals(ActualResult, ExpectedResult, "ActualResult");
+            t.done();
         }
     });
 </script>
 </body>
 </html>
--- a/testing/web-platform/tests/webmessaging/postMessage_asterisk_xorigin.sub.htm
+++ b/testing/web-platform/tests/webmessaging/postMessage_asterisk_xorigin.sub.htm
@@ -37,17 +37,28 @@
         {
             TARGET1.contentWindow.postMessage("#1", "*");
             TARGET2.contentWindow.postMessage("#2", "*");
         }
     }
 
     window.onmessage = t.step_func(function(e)
     {
-        ActualResult.push(e.data, e.origin);
+        // Messages from TARGET1 and TARGET2 can come in any order
+        // (since one of them is cross-origin and can run in parallel).
+        // To make the tests immune to message reordering, always
+        // put the response from TARGET1 at the start of the list.
+        if (e.data.toString() === "#1")
+        {
+            ActualResult = [e.data, e.origin].concat(ActualResult);
+        }
+        else if (e.data.toString() === "#2")
+        {
+            ActualResult = ActualResult.concat([e.data, e.origin]);
+        }
 
         if (ActualResult.length >= ExpectedResult.length)
         {
             assert_array_equals(ActualResult, ExpectedResult, "ActualResult");
             t.done();
         }
     });
 </script>