2008-01-29 17:31:29 -08:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=postMessage
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>postMessage called through a different same-origin page</title>
|
2009-05-06 13:46:04 -07:00
|
|
|
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
2008-01-29 17:31:29 -08:00
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=postMessage">Mozilla Bug 387706</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none"></div>
|
|
|
|
|
2008-05-02 12:26:47 -07:00
|
|
|
<iframe src="http://example.com/tests/dom/tests/mochitest/whatwg/postMessage_onOther.html"
|
|
|
|
name="topDomainFrame"></iframe>
|
|
|
|
<iframe src="http://test1.example.com/tests/dom/tests/mochitest/whatwg/postMessage_onOther.html"
|
|
|
|
name="subDomainFrame"></iframe>
|
2008-01-29 17:31:29 -08:00
|
|
|
|
|
|
|
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="application/javascript">
|
|
|
|
/** Test for Bug 387706 **/
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
/** Receives MessageEvents to this window. */
|
|
|
|
function messageReceiver(evt)
|
|
|
|
{
|
|
|
|
ok(evt instanceof MessageEvent, "wrong event type");
|
2008-05-02 12:26:47 -07:00
|
|
|
is(evt.origin, "http://test1.example.com", "unexpected origin");
|
|
|
|
is(evt.lastEventId, "", "postMessage creates events with empty lastEventId");
|
|
|
|
is(evt.data, "test-finished",
|
2008-01-29 17:31:29 -08:00
|
|
|
"unexpected data in message");
|
|
|
|
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
2008-05-02 12:26:47 -07:00
|
|
|
function run()
|
2008-01-29 17:31:29 -08:00
|
|
|
{
|
2008-05-02 12:26:47 -07:00
|
|
|
window.frames.subDomainFrame.postMessage("start-test",
|
|
|
|
"http://test1.example.com");
|
2008-01-29 17:31:29 -08:00
|
|
|
}
|
|
|
|
|
2008-05-02 12:26:47 -07:00
|
|
|
window.addEventListener("message", messageReceiver, false);
|
|
|
|
window.addEventListener("load", run, false);
|
2008-01-29 17:31:29 -08:00
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|