Bug 1320744 - Part 4, Allow iframes in test_bug440572.html to be loaded out of sequence. r=mrbkap.
MozReview-Commit-ID: Hl7kGHP6ILQ
--- 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>