1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
4 add_task(async function() {
5 let sb = new Cu.Sandbox('http://www.example.com',
6 { wantGlobalProperties: ["MessageChannel"] });
8 Cu.evalInSandbox('ok((new MessageChannel()) instanceof MessageChannel);',
10 Cu.evalInSandbox('ok((new MessageChannel()).port1 instanceof MessagePort);',
13 Cu.importGlobalProperties(["MessageChannel"]);
15 let mc = new MessageChannel();
16 Assert.ok(mc instanceof MessageChannel);
17 Assert.ok(mc.port1 instanceof MessagePort);
18 Assert.ok(mc.port2 instanceof MessagePort);
20 mc.port1.postMessage(42);
22 let result = await new Promise(resolve => {
23 mc.port2.onmessage = e => {
28 Assert.equal(result, 42);