|
1 <!DOCTYPE html> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=postMessage |
|
5 --> |
|
6 <head> |
|
7 <title>Dispatching MessageEvent across origins</title> |
|
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
10 </head> |
|
11 <body> |
|
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=postMessage">Mozilla Bug 387706</a> |
|
13 <p id="display"></p> |
|
14 <div id="content" style="display: none"></div> |
|
15 |
|
16 <iframe src="http://example.com/" name="otherDomain"></iframe> |
|
17 |
|
18 <pre id="test"> |
|
19 <script class="testbody" type="application/javascript"> |
|
20 /** Test for Bug 387706 **/ |
|
21 |
|
22 SimpleTest.waitForExplicitFinish(); |
|
23 |
|
24 function run() |
|
25 { |
|
26 try |
|
27 { |
|
28 var msg = new MessageEvent('message', { bubbles: true, cancelable: true, |
|
29 data: "foo", origin: "http://evil.com", |
|
30 source: window }); |
|
31 |
|
32 try |
|
33 { |
|
34 var ex; |
|
35 window.frames.otherDomain.dispatchEvent(msg); |
|
36 ok(false, "should have thrown a security exception per HTML5"); |
|
37 } |
|
38 catch (e) |
|
39 { |
|
40 ok(true, "correctly threw an exception (security exception, but " + |
|
41 "what that entails isn't yet defined in the spec)"); |
|
42 } |
|
43 } |
|
44 catch (e) |
|
45 { |
|
46 ok(false, "threw exception during execution: " + e); |
|
47 } |
|
48 finally |
|
49 { |
|
50 SimpleTest.finish(); |
|
51 } |
|
52 } |
|
53 |
|
54 addLoadEvent(run); |
|
55 |
|
56 </script> |
|
57 </pre> |
|
58 </body> |
|
59 </html> |