Bug 1320744 - Part 4, Allow iframes in test_bug440572.html to be loaded out of sequence. r=mrbkap. draft
authorShih-Chiang Chien <schien@mozilla.com>
Sun, 26 Mar 2017 22:37:01 +0800
changeset 551476 5cd705359887e260b96908cf4bc8f69cea03a4dc
parent 551270 88e9c56a73d268e1313c654c78a14e7b7d04fd9b
child 621550 752f2eaff70ae43f8601a7008991fe760ef40c34
push id51059
push userbmo:schien@mozilla.com
push dateSun, 26 Mar 2017 16:37:19 +0000
reviewersmrbkap
bugs1320744, 440572
milestone55.0a1
Bug 1320744 - Part 4, Allow iframes in test_bug440572.html to be loaded out of sequence. r=mrbkap. MozReview-Commit-ID: Hl7kGHP6ILQ
dom/tests/mochitest/bugs/iframe_bug440572.html
dom/tests/mochitest/bugs/test_bug440572.html
--- a/dom/tests/mochitest/bugs/iframe_bug440572.html
+++ b/dom/tests/mochitest/bugs/iframe_bug440572.html
@@ -1,17 +1,23 @@
 <html>
 <body>
 <script>
 
 var success = 0;
 
 try {
   parent[name].success = 1;
-  parent.postMessage(success ? "success" : "failure", "http://mochi.test:8888");
+  parent.postMessage({
+    from: name,
+    result: success ? "success" : "failure"
+  }, "http://mochi.test:8888");
 } catch (e) {
-  parent.postMessage(e.toString(), "http://mochi.test:8888");
+  parent.postMessage({
+    from: name,
+    result: e.toString()
+  }, "http://mochi.test:8888");
 }
 
 </script>
 <p>Move on, nothing to see here...</p>
 </body>
 </html>
--- a/dom/tests/mochitest/bugs/test_bug440572.html
+++ b/dom/tests/mochitest/bugs/test_bug440572.html
@@ -10,32 +10,32 @@ https://bugzilla.mozilla.org/show_bug.cg
 </head>
 <body onload="runtests()">
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=440572">Mozilla Bug 440572</a>
 
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 440572 **/
 
-var messages = [];
+var messages = new Map();
 
 function receiveMessage(e)
 {
   is(e.origin, "http://example.org", "wrong sender!");
-  messages.push(e.data);
+  messages.set(e.data.from, e.data.result);
 }
 
 window.addEventListener("message", receiveMessage);
 
 function runtests()
 {
-  is(messages.length, 3, "received the right number of messages.");
-  is(messages[0], "success", "test in frame failed.");
-  isnot(messages[1], "success", "parent[\"content\"] should be the WebIDL property of Window.");
-  isnot(messages[2], "success", "parent[\"dump\"] should be the WebIDL property of Window.");
+  is(messages.size, 3, "received the right number of messages.");
+  is(messages.get("test"), "success", "test in frame failed.");
+  isnot(messages.get("content"), "success", "parent[\"content\"] should be the WebIDL property of Window.");
+  isnot(messages.get("dump"), "success", "parent[\"dump\"] should be the WebIDL property of Window.");
 
   SimpleTest.finish();
 }
 
 SimpleTest.waitForExplicitFinish();
 </script>
 <br>
 <iframe name="test" src="http://example.org:80/tests/dom/tests/mochitest/bugs/iframe_bug440572.html"></iframe>