mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1370725
- Remove redundant dom/broadcastchannel/tests/test_broadcastchannel_any.html. r=baku
Differential Revision: https://phabricator.services.mozilla.com/D67819 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
e1b33b47fd
commit
6260a0f6e4
@ -1,5 +0,0 @@
|
||||
new BroadcastChannel("foobar").onmessage = function(event) {
|
||||
event.target.postMessage(event.data);
|
||||
};
|
||||
|
||||
postMessage("READY");
|
@ -3,7 +3,6 @@ support-files =
|
||||
iframe_broadcastchannel.html
|
||||
broadcastchannel_sharedWorker.js
|
||||
broadcastchannel_worker_alive.js
|
||||
broadcastchannel_worker_any.js
|
||||
!/dom/events/test/event_leak_utils.js
|
||||
file_mozbrowser.html
|
||||
file_mozbrowser2.html
|
||||
@ -12,7 +11,6 @@ support-files =
|
||||
testUrl1_bfcache.html
|
||||
testUrl2_bfcache.html
|
||||
|
||||
[test_broadcastchannel_any.html]
|
||||
[test_broadcastchannel_basic.html]
|
||||
[test_broadcastchannel_close.html]
|
||||
[test_broadcastchannel_self.html]
|
||||
|
@ -1,143 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for BroadcastChannel</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="content"></div>
|
||||
|
||||
<script type="application/javascript">
|
||||
|
||||
// XXX It is unclear what exactly this test tests and why these different test
|
||||
// cases are needed. Maybe it makes more sense to reduce this to a single test
|
||||
// case, and check whatever the different data should test at another level? In
|
||||
// any case, the purpose of the test should be described. It is likely that
|
||||
// this overlaps with some WPT test, and maybe it can be removed entirely.
|
||||
var tests = [
|
||||
"hello world",
|
||||
123,
|
||||
null,
|
||||
true,
|
||||
new Date(),
|
||||
[ 1, "test", true, new Date() ],
|
||||
{ a: true, b: null, c: new Date(), d: [ true, false, {} ] },
|
||||
new Blob([123], { type: "plain/text" }),
|
||||
];
|
||||
|
||||
var currentTest = null;
|
||||
|
||||
function getType(a) {
|
||||
if (a === null || a === undefined)
|
||||
return "null";
|
||||
|
||||
if (Array.isArray(a))
|
||||
return "array";
|
||||
|
||||
if (typeof a == "object")
|
||||
return "object";
|
||||
|
||||
return "primitive";
|
||||
}
|
||||
|
||||
function compare(a, b) {
|
||||
is(getType(a), getType(b), "Type matches");
|
||||
|
||||
var type = getType(a);
|
||||
if (type == "array") {
|
||||
is(a.length, b.length, "Array.length matches");
|
||||
for (var i = 0; i < a.length; ++i) {
|
||||
compare(a[i], b[i]);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == "object") {
|
||||
ok(a !== b, "They should not match");
|
||||
|
||||
var aProps = [];
|
||||
for (let p in a) aProps.push(p);
|
||||
|
||||
var bProps = [];
|
||||
for (let p in b) bProps.push(p);
|
||||
|
||||
is(aProps.length, bProps.length, "Props match");
|
||||
is(aProps.sort().toString(), bProps.sort().toString(), "Props names match");
|
||||
|
||||
for (let p in a) {
|
||||
compare(a[p], b[p]);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (type != "null") {
|
||||
is(a, b, "Same value");
|
||||
}
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
var count = 2;
|
||||
|
||||
var bc = new BroadcastChannel("foobar");
|
||||
ok(bc, "BroadcastChannel can be created");
|
||||
|
||||
bc.onmessage = function(event) {
|
||||
ok(count < 2, "Still comparing...");
|
||||
info("bc: " + currentTest);
|
||||
compare(event.data, currentTest);
|
||||
++count;
|
||||
next();
|
||||
};
|
||||
|
||||
var bc2 = new BroadcastChannel("foobar");
|
||||
ok(bc2, "BroadcastChannel can be created");
|
||||
|
||||
var toSkip = true;
|
||||
bc2.onmessage = function(event) {
|
||||
toSkip = !toSkip;
|
||||
if (toSkip) return;
|
||||
|
||||
ok(count < 2, "Still comparing...");
|
||||
info("bc2: " + currentTest);
|
||||
compare(event.data, currentTest);
|
||||
++count;
|
||||
next();
|
||||
};
|
||||
|
||||
function next() {
|
||||
if (count < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
is(count, 2, "Just 2 comparations");
|
||||
count = 0;
|
||||
|
||||
if (!tests.length) {
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
currentTest = tests.shift();
|
||||
bc.postMessage(currentTest);
|
||||
info("Posted: " + currentTest);
|
||||
}
|
||||
|
||||
var worker = new Worker("broadcastchannel_worker_any.js");
|
||||
worker.onmessage = function(event) {
|
||||
if (event.data == "READY") {
|
||||
next();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
runTest();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user