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
parent d402239dae
commit a164593e05
42 changed files with 195 additions and 208 deletions

View file

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

View file

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

View file

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

View file

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

View file

@ -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"; script.src = "http://mochi.test:8888/tests/dom/asmjscache/test/file_slow.js";
document.body.appendChild(script); 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) { w.onmessage = function(e) {
ok(e.data === "ok", "Worker asm.js tests"); ok(e.data === "ok", "Worker asm.js tests");
complete(); complete();
} };
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
} }

View file

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

View file

@ -20,10 +20,10 @@ SimpleTest.waitForExplicitFinish();
ok("getBattery" in navigator, "navigator.getBattery should exist"); ok("getBattery" in navigator, "navigator.getBattery should exist");
ok(!("battery" in navigator), "navigator.battery should not 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]"); 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"); ok(battery.charging, "Battery should be charging by default");
is(battery.chargingTime, 0, "Battery chargingTime " + battery.chargingTime + " should be zero 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"); is(battery.dischargingTime, Infinity, "Battery dischargingTime should be Infinity by default");

View file

@ -17,10 +17,10 @@
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
/** Test for Battery API **/ /** 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]"); 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"); is(battery.charging, true, "Battery should be charging");
ok(battery.chargingTime >= 0, "Battery chargingTime " + battery.chargingTime + " should be nonnegative when 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"); is(battery.dischargingTime, Infinity, "Battery dischargingTime should be Infinity when charging");

View file

@ -17,10 +17,10 @@
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
/** Test for Battery API **/ /** 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]"); 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.charging, false, "Battery should be discharging");
is(battery.chargingTime, Infinity, "Battery chargingTime should be Infinity when 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"); ok(battery.dischargingTime > 0, "Battery dischargingTime " + battery.dischargingTime + " should be positive when discharging");

View file

@ -1,12 +1,12 @@
onconnect = function(evt) { onconnect = function(evt) {
evt.ports[0].onmessage = function(evt) { evt.ports[0].onmessage = function(evt) {
var bc = new BroadcastChannel('foobar'); var bc = new BroadcastChannel("foobar");
bc.addEventListener('message', function(event) { bc.addEventListener("message", function(event) {
bc.postMessage(event.data == "hello world from the window" ? bc.postMessage(event.data == "hello world from the window" ?
"hello world from the worker" : "KO"); "hello world from the worker" : "KO");
bc.close(); bc.close();
}); });
evt.target.postMessage("READY"); evt.target.postMessage("READY");
} };
} };

View file

@ -3,16 +3,16 @@ onmessage = function(evt) {
var worker = new Worker("broadcastchannel_worker.js"); var worker = new Worker("broadcastchannel_worker.js");
worker.onmessage = function(evt) { worker.onmessage = function(evt) {
postMessage(evt.data); postMessage(evt.data);
} };
worker.postMessage(evt.data - 1); worker.postMessage(evt.data - 1);
return; return;
} }
var bc = new BroadcastChannel('foobar'); var bc = new BroadcastChannel("foobar");
bc.addEventListener('message', function(event) { bc.addEventListener("message", function(event) {
bc.postMessage(event.data == "hello world from the window" ? "hello world from the worker" : "KO"); bc.postMessage(event.data == "hello world from the window" ? "hello world from the worker" : "KO");
bc.close(); bc.close();
}); });
postMessage("READY"); postMessage("READY");
} };

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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