1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/whatwg/test_postMessage_onOther.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,51 @@ 1.4 +<!DOCTYPE html> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=postMessage 1.8 +--> 1.9 +<head> 1.10 + <title>postMessage called through a different same-origin page</title> 1.11 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.13 +</head> 1.14 +<body> 1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=postMessage">Mozilla Bug 387706</a> 1.16 +<p id="display"></p> 1.17 +<div id="content" style="display: none"></div> 1.18 + 1.19 +<iframe src="http://example.com/tests/dom/tests/mochitest/whatwg/postMessage_onOther.html" 1.20 + name="topDomainFrame"></iframe> 1.21 +<iframe src="http://test1.example.com/tests/dom/tests/mochitest/whatwg/postMessage_onOther.html" 1.22 + name="subDomainFrame"></iframe> 1.23 + 1.24 + 1.25 +<pre id="test"> 1.26 +<script class="testbody" type="application/javascript"> 1.27 +/** Test for Bug 387706 **/ 1.28 + 1.29 +SimpleTest.waitForExplicitFinish(); 1.30 + 1.31 +/** Receives MessageEvents to this window. */ 1.32 +function messageReceiver(evt) 1.33 +{ 1.34 + ok(evt instanceof MessageEvent, "wrong event type"); 1.35 + is(evt.origin, "http://test1.example.com", "unexpected origin"); 1.36 + is(evt.lastEventId, "", "postMessage creates events with empty lastEventId"); 1.37 + is(evt.data, "test-finished", 1.38 + "unexpected data in message"); 1.39 + 1.40 + SimpleTest.finish(); 1.41 +} 1.42 + 1.43 +function run() 1.44 +{ 1.45 + window.frames.subDomainFrame.postMessage("start-test", 1.46 + "http://test1.example.com"); 1.47 +} 1.48 + 1.49 +window.addEventListener("message", messageReceiver, false); 1.50 +window.addEventListener("load", run, false); 1.51 +</script> 1.52 +</pre> 1.53 +</body> 1.54 +</html>