1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/whatwg/test_MessageEvent_dispatchToOther.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,59 @@ 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>Dispatching MessageEvent across origins</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/" name="otherDomain"></iframe> 1.20 + 1.21 +<pre id="test"> 1.22 +<script class="testbody" type="application/javascript"> 1.23 +/** Test for Bug 387706 **/ 1.24 + 1.25 +SimpleTest.waitForExplicitFinish(); 1.26 + 1.27 +function run() 1.28 +{ 1.29 + try 1.30 + { 1.31 + var msg = new MessageEvent('message', { bubbles: true, cancelable: true, 1.32 + data: "foo", origin: "http://evil.com", 1.33 + source: window }); 1.34 + 1.35 + try 1.36 + { 1.37 + var ex; 1.38 + window.frames.otherDomain.dispatchEvent(msg); 1.39 + ok(false, "should have thrown a security exception per HTML5"); 1.40 + } 1.41 + catch (e) 1.42 + { 1.43 + ok(true, "correctly threw an exception (security exception, but " + 1.44 + "what that entails isn't yet defined in the spec)"); 1.45 + } 1.46 + } 1.47 + catch (e) 1.48 + { 1.49 + ok(false, "threw exception during execution: " + e); 1.50 + } 1.51 + finally 1.52 + { 1.53 + SimpleTest.finish(); 1.54 + } 1.55 +} 1.56 + 1.57 +addLoadEvent(run); 1.58 + 1.59 +</script> 1.60 +</pre> 1.61 +</body> 1.62 +</html>