зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset fc73a1225106 (bug 1509292) for causing build bustages CLOSED TREE
This commit is contained in:
Родитель
fafd525cc9
Коммит
c57127be79
|
@ -0,0 +1,22 @@
|
|||
onmessage = function(evt) {
|
||||
if (evt.data != 0) {
|
||||
var worker = new Worker("broadcastchannel_worker.js");
|
||||
worker.onmessage = function(event) {
|
||||
postMessage(event.data);
|
||||
};
|
||||
worker.postMessage(evt.data - 1);
|
||||
return;
|
||||
}
|
||||
|
||||
var bc = new BroadcastChannel("foobar");
|
||||
bc.addEventListener("message", function(event) {
|
||||
bc.postMessage(
|
||||
event.data == "hello world from the window"
|
||||
? "hello world from the worker"
|
||||
: "KO"
|
||||
);
|
||||
bc.close();
|
||||
});
|
||||
|
||||
postMessage("READY");
|
||||
};
|
|
@ -20,6 +20,7 @@ support-files =
|
|||
skip-if = debug && ((os == "mac") || (os == "linux" && bits == 64) || (os == "android")) #Bug 1447586
|
||||
[test_broadcastchannel_self.html]
|
||||
[test_broadcastchannel_sharedWorker.html]
|
||||
[test_broadcastchannel_worker.html]
|
||||
[test_broadcastchannel_worker_alive.html]
|
||||
[test_bfcache.html]
|
||||
[test_event_listener_leaks.html]
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
Tests of DOM BroadcastChannel in workers
|
||||
-->
|
||||
<head>
|
||||
<title>Test for BroadcastChannel in workers</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" language="javascript">
|
||||
|
||||
function testWorker(x) {
|
||||
var worker = new Worker("broadcastchannel_worker.js");
|
||||
|
||||
var bc = new BroadcastChannel("foobar");
|
||||
|
||||
worker.onmessage = function(event) {
|
||||
if (event.data == "READY") {
|
||||
ok(true, "Worker is ready!");
|
||||
bc.postMessage("hello world from the window");
|
||||
} else {
|
||||
ok(false, "Something wrong happened");
|
||||
}
|
||||
};
|
||||
|
||||
bc.onmessage = function(event) {
|
||||
is("hello world from the worker", event.data, "The message matches!");
|
||||
bc.close();
|
||||
runTests();
|
||||
};
|
||||
|
||||
worker.postMessage(x);
|
||||
}
|
||||
|
||||
var tests = [ 0, 3 ];
|
||||
function runTests() {
|
||||
if (tests.length == 0) {
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
testWorker(tests.shift());
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
runTests();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче