mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-08 08:17:31 +09:00
import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo
This commit is contained in:
commit
dcd9973243
150858 changed files with 23884658 additions and 0 deletions
235
dom/messagechannel/tests/test_messageChannel_start.html
Normal file
235
dom/messagechannel/tests/test_messageChannel_start.html
Normal file
|
|
@ -0,0 +1,235 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=677638
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 677638 - start/close</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=677638">Mozilla Bug 677638</a>
|
||||
<div id="content"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
<script type="application/javascript">
|
||||
|
||||
function runTests() {
|
||||
if (!tests.length) {
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
var test = tests.shift();
|
||||
test();
|
||||
}
|
||||
|
||||
function testOnMessage() {
|
||||
var a = new MessageChannel();
|
||||
ok(a, "MessageChannel created");
|
||||
|
||||
a.port1.postMessage(42);
|
||||
a.port2.postMessage(43);
|
||||
ok(true, "MessagePort{1,2}.postmessage() invoked");
|
||||
|
||||
var events = 2;
|
||||
|
||||
a.port1.onmessage = function(evt) {
|
||||
ok(true, "This method should be called");
|
||||
if (!--events) runTests();
|
||||
}
|
||||
|
||||
a.port2.onmessage = function(evt) {
|
||||
ok(true, "This method should be called");
|
||||
if (!--events) runTests();
|
||||
}
|
||||
}
|
||||
|
||||
function testAddEventListener() {
|
||||
var a = new MessageChannel();
|
||||
ok(a, "MessageChannel created");
|
||||
|
||||
a.port1.postMessage(42);
|
||||
a.port2.postMessage(43);
|
||||
ok(true, "MessagePort{1,2}.postmessage() invoked");
|
||||
|
||||
a.port1.addEventListener('message', function(evt) {
|
||||
ok(false, "This method should not be called");
|
||||
}, false);
|
||||
|
||||
a.port2.addEventListener('message', function(evt) {
|
||||
ok(false, "This method should not be called");
|
||||
}, false);
|
||||
|
||||
setTimeout(runTests, 0);
|
||||
}
|
||||
|
||||
function testAddEventListenerAndStart() {
|
||||
var a = new MessageChannel();
|
||||
ok(a, "MessageChannel created");
|
||||
|
||||
a.port1.postMessage(42);
|
||||
a.port2.postMessage(43);
|
||||
ok(true, "MessagePort{1,2}.postmessage() invoked");
|
||||
|
||||
var events = 2;
|
||||
|
||||
a.port1.addEventListener('message', function(evt) {
|
||||
ok(true, "This method should be called");
|
||||
if (!--events) runTests();
|
||||
}, false);
|
||||
|
||||
a.port2.addEventListener('message', function(evt) {
|
||||
ok(true, "This method should be called");
|
||||
if (!--events) runTests();
|
||||
}, false);
|
||||
|
||||
a.port1.start();
|
||||
a.port2.start();
|
||||
}
|
||||
|
||||
function testAddEventListener1AndStart() {
|
||||
var a = new MessageChannel();
|
||||
ok(a, "MessageChannel created");
|
||||
|
||||
a.port1.postMessage(42);
|
||||
a.port2.postMessage(43);
|
||||
ok(true, "MessagePort{1,2}.postmessage() invoked");
|
||||
|
||||
var events = 1;
|
||||
|
||||
a.port1.addEventListener('message', function(evt) {
|
||||
ok(true, "This method should be called");
|
||||
if (!--events) runTests();
|
||||
}, false);
|
||||
|
||||
a.port2.addEventListener('message', function(evt) {
|
||||
ok(false, "This method should not be called");
|
||||
}, false);
|
||||
|
||||
a.port1.start();
|
||||
}
|
||||
|
||||
function testAddEventListener2AndStart() {
|
||||
var a = new MessageChannel();
|
||||
ok(a, "MessageChannel created");
|
||||
|
||||
a.port1.postMessage(42);
|
||||
a.port2.postMessage(43);
|
||||
ok(true, "MessagePort{1,2}.postmessage() invoked");
|
||||
|
||||
var events = 1;
|
||||
|
||||
a.port1.addEventListener('message', function(evt) {
|
||||
ok(false, "This method should not be called");
|
||||
}, false);
|
||||
|
||||
a.port2.addEventListener('message', function(evt) {
|
||||
ok(true, "This method should be called");
|
||||
if (!--events) runTests();
|
||||
}, false);
|
||||
|
||||
a.port2.start();
|
||||
}
|
||||
|
||||
function testTimer() {
|
||||
var a = new MessageChannel();
|
||||
ok(a, "MessageChannel created");
|
||||
|
||||
a.port1.postMessage(42);
|
||||
a.port2.postMessage(43);
|
||||
ok(true, "MessagePort{1,2}.postmessage() invoked");
|
||||
|
||||
setTimeout(function() {
|
||||
var events = 2;
|
||||
a.port1.onmessage = function(evt) {
|
||||
ok(true, "This method should be called");
|
||||
if (!--events) runTests();
|
||||
}
|
||||
|
||||
a.port2.onmessage = function(evt) {
|
||||
ok(true, "This method should be called");
|
||||
if (!--events) runTests();
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
|
||||
function testAddEventListenerAndStartWrongOrder() {
|
||||
var a = new MessageChannel();
|
||||
ok(a, "MessageChannel created");
|
||||
|
||||
a.port1.postMessage(42);
|
||||
a.port2.postMessage(43);
|
||||
ok(true, "MessagePort{1,2}.postmessage() invoked");
|
||||
|
||||
var events = 2;
|
||||
|
||||
a.port1.start();
|
||||
a.port1.addEventListener('message', function(evt) {
|
||||
ok(true, "This method should be called");
|
||||
if (!--events) runTests();
|
||||
}, false);
|
||||
|
||||
a.port2.start();
|
||||
a.port2.addEventListener('message', function(evt) {
|
||||
ok(true, "This method should be called");
|
||||
if (!--events) runTests();
|
||||
}, false);
|
||||
}
|
||||
|
||||
function testOnMessageClone() {
|
||||
var a = new MessageChannel();
|
||||
ok(a, "MessageChannel created");
|
||||
|
||||
a.port1.postMessage(42);
|
||||
a.port2.postMessage(43);
|
||||
ok(true, "MessagePort{1,2}.postmessage() invoked");
|
||||
|
||||
var events = 2;
|
||||
|
||||
addEventListener('message', testOnMessageCloneCb, false);
|
||||
function testOnMessageCloneCb(evt) {
|
||||
a.port1.onmessage = function(evt) {
|
||||
ok(true, "This method should be called");
|
||||
testOnMessageCloneFinish();
|
||||
}
|
||||
|
||||
evt.data.onmessage = function(evt) {
|
||||
ok(true, "This method should be called");
|
||||
testOnMessageCloneFinish();
|
||||
}
|
||||
|
||||
a.port2.onmessage = function(evt) {
|
||||
ok(false, "This method should not be called");
|
||||
}
|
||||
}
|
||||
|
||||
function testOnMessageCloneFinish() {
|
||||
if (!--events) {
|
||||
removeEventListener('message', testOnMessageCloneCb);
|
||||
runTests();
|
||||
}
|
||||
}
|
||||
|
||||
postMessage(a.port2, '*', [a.port2]);
|
||||
}
|
||||
|
||||
var tests = [
|
||||
testOnMessage,
|
||||
testAddEventListener,
|
||||
testAddEventListenerAndStart,
|
||||
testAddEventListener1AndStart,
|
||||
testAddEventListener2AndStart,
|
||||
testTimer,
|
||||
testAddEventListenerAndStartWrongOrder,
|
||||
testOnMessageClone,
|
||||
];
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SimpleTest.requestFlakyTimeout("untriaged");
|
||||
runTests();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue