Skip to content

Commit

Permalink
Bug 1508988 - Enable ESLint for dom/abort/, dom/asmjscache/, dom/batt…
Browse files Browse the repository at this point in the history
…ery/, dom/broadcastchannel/ and dom/console/ (automatic changes). r=Standard8,nika

Differential Revision: https://phabricator.services.mozilla.com/D14131
  • Loading branch information
jrkong committed Dec 19, 2018
1 parent 7f1693b commit d525dcf
Show file tree
Hide file tree
Showing 42 changed files with 195 additions and 208 deletions.
5 changes: 0 additions & 5 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/**
Expand Down
10 changes: 5 additions & 5 deletions dom/asmjscache/test/file_slow.js
Original file line number Diff line number Diff line change
@@ -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");
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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");

Expand Down
6 changes: 3 additions & 3 deletions dom/asmjscache/test/test_cachingBasic.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
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);
}
Expand All @@ -44,7 +44,7 @@
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:
Expand Down
8 changes: 4 additions & 4 deletions dom/asmjscache/test/test_cachingMulti.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
}

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);
}
Expand All @@ -55,13 +55,13 @@
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();
}
}
Expand Down
4 changes: 2 additions & 2 deletions dom/asmjscache/test/test_slow.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
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();
}
Expand Down
8 changes: 4 additions & 4 deletions dom/asmjscache/test/test_workers.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
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";
mainCode += "var g42 = f();\n";
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));

Expand All @@ -51,14 +51,14 @@
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();
}
Expand Down
4 changes: 2 additions & 2 deletions dom/battery/test/test_battery_basics.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
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");
Expand Down
4 changes: 2 additions & 2 deletions dom/battery/test/test_battery_charging.html
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions dom/battery/test/test_battery_discharging.html
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
8 changes: 4 additions & 4 deletions dom/broadcastchannel/tests/broadcastchannel_sharedWorker.js
Original file line number Diff line number Diff line change
@@ -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");
}
}
};
};
8 changes: 4 additions & 4 deletions dom/broadcastchannel/tests/broadcastchannel_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
};
6 changes: 3 additions & 3 deletions dom/broadcastchannel/tests/broadcastchannel_worker_alive.js
Original file line number Diff line number Diff line change
@@ -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");
4 changes: 2 additions & 2 deletions dom/broadcastchannel/tests/broadcastchannel_worker_any.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(new BroadcastChannel('foobar')).onmessage = function(event) {
(new BroadcastChannel("foobar")).onmessage = function(event) {
event.target.postMessage(event.data);
}
};

postMessage("READY");
20 changes: 10 additions & 10 deletions dom/broadcastchannel/tests/browser_private_browsing.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions dom/broadcastchannel/tests/file_mozbrowser.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
10 changes: 5 additions & 5 deletions dom/broadcastchannel/tests/file_mozbrowser2.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
12 changes: 6 additions & 6 deletions dom/broadcastchannel/tests/iframe_broadcastchannel.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@

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>
Expand Down
4 changes: 2 additions & 2 deletions dom/broadcastchannel/tests/iframe_mozbrowser.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 2 additions & 2 deletions dom/broadcastchannel/tests/iframe_mozbrowser2.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion dom/broadcastchannel/tests/test_bfcache.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit d525dcf

Please sign in to comment.