summaryrefslogtreecommitdiffstats
path: root/dom/events/test/test_messageEvent.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/events/test/test_messageEvent.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/events/test/test_messageEvent.html')
-rw-r--r--dom/events/test/test_messageEvent.html79
1 files changed, 79 insertions, 0 deletions
diff --git a/dom/events/test/test_messageEvent.html b/dom/events/test/test_messageEvent.html
new file mode 100644
index 000000000..0402649af
--- /dev/null
+++ b/dom/events/test/test_messageEvent.html
@@ -0,0 +1,79 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=848294
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 848294</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+ <script type="application/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+ <script type="application/javascript">
+ function testMessageEvent(e, test) {
+ ok(e, "MessageEvent created");
+ is(e.type, 'message', 'MessageEvent.type is right');
+
+ is(e.data, 'data' in test ? test.data : null, 'MessageEvent.data is ok');
+ is(e.origin, 'origin' in test ? test.origin : '', 'MessageEvent.origin is ok');
+ is(e.lastEventId, 'lastEventId' in test ? test.lastEventId : '', 'MessageEvent.lastEventId is ok');
+ is(e.source, 'source' in test ? test.source : null, 'MessageEvent.source is ok');
+
+ if (test.ports != undefined) {
+ is(e.ports.length, test.ports.length, 'MessageEvent.ports is ok');
+ is(e.ports, e.ports, 'MessageEvent.ports is ok');
+ } else {
+ ok(!('ports' in test) || test.ports == null, 'MessageEvent.ports is ok');
+ }
+ }
+
+ function runTest() {
+ var channel = new MessageChannel();
+
+ var tests = [
+ {},
+ { data: 42 },
+ { data: {} },
+ { data: true, origin: 'wow' },
+ { data: [], lastEventId: 'wow2' },
+ { data: null, source: null },
+ { data: window, source: window },
+ { data: window, source: channel.port1 },
+ { data: window, source: channel.port1, ports: [ channel.port1, channel.port2 ] },
+ { data: null, ports: [] },
+ ];
+
+ while (tests.length) {
+ var test = tests.shift();
+
+ var e = new MessageEvent('message', test);
+ testMessageEvent(e, test);
+
+ e = new MessageEvent('message');
+ e.initMessageEvent('message', true, true,
+ 'data' in test ? test.data : null,
+ 'origin' in test ? test.origin : '',
+ 'lastEventId' in test ? test.lastEventId : '',
+ 'source' in test ? test.source : null,
+ 'ports' in test ? test.ports : []);
+ testMessageEvent(e, test);
+ }
+
+ try {
+ var e = new MessageEvent('foobar', { source: 42 });
+ ok(false, "Source has to be a window or a port");
+ } catch(e) {
+ ok(true, "Source has to be a window or a port");
+ }
+
+ SimpleTest.finish();
+ }
+
+ SimpleTest.waitForExplicitFinish();
+ runTest();
+ </script>
+</body>
+</html>