Bug 1508988 - Enable ESLint for dom/abort/, dom/asmjscache/, dom/battery/, dom/broadcastchannel/ and dom/console/ (automatic changes). r=Standard8,nika

Differential Revision: https://phabricator.services.mozilla.com/D14131

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alex Kong 2018-12-19 22:38:44 +00:00
Родитель d402239dae
Коммит a164593e05
42 изменённых файлов: 195 добавлений и 208 удалений

Просмотреть файл

@ -166,22 +166,17 @@ devtools/server/tests/unit/sourcemapped.js
devtools/server/tests/unit/xpcshell_debugging_script.js
# dom/ exclusions
dom/abort/**
dom/animation/**
dom/asmjscache/**
dom/battery/**
dom/base/*.*
dom/base/test/*.*
dom/base/test/unit/test_serializers_entities*.js
dom/base/test/unit_ipc/**
dom/base/test/jsmodules/**
dom/bindings/**
dom/broadcastchannel/**
dom/browser-element/**
dom/cache/test/mochitest/**
dom/cache/test/xpcshell/**
dom/canvas/**
dom/console/**
dom/encoding/**
dom/events/**
dom/fetch/**

Просмотреть файл

@ -1,4 +1,4 @@
function f1() { "use asm"; function g() {} return g }
function f1() { "use asm"; function g() {} return g; }
if (this.jsFuns) {
ok(jsFuns.isAsmJSModule(f1), "f1 is an asm.js module");
ok(jsFuns.isAsmJSFunction(f1()), "f1.g is an asm.js function");
@ -10,8 +10,8 @@ function f2(stdlib, foreign, buffer) {
function main(n) {
n = n|0;
var i = 0, sum = 0;
for (; (i|0) < (n|0); i=(i+1)|0)
sum = (sum + (i32[(i<<2)>>2]|0))|0;
for (; (i|0) < (n|0); i=(i + 1)|0)
sum = (sum + (i32[(i << 2) >> 2]|0))|0;
return sum|0;
}
return main;
@ -41,7 +41,7 @@ function f3(stdlib, foreign, buffer) {
function main() {
var i = 0, sum = 0;
while (1) {
for (i = 0; (i|0) < 1000; i=(i+1)|0)
for (i = 0; (i|0) < 1000; i=(i + 1)|0)
sum = (sum + i)|0;
if (done(sum|0)|0)
break;
@ -58,7 +58,7 @@ function done(sum) {
lastSum = sum;
return (Date.now() - begin) > 3000;
}
var f3Main = f3(this, {done:done}, i32.buffer);
var f3Main = f3(this, {done}, i32.buffer);
if (this.jsFuns)
ok(jsFuns.isAsmJSFunction(f3Main), "f3.main is an asm.js function");

Просмотреть файл

@ -30,8 +30,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=929236
ok(code.length > 100000, "code is long enough to definitely hit the cache");
function evalAsync(code) {
var blob = new Blob([code], {type:"application/javascript"});
var script = document.createElement('script');
var blob = new Blob([code], {type: "application/javascript"});
var script = document.createElement("script");
script.src = URL.createObjectURL(blob);
document.body.appendChild(script);
}
@ -44,7 +44,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=929236
evalAsync(code);
break;
case 1:
ok(jsFuns.isAsmJSModuleLoadedFromCache(module), 'module loaded from cache');
ok(jsFuns.isAsmJSModuleLoadedFromCache(module), "module loaded from cache");
SimpleTest.finish();
break;
default:

Просмотреть файл

@ -45,8 +45,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=944821
}
function evalAsync(code) {
var blob = new Blob([code], {type:"application/javascript"});
var script = document.createElement('script');
var blob = new Blob([code], {type: "application/javascript"});
var script = document.createElement("script");
script.src = URL.createObjectURL(blob);
document.body.appendChild(script);
}
@ -55,13 +55,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=944821
function finishedEvalAsync() {
finishedCount++;
if (finishedCount < 1 || finishedCount > 2*N) {
if (finishedCount < 1 || finishedCount > 2 * N) {
throw "Huh?!";
} else if (finishedCount == N) {
assertCacheHit = true;
for (var i = 0; i < N; i++)
evalAsync(codes[i]);
} else if (finishedCount == 2*N) {
} else if (finishedCount == 2 * N) {
SimpleTest.finish();
}
}

Просмотреть файл

@ -31,11 +31,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=854209
script.src = "http://mochi.test:8888/tests/dom/asmjscache/test/file_slow.js";
document.body.appendChild(script);
var w = new Worker('http://mochi.test:8888/tests/dom/asmjscache/test/file_slow.js');
var w = new Worker("http://mochi.test:8888/tests/dom/asmjscache/test/file_slow.js");
w.onmessage = function(e) {
ok(e.data === "ok", "Worker asm.js tests");
complete();
}
};
SimpleTest.waitForExplicitFinish();
}

Просмотреть файл

@ -28,7 +28,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=941830
var workerCode = asmjsCode;
workerCode += "if (f()() !== 42) postMessage('fail'); else postMessage('ok');";
workerCode = 'var code = "' + workerCode + '"; eval(code); eval(code)';
var workerBlob = new Blob([workerCode], {type:"application/javascript"});
var workerBlob = new Blob([workerCode], {type: "application/javascript"});
var mainCode = asmjsCode;
mainCode += "ok(jsFuns.isAsmJSModuleLoadedFromCache(f), 'f is a cache hit')\n";
@ -36,7 +36,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=941830
mainCode += "ok(jsFuns.isAsmJSFunction(g42), 'g42 is an asm.js function');\n";
mainCode += "ok(g42() === 42, 'g42 returns the correct result');\n";
mainCode += "SimpleTest.finish();\n";
var mainBlob = new Blob([mainCode], {type:"application/javascript"});
var mainBlob = new Blob([mainCode], {type: "application/javascript"});
var w = new Worker(URL.createObjectURL(workerBlob));
@ -51,14 +51,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=941830
ok(e.data === "ok", "Received second message");
received = 2;
var script = document.createElement('script');
var script = document.createElement("script");
script.src = URL.createObjectURL(mainBlob);
document.body.appendChild(script);
break;
default:
throw "Huh?";
}
}
};
SimpleTest.waitForExplicitFinish();
}

Просмотреть файл

@ -20,10 +20,10 @@ SimpleTest.waitForExplicitFinish();
ok("getBattery" in navigator, "navigator.getBattery should exist");
ok(!("battery" in navigator), "navigator.battery should not exist");
navigator.getBattery().then(function (battery) {
navigator.getBattery().then(function(battery) {
ok(battery.level >= 0.0 && battery.level <= 1.0, "Battery level " + battery.level + " should be in the range [0.0, 1.0]");
SpecialPowers.pushPrefEnv({"set": [["dom.battery.test.default", true]]}, function () {
SpecialPowers.pushPrefEnv({"set": [["dom.battery.test.default", true]]}, function() {
ok(battery.charging, "Battery should be charging by default");
is(battery.chargingTime, 0, "Battery chargingTime " + battery.chargingTime + " should be zero by default");
is(battery.dischargingTime, Infinity, "Battery dischargingTime should be Infinity by default");

Просмотреть файл

@ -17,10 +17,10 @@
SimpleTest.waitForExplicitFinish();
/** Test for Battery API **/
navigator.getBattery().then(function (battery) {
navigator.getBattery().then(function(battery) {
ok(battery.level >= 0.0 && battery.level <= 1.0, "Battery level " + battery.level + " should be in the range [0.0, 1.0]");
SpecialPowers.pushPrefEnv({"set": [["dom.battery.test.charging", true]]}, function () {
SpecialPowers.pushPrefEnv({"set": [["dom.battery.test.charging", true]]}, function() {
is(battery.charging, true, "Battery should be charging");
ok(battery.chargingTime >= 0, "Battery chargingTime " + battery.chargingTime + " should be nonnegative when charging");
is(battery.dischargingTime, Infinity, "Battery dischargingTime should be Infinity when charging");

Просмотреть файл

@ -17,10 +17,10 @@
SimpleTest.waitForExplicitFinish();
/** Test for Battery API **/
navigator.getBattery().then(function (battery) {
navigator.getBattery().then(function(battery) {
ok(battery.level >= 0.0 && battery.level <= 1.0, "Battery level " + battery.level + " should be in the range [0.0, 1.0]");
SpecialPowers.pushPrefEnv({"set": [["dom.battery.test.discharging", true]]}, function () {
SpecialPowers.pushPrefEnv({"set": [["dom.battery.test.discharging", true]]}, function() {
is(battery.charging, false, "Battery should be discharging");
is(battery.chargingTime, Infinity, "Battery chargingTime should be Infinity when discharging");
ok(battery.dischargingTime > 0, "Battery dischargingTime " + battery.dischargingTime + " should be positive when discharging");

Просмотреть файл

@ -1,12 +1,12 @@
onconnect = function(evt) {
evt.ports[0].onmessage = function(evt) {
var bc = new BroadcastChannel('foobar');
bc.addEventListener('message', function(event) {
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();
});
evt.target.postMessage("READY");
}
}
};
};

Просмотреть файл

@ -3,16 +3,16 @@ onmessage = function(evt) {
var worker = new Worker("broadcastchannel_worker.js");
worker.onmessage = function(evt) {
postMessage(evt.data);
}
};
worker.postMessage(evt.data - 1);
return;
}
var bc = new BroadcastChannel('foobar');
bc.addEventListener('message', function(event) {
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");
}
};

Просмотреть файл

@ -1,7 +1,7 @@
(new BroadcastChannel('foobar')).addEventListener('message', function(event) {
if (event.data != 'READY') {
(new BroadcastChannel("foobar")).addEventListener("message", function(event) {
if (event.data != "READY") {
event.target.postMessage(event.data);
}
});
(new BroadcastChannel('foobar')).postMessage('READY');
(new BroadcastChannel("foobar")).postMessage("READY");

Просмотреть файл

@ -1,5 +1,5 @@
(new BroadcastChannel('foobar')).onmessage = function(event) {
(new BroadcastChannel("foobar")).onmessage = function(event) {
event.target.postMessage(event.data);
}
};
postMessage("READY");

Просмотреть файл

@ -30,39 +30,39 @@ add_task(async function() {
var p1 = ContentTask.spawn(browser1, null, function(opts) {
return new content.window.Promise(resolve => {
content.window.bc = new content.window.BroadcastChannel('foobar');
content.window.bc.onmessage = function(e) { resolve(e.data); }
content.window.bc = new content.window.BroadcastChannel("foobar");
content.window.bc.onmessage = function(e) { resolve(e.data); };
});
});
var p2 = ContentTask.spawn(browser2, null, function(opts) {
return new content.window.Promise(resolve => {
content.window.bc = new content.window.BroadcastChannel('foobar');
content.window.bc.onmessage = function(e) { resolve(e.data); }
content.window.bc = new content.window.BroadcastChannel("foobar");
content.window.bc.onmessage = function(e) { resolve(e.data); };
});
});
await ContentTask.spawn(browser1, null, function(opts) {
return new content.window.Promise(resolve => {
var bc = new content.window.BroadcastChannel('foobar');
bc.postMessage('hello world from private browsing');
var bc = new content.window.BroadcastChannel("foobar");
bc.postMessage("hello world from private browsing");
resolve();
});
});
await ContentTask.spawn(browser2, null, function(opts) {
return new content.window.Promise(resolve => {
var bc = new content.window.BroadcastChannel('foobar');
bc.postMessage('hello world from non private browsing');
var bc = new content.window.BroadcastChannel("foobar");
bc.postMessage("hello world from non private browsing");
resolve();
});
});
var what1 = await p1;
is(what1, 'hello world from private browsing', 'No messages received from the other window.');
is(what1, "hello world from private browsing", "No messages received from the other window.");
var what2 = await p2;
is(what2, 'hello world from non private browsing', 'No messages received from the other window.');
is(what2, "hello world from non private browsing", "No messages received from the other window.");
BrowserTestUtils.removeTab(tab1);
await BrowserTestUtils.closeWindow(win1);

Просмотреть файл

@ -8,11 +8,11 @@
<div id="container"></div>
<script type="application/javascript">
var ifr = document.createElement('iframe');
ifr.src = 'http://mochi.test:8888/tests/dom/broadcastchannel/tests/iframe_mozbrowser.html';
ifr.onload = function() { alert('DONE'); }
var ifr = document.createElement("iframe");
ifr.src = "http://mochi.test:8888/tests/dom/broadcastchannel/tests/iframe_mozbrowser.html";
ifr.onload = function() { alert("DONE"); };
var domParent = document.getElementById('container');
var domParent = document.getElementById("container");
domParent.appendChild(ifr);
</script>

Просмотреть файл

@ -8,12 +8,12 @@
<div id="container"></div>
<script type="application/javascript">
var ifr = document.createElement('iframe');
ifr.setAttribute('mozbrowser', true);
ifr.src = 'http://mochi.test:8888/tests/dom/broadcastchannel/tests/iframe_mozbrowser2.html';
ifr.onload = function() { alert('DONE'); }
var ifr = document.createElement("iframe");
ifr.setAttribute("mozbrowser", true);
ifr.src = "http://mochi.test:8888/tests/dom/broadcastchannel/tests/iframe_mozbrowser2.html";
ifr.onload = function() { alert("DONE"); };
var domParent = document.getElementById('container');
var domParent = document.getElementById("container");
domParent.appendChild(ifr);
</script>

Просмотреть файл

@ -15,18 +15,18 @@ ok("BroadcastChannel" in window, "BroadcastChannel exists");
var bc = new BroadcastChannel("foobar");
ok(bc, "BroadcastChannel can be created");
is(bc.name, 'foobar', "BroadcastChannel.name is foobar");
is(bc.name, "foobar", "BroadcastChannel.name is foobar");
ok("postMessage" in bc, "BroadcastChannel has postMessage() method");
bc.onmessage = function(evt) {
ok(evt instanceof MessageEvent, 'evt is a MessageEvent');
is(evt.target, bc, 'MessageEvent.target is bc');
is(evt.target.name, 'foobar', 'MessageEvent.target.name is foobar');
is(evt.target.name, bc.name, 'MessageEvent.target.name is bc.name');
ok(evt instanceof MessageEvent, "evt is a MessageEvent");
is(evt.target, bc, "MessageEvent.target is bc");
is(evt.target.name, "foobar", "MessageEvent.target.name is foobar");
is(evt.target.name, bc.name, "MessageEvent.target.name is bc.name");
is(evt.data, "Hello world from the window!", "Message received from the window");
bc.postMessage("Hello world from the iframe!");
}
};
</script>
</body>

Просмотреть файл

@ -7,8 +7,8 @@
<body>
<script type="application/javascript">
var bc = new BroadcastChannel('foobar');
bc.postMessage('This is wrong!');
var bc = new BroadcastChannel("foobar");
bc.postMessage("This is wrong!");
</script>
</body>

Просмотреть файл

@ -7,8 +7,8 @@
<body>
<script type="application/javascript">
var bc = new BroadcastChannel('foobar');
bc.postMessage('This is wrong!');
var bc = new BroadcastChannel("foobar");
bc.postMessage("This is wrong!");
</script>
</body>

Просмотреть файл

@ -39,7 +39,7 @@
if (counter == 0) {
ok(!e.persisted, "test page should have been persisted initially");
bc = new testWin.BroadcastChannel('a');
bc = new testWin.BroadcastChannel("a");
SimpleTest.executeSoon(function() {
info("New location: " + testUrl2);

Просмотреть файл

@ -12,37 +12,37 @@
<script type="application/javascript">
var tests = [
'hello world',
"hello world",
123,
null,
true,
new Date(),
[ 1, 'test', true, new Date() ],
[ 1, "test", true, new Date() ],
{ a: true, b: null, c: new Date(), d: [ true, false, {} ] },
new Blob([123], { type: 'plain/text' })
new Blob([123], { type: "plain/text" }),
];
var currentTest = null;
function getType(a) {
if (a === null || a === undefined)
return 'null';
return "null";
if (Array.isArray(a))
return 'array';
return "array";
if (typeof a == 'object')
return 'object';
if (typeof a == "object")
return "object";
return 'primitive';
return "primitive";
}
function compare(a, b) {
is (getType(a), getType(b), 'Type matches');
is(getType(a), getType(b), "Type matches");
var type = getType(a);
if (type == 'array') {
is (a.length, b.length, 'Array.length matches');
if (type == "array") {
is(a.length, b.length, "Array.length matches");
for (var i = 0; i < a.length; ++i) {
compare(a[i], b[i]);
}
@ -50,8 +50,8 @@ function compare(a, b) {
return;
}
if (type == 'object') {
ok (a !== b, 'They should not match');
if (type == "object") {
ok(a !== b, "They should not match");
var aProps = [];
for (var p in a) aProps.push(p);
@ -59,8 +59,8 @@ function compare(a, b) {
var bProps = [];
for (var p in b) bProps.push(p);
is (aProps.length, bProps.length, 'Props match');
is (aProps.sort().toSource(), bProps.sort().toSource(), 'Props match - using toSource()');
is(aProps.length, bProps.length, "Props match");
is(aProps.sort().toSource(), bProps.sort().toSource(), "Props match - using toSource()");
for (var p in a) {
compare(a[p], b[p]);
@ -69,8 +69,8 @@ function compare(a, b) {
return;
}
if (type != 'null') {
is (a.toSource(), b.toSource(), 'Matching using toSource()');
if (type != "null") {
is(a.toSource(), b.toSource(), "Matching using toSource()");
}
}
@ -86,7 +86,7 @@ function runTest() {
compare(event.data, currentTest);
++count;
next();
}
};
var bc2 = new BroadcastChannel("foobar");
ok(bc2, "BroadcastChannel can be created");
@ -101,7 +101,7 @@ function runTest() {
compare(event.data, currentTest);
++count;
next();
}
};
function next() {
if (count < 2) {

Просмотреть файл

@ -12,11 +12,11 @@
<script type="application/javascript">
function runTest() {
addEventListener('message', receiveMessage, false);
addEventListener("message", receiveMessage, false);
function receiveMessage(evt) {
if (evt.data.status == 'OK') {
if (evt.data.status == "OK") {
ok(true, evt.data.message);
} else if (evt.data.status == 'KO') {
} else if (evt.data.status == "KO") {
ok(false, evt.data.message);
} else {
ok(false, "Unknown message");
@ -27,26 +27,26 @@ function runTest() {
var bc = new BroadcastChannel("foobar");
ok(bc, "BroadcastChannel can be created");
is(bc.name, 'foobar', "BroadcastChannel.name is foobar");
is(bc.name, "foobar", "BroadcastChannel.name is foobar");
ok("postMessage" in bc, "BroadcastChannel has postMessage() method");
bc.onmessage = function(evt) {
ok(evt instanceof MessageEvent, "This is a MessageEvent");
is(evt.target, bc, "MessageEvent.target is bc");
is(evt.target.name, 'foobar', "MessageEvent.target.name is foobar");
is(evt.target.name, "foobar", "MessageEvent.target.name is foobar");
is(evt.target.name, bc.name, "MessageEvent.target.name == bc.name");
ok(evt.origin.indexOf('http://mochi.test:8888') == 0, "MessageEvent.origin is correct");
ok(evt.origin.indexOf("http://mochi.test:8888") == 0, "MessageEvent.origin is correct");
is(evt.data, "Hello world from the iframe!", "The message from the iframe has been received!");
SimpleTest.finish();
}
};
var div = document.getElementById("content");
ok(div, "Parent exists");
var ifr = document.createElement("iframe");
ifr.addEventListener("load", iframeLoaded);
ifr.setAttribute('src', "iframe_broadcastchannel.html");
ifr.setAttribute("src", "iframe_broadcastchannel.html");
div.appendChild(ifr);
function iframeLoaded() {

Просмотреть файл

@ -12,11 +12,11 @@
<script type="application/javascript">
function runTest() {
var receiver = new BroadcastChannel('foo');
var sequence = [ '2', 'done' ];
var receiver = new BroadcastChannel("foo");
var sequence = [ "2", "done" ];
receiver.onmessage = function(e) {
if (!sequence.length) {
ok (false, 'No more data is expected');
ok(false, "No more data is expected");
return;
}
@ -28,29 +28,29 @@ function runTest() {
SimpleTest.finish();
});
}
}
};
var x = new BroadcastChannel('foo');
var x = new BroadcastChannel("foo");
x.close();
try {
x.postMessage('1');
x.postMessage("1");
ok(false, "PostMessage should throw if called after a close().");
} catch(e) {
} catch (e) {
ok(true, "PostMessage should throw if called after a close().");
}
var y = new BroadcastChannel('foo');
y.postMessage('2');
var y = new BroadcastChannel("foo");
y.postMessage("2");
y.close();
try {
y.postMessage('3');
y.postMessage("3");
ok(false, "PostMessage should throw if called after a close().");
} catch(e) {
} catch (e) {
ok(true, "PostMessage should throw if called after a close().");
}
var z = new BroadcastChannel('foo');
z.postMessage('done');
var z = new BroadcastChannel("foo");
z.postMessage("done");
}
SimpleTest.waitForExplicitFinish();

Просмотреть файл

@ -12,23 +12,23 @@
<script type="application/javascript">
function runTest() {
var c1 = new BroadcastChannel('foo');
var c2 = new BroadcastChannel('foo');
var c1 = new BroadcastChannel("foo");
var c2 = new BroadcastChannel("foo");
var status = [];
c2.onmessage = function(e) {
status.push(e.data);
if (status.length == 2) {
is (status[0], 'first', "First message has been received");
is (status[1], 'second', "Second message has been received");
is(status[0], "first", "First message has been received");
is(status[1], "second", "Second message has been received");
SimpleTest.finish();
}
c2.close();
}
};
c1.postMessage('first');
c1.postMessage('second');
c1.postMessage("first");
c1.postMessage("second");
}
SimpleTest.waitForExplicitFinish();

Просмотреть файл

@ -12,8 +12,8 @@
<script type="application/javascript">
function runTest() {
x = new BroadcastChannel('foo');
y = new BroadcastChannel('foo');
x = new BroadcastChannel("foo");
y = new BroadcastChannel("foo");
function func(e) {
is(e.target, y, "The target is !x");
@ -26,7 +26,7 @@ function runTest() {
x.onmessage = func;
y.onmessage = func;
x.postMessage('foo');
x.postMessage("foo");
}
SimpleTest.waitForExplicitFinish();

Просмотреть файл

@ -23,12 +23,12 @@ Tests of DOM BroadcastChannel in SharedWorkers
function runTests() {
var worker = new SharedWorker("broadcastchannel_sharedWorker.js");
var bc = new BroadcastChannel('foobar');
var bc = new BroadcastChannel("foobar");
worker.port.onmessage = function(event) {
if (event.data == "READY") {
ok(true, "SharedWorker is ready!");
bc.postMessage('hello world from the window');
bc.postMessage("hello world from the window");
} else {
ok(false, "Something wrong happened");
}
@ -38,9 +38,9 @@ function runTests() {
is("hello world from the worker", event.data, "The message matches!");
bc.close();
SimpleTest.finish();
}
};
worker.port.postMessage('go');
worker.port.postMessage("go");
}
SimpleTest.waitForExplicitFinish();

Просмотреть файл

@ -23,12 +23,12 @@ Tests of DOM BroadcastChannel in workers
function testWorker(x) {
var worker = new Worker("broadcastchannel_worker.js");
var bc = new BroadcastChannel('foobar');
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');
bc.postMessage("hello world from the window");
} else {
ok(false, "Something wrong happened");
}
@ -38,7 +38,7 @@ function testWorker(x) {
is("hello world from the worker", event.data, "The message matches!");
bc.close();
runTests();
}
};
worker.postMessage(x);
}

Просмотреть файл

@ -22,7 +22,7 @@ Tests of DOM BroadcastChannel in workers
function runTests() {
var id = 0;
(new BroadcastChannel('foobar')).onmessage = function(event) {
(new BroadcastChannel("foobar")).onmessage = function(event) {
info("MSG: " + event.data);
if (event.data == "READY") {

Просмотреть файл

@ -14,10 +14,10 @@
let c = new BroadcastChannel("foo");
try {
try {
c.postMessage(Symbol());
ok(false, "This should throw!");
} catch(e) {
} catch (e) {
ok(true, "This should throw!");
is(e.name, "DataCloneError", "Correct DataCloneError exception thrown");
}

Просмотреть файл

@ -17,17 +17,17 @@ b.postMessage(42);
SimpleTest.waitForExplicitFinish();
onmessage= function(e) {
onmessage = function(e) {
is(e.data, 42, "BroadcastChannel works with data URLs");
SimpleTest.finish();
}
};
var url = "data:text/html,<script>" + document.getElementById("dataURL").textContent + "</" + "script>";
var ifr = document.createElement('iframe');
var ifr = document.createElement("iframe");
document.body.appendChild(ifr);
ifr.setAttribute('sandbox', 'allow-scripts');
ifr.setAttribute("sandbox", "allow-scripts");
ifr.src = url;
</script>
</body>

Просмотреть файл

@ -25,7 +25,7 @@ async function useBroadcastChannel(contentWindow) {
let bc = new contentWindow.BroadcastChannel(name);
let outer = new BroadcastChannel(name);
outer.postMessage('foo');
outer.postMessage("foo");
await new Promise(resolve => {
bc.onmessage = e => {

Просмотреть файл

@ -14,10 +14,10 @@
var c = new BroadcastChannel("foo");
c.close();
try {
try {
c.postMessage("bar");
ok(false, "This should throw!");
} catch(e) {
} catch (e) {
ok(true, "This should throw!");
is(e.name, "InvalidStateError", "Correct invalid-state exception thrown");
}

Просмотреть файл

@ -11,9 +11,9 @@
<script type="application/javascript">
let c1 = new BroadcastChannel('order');
let c2 = new BroadcastChannel('order');
let c3 = new BroadcastChannel('order');
let c1 = new BroadcastChannel("order");
let c2 = new BroadcastChannel("order");
let c3 = new BroadcastChannel("order");
let events = [];
let doneCount = 0;
@ -27,22 +27,22 @@ function whichBC(bc) {
function handler(e) {
events.push(e);
if (e.data == 'done') {
if (e.data == "done") {
doneCount++;
if (doneCount == 2) {
is(events.length, 6, "Correct length");
is(whichBC(events[0].target), "c2", 'target for event 0');
is(events[0].data, 'from c1');
is(whichBC(events[1].target), "c3", 'target for event 1');
is(events[1].data, 'from c1');
is(whichBC(events[2].target), "c1", 'target for event 2');
is(events[2].data, 'from c3');
is(whichBC(events[3].target), "c2", 'target for event 3');
is(events[3].data, 'from c3');
is(whichBC(events[4].target), "c1", 'target for event 4');
is(events[4].data, 'done');
is(whichBC(events[5].target), "c3", 'target for event 5');
is(events[5].data, 'done');
is(whichBC(events[0].target), "c2", "target for event 0");
is(events[0].data, "from c1");
is(whichBC(events[1].target), "c3", "target for event 1");
is(events[1].data, "from c1");
is(whichBC(events[2].target), "c1", "target for event 2");
is(events[2].data, "from c3");
is(whichBC(events[3].target), "c2", "target for event 3");
is(events[3].data, "from c3");
is(whichBC(events[4].target), "c1", "target for event 4");
is(events[4].data, "done");
is(whichBC(events[5].target), "c3", "target for event 5");
is(events[5].data, "done");
SimpleTest.finish();
}
@ -53,9 +53,9 @@ c1.onmessage = handler;
c2.onmessage = handler;
c3.onmessage = handler;
c1.postMessage('from c1');
c3.postMessage('from c3');
c2.postMessage('done');
c1.postMessage("from c1");
c3.postMessage("from c3");
c2.postMessage("done");
SimpleTest.waitForExplicitFinish();

Просмотреть файл

@ -8,13 +8,13 @@ ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
// This constant tells how many messages to process in a single timer execution.
const MESSAGES_IN_INTERVAL = 1500
const MESSAGES_IN_INTERVAL = 1500;
const STORAGE_MAX_EVENTS = 1000;
var _consoleStorage = new Map();
const CONSOLEAPISTORAGE_CID = Components.ID('{96cf7855-dfa9-4c6d-8276-f9705b4890f2}');
const CONSOLEAPISTORAGE_CID = Components.ID("{96cf7855-dfa9-4c6d-8276-f9705b4890f2}");
/**
* The ConsoleAPIStorage is meant to cache window.console API calls for later
@ -43,29 +43,25 @@ function ConsoleAPIStorageService() {
}
ConsoleAPIStorageService.prototype = {
classID : CONSOLEAPISTORAGE_CID,
classID: CONSOLEAPISTORAGE_CID,
QueryInterface: ChromeUtils.generateQI([Ci.nsIConsoleAPIStorage,
Ci.nsIObserver]),
observe: function CS_observe(aSubject, aTopic, aData)
{
observe: function CS_observe(aSubject, aTopic, aData) {
if (aTopic == "xpcom-shutdown") {
Services.obs.removeObserver(this, "xpcom-shutdown");
Services.obs.removeObserver(this, "inner-window-destroyed");
Services.obs.removeObserver(this, "memory-pressure");
}
else if (aTopic == "inner-window-destroyed") {
} else if (aTopic == "inner-window-destroyed") {
let innerWindowID = aSubject.QueryInterface(Ci.nsISupportsPRUint64).data;
this.clearEvents(innerWindowID + "");
}
else if (aTopic == "memory-pressure") {
} else if (aTopic == "memory-pressure") {
this.clearEvents();
}
},
/** @private */
init: function CS_init()
{
init: function CS_init() {
Services.obs.addObserver(this, "xpcom-shutdown");
Services.obs.addObserver(this, "inner-window-destroyed");
Services.obs.addObserver(this, "memory-pressure");
@ -82,8 +78,7 @@ ConsoleAPIStorageService.prototype = {
* given this function returns all of the cached events, from any
* window.
*/
getEvents: function CS_getEvents(aId)
{
getEvents: function CS_getEvents(aId) {
if (aId != null) {
return (_consoleStorage.get(aId) || []).slice(0);
}
@ -111,8 +106,7 @@ ConsoleAPIStorageService.prototype = {
* @param object aEvent
* A JavaScript object you want to store.
*/
recordEvent: function CS_recordEvent(aId, aOuterId, aEvent)
{
recordEvent: function CS_recordEvent(aId, aOuterId, aEvent) {
if (!_consoleStorage.has(aId)) {
_consoleStorage.set(aId, []);
}
@ -138,12 +132,10 @@ ConsoleAPIStorageService.prototype = {
* messages. If this is not specified all of the cached messages are
* cleared, from all window objects.
*/
clearEvents: function CS_clearEvents(aId)
{
clearEvents: function CS_clearEvents(aId) {
if (aId != null) {
_consoleStorage.delete(aId);
}
else {
} else {
_consoleStorage.clear();
Services.obs.notifyObservers(null, "console-storage-reset");
}

Просмотреть файл

@ -5,7 +5,7 @@
var EXPORTED_SYMBOLS = [ "ConsoleTest" ];
var ConsoleTest = {
go: function(dumpFunction) {
go(dumpFunction) {
console.log("Hello world!");
console.createInstance().log("Hello world!");
@ -23,5 +23,5 @@ var ConsoleTest = {
console.createInstance({ innerID: "LEVEL", maxLogLevel: "All" }).log("Hello world!");
console.createInstance({ innerID: "LEVEL", maxLogLevelPref: "foo.pref" }).log("Invisible!");
console.createInstance({ innerID: "LEVEL", maxLogLevelPref: "pref.test.console" }).log("Hello world!");
}
},
};

Просмотреть файл

@ -22,7 +22,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=659625
"Only one event remains in consoleAPIStorage");
ok(storage.getEvents()[0].level === "clear",
"Remaining event has level 'clear'");
}
};
storage.clearEvents();
ok(storage.getEvents().length === 0,
@ -69,21 +69,21 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=659625
}
clearAndCheckStorage();
console.group("group-label")
console.group("group-label");
console.log("group-log");
ok(storage.getEvents().length === 3,
"2 new console events registered for group + log");
clearAndCheckStorage();
console.groupCollapsed("group-collapsed")
console.groupCollapsed("group-collapsed");
console.log("group-collapsed-log");
ok(storage.getEvents().length === 3,
"2 new console events registered for groupCollapsed + log");
clearAndCheckStorage();
console.group("closed-group-label")
console.group("closed-group-label");
console.log("group-log");
console.groupEnd()
console.groupEnd();
ok(storage.getEvents().length === 4,
"3 new console events registered for group/groupEnd");
clearAndCheckStorage();

Просмотреть файл

@ -13,16 +13,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=978522
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=978522">Mozilla Bug 978522</a>
<script type="application/javascript">
console.log('%s', {
toString: function() {
console.log('%s', {
toString: function() {
ok(true, "Still alive \\o/");
SimpleTest.finish();
return "hello world";
}
});
}
console.log("%s", {
toString() {
console.log("%s", {
toString() {
ok(true, "Still alive \\o/");
SimpleTest.finish();
return "hello world";
},
});
},
});
SimpleTest.waitForExplicitFinish();

Просмотреть файл

@ -15,10 +15,10 @@ function consoleListener() {
var order = 0;
consoleListener.prototype = {
observe: function(aSubject, aTopic, aData) {
observe(aSubject, aTopic, aData) {
if (aTopic == "console-api-log-event") {
var obj = aSubject.wrappedJSObject;
if (order+1 == parseInt(obj.arguments[0])) {
if (order + 1 == parseInt(obj.arguments[0])) {
ok(true, "Message received: " + obj.arguments[0]);
order++;
}
@ -26,16 +26,16 @@ consoleListener.prototype = {
if (order == 3) {
SpecialPowers.removeObserver(this, "console-api-log-event");
SimpleTest.finish();
return;
}
}
}
}
},
};
var cl = new consoleListener();
SimpleTest.waitForExplicitFinish();
[1,2,3].forEach(console.log);
[1, 2, 3].forEach(console.log);
</script>
</body>

Просмотреть файл

@ -18,7 +18,7 @@ function ConsoleListener() {
ConsoleListener.prototype = {
observe(aSubject, aTopic, aData) {
let obj = aSubject.wrappedJSObject;
if (obj.arguments[0] != 'test') {
if (obj.arguments[0] != "test") {
return;
}

Просмотреть файл

@ -20,9 +20,9 @@ function consoleListener(expected) {
SpecialPowers.removeObserver(observer, "console-api-log-event");
SpecialPowers.removeObserver(observer, "console-api-profiler");
done(messages);
return;
}
}
},
};
SpecialPowers.addObserver(observer, "console-api-log-event");
SpecialPowers.addObserver(observer, "console-api-profiler");
@ -30,7 +30,7 @@ function consoleListener(expected) {
}
SimpleTest.waitForExplicitFinish();
(async function () {
(async function() {
var onMessages = consoleListener(4);
await SpecialPowers.pushPrefEnv({set: [["devtools.enabled", false]]});

Просмотреть файл

@ -12,7 +12,7 @@ add_task(async function() {
}
consoleListener.prototype = {
observe: function(aSubject, aTopic, aData) {
observe(aSubject, aTopic, aData) {
let obj = aSubject.wrappedJSObject;
Assert.ok(obj.arguments[0] === 42, "Message received!");
Assert.ok(obj.ID === "jsm", "The ID is JSM");
@ -20,7 +20,7 @@ add_task(async function() {
Services.obs.removeObserver(this, "console-api-log-event");
resolve();
}
},
};
new consoleListener();

Просмотреть файл

@ -10,7 +10,7 @@ add_task(async function() {
}
consoleListener.prototype = {
observe: function(aSubject, aTopic, aData) {
observe(aSubject, aTopic, aData) {
let obj = aSubject.wrappedJSObject;
Assert.ok(obj.arguments[0] === "Hello world!", "Message received!");
Assert.ok(obj.ID === "scope", "The ID is the scope");
@ -22,7 +22,7 @@ add_task(async function() {
Services.obs.removeObserver(this, "console-api-log-event");
resolve();
}
},
};
new consoleListener();