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