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=848294 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <meta charset="utf-8"> |
michael@0 | 8 | <title>Test for Bug 848294</title> |
michael@0 | 9 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 11 | <script type="application/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script> |
michael@0 | 12 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 13 | </head> |
michael@0 | 14 | <body> |
michael@0 | 15 | <script type="application/javascript"> |
michael@0 | 16 | function runTest() { |
michael@0 | 17 | var channel = new MessageChannel(); |
michael@0 | 18 | |
michael@0 | 19 | var tests = [ |
michael@0 | 20 | {}, |
michael@0 | 21 | { data: 42 }, |
michael@0 | 22 | { data: {} }, |
michael@0 | 23 | { data: true, origin: 'wow' }, |
michael@0 | 24 | { data: [], lastEventId: 'wow2' }, |
michael@0 | 25 | { data: null, source: null }, |
michael@0 | 26 | { data: window, source: window }, |
michael@0 | 27 | { data: window, source: channel.port1 }, |
michael@0 | 28 | { data: window, source: channel.port1, ports: [ channel.port1, channel.port2 ] }, |
michael@0 | 29 | { data: null, ports: null }, |
michael@0 | 30 | ]; |
michael@0 | 31 | |
michael@0 | 32 | while (tests.length) { |
michael@0 | 33 | var test = tests.shift(); |
michael@0 | 34 | |
michael@0 | 35 | var e = new MessageEvent('message', test); |
michael@0 | 36 | ok(e, "MessageEvent created"); |
michael@0 | 37 | is(e.type, 'message', 'MessageEvent.type is right'); |
michael@0 | 38 | |
michael@0 | 39 | is(e.data, 'data' in test ? test.data : undefined, 'MessageEvent.data is ok'); |
michael@0 | 40 | is(e.origin, 'origin' in test ? test.origin : '', 'MessageEvent.origin is ok'); |
michael@0 | 41 | is(e.lastEventId, 'lastEventId' in test ? test.lastEventId : '', 'MessageEvent.lastEventId is ok'); |
michael@0 | 42 | is(e.source, 'source' in test ? test.source : undefined, 'MessageEvent.source is ok'); |
michael@0 | 43 | |
michael@0 | 44 | if (test.ports != undefined) { |
michael@0 | 45 | is(e.ports.length, test.ports.length, 'MessageEvent.ports is ok'); |
michael@0 | 46 | is(e.ports, e.ports, 'MessageEvent.ports is ok'); |
michael@0 | 47 | } else { |
michael@0 | 48 | ok(!('ports' in test) || test.ports == null, 'MessageEvent.ports is ok'); |
michael@0 | 49 | } |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | try { |
michael@0 | 53 | var e = new MessageEvent('foobar', { source: 42 }); |
michael@0 | 54 | ok(false, "Source has to be a window or a port"); |
michael@0 | 55 | } catch(e) { |
michael@0 | 56 | ok(true, "Source has to be a window or a port"); |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | SimpleTest.finish(); |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 63 | SpecialPowers.pushPrefEnv({"set": [["dom.messageChannel.enabled", true]]}, runTest); |
michael@0 | 64 | </script> |
michael@0 | 65 | </body> |
michael@0 | 66 | </html> |