diff --git a/.eslintignore b/.eslintignore index a4ee00f84f6f..90ac6d438b10 100644 --- a/.eslintignore +++ b/.eslintignore @@ -182,7 +182,6 @@ dom/cache/test/mochitest/** dom/cache/test/xpcshell/** dom/canvas/** dom/console/** -dom/crypto/** dom/encoding/** dom/events/** dom/fetch/** diff --git a/dom/crypto/test/test-array.js b/dom/crypto/test/test-array.js index 5dbe6bea50ae..54a616ef188a 100644 --- a/dom/crypto/test/test-array.js +++ b/dom/crypto/test/test-array.js @@ -2,6 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +// This file expects utils.js to be included in its scope +/* import-globals-from ./util.js */ var MOCHITEST = false; function Test(name, test) { @@ -34,7 +36,9 @@ function Test(name, test) { }; this.complete = function(result) { - if (MOCHITEST) { ok(result, this.name); } + if (MOCHITEST) { + ok(result, this.name); + } // Note the end time this.endTime = new Date(); @@ -60,28 +64,30 @@ function Test(name, test) { // Print the name of the test if (this.name) { - this.row[0].innerHTML = this.name; + this.row[0].textContent = this.name; var that = this; - this.row[0].onclick = function() { that.run(); }; + this.row[0].onclick = function() { + that.run(); + }; } else { this.row[0] = ""; } // Print the result of the test - if (this.result == true) { + if (this.result === true) { this.row[1].className = "pass"; this.row[1].innerHTML = "PASS"; - } else if (this.result == false) { + } else if (this.result === false) { this.row[1].className = "fail"; this.row[1].innerHTML = "FAIL"; } else { // this.row[1].innerHTML = ""; - this.row[1].innerHTML = this.result; + this.row[1].textContent = this.result; } // Print the elapsed time, if known if (this.startTime && this.endTime) { - this.row[2].innerHTML = (this.endTime - this.startTime) + " ms"; + this.row[2].textContent = (this.endTime - this.startTime) + " ms"; } else { this.row[2].innerHTML = ""; } @@ -143,13 +149,13 @@ var TestArray = { updateSummary() { this.pass = this.fail = this.pending = 0; for (var i = 0; i < this.tests.length; ++i) { - if (this.tests[i].result == true) this.pass++; - if (this.tests[i].result == false) this.fail++; + if (this.tests[i].result === true) this.pass++; + if (this.tests[i].result === false) this.fail++; if (this.tests[i].result == null) this.pending++; } - this.passSpan.innerHTML = this.pass; - this.failSpan.innerHTML = this.fail; - this.pendingSpan.innerHTML = this.pending; + this.passSpan.textContent = this.pass; + this.failSpan.textContent = this.fail; + this.pendingSpan.textContent = this.pending; }, load() { @@ -182,7 +188,9 @@ var TestArray = { this.updateSummary(); var i = this.currTest++; if (i >= this.tests.length) { - if (MOCHITEST) { SimpleTest.finish(); } + if (MOCHITEST) { + SimpleTest.finish(); + } return; } @@ -195,16 +203,20 @@ var TestArray = { }; if (window.addEventListener) { - window.addEventListener("load", function() { TestArray.load(); } ); + window.addEventListener("load", function() { + TestArray.load(); + }); } else { - window.attachEvent("onload", function() { TestArray.load(); } ); + window.attachEvent("onload", function() { + TestArray.load(); + }); } function start() { TestArray.run(); } -MOCHITEST = ("SimpleTest" in window); +MOCHITEST = "SimpleTest" in window; if (MOCHITEST) { SimpleTest.waitForExplicitFinish(); SimpleTest.requestLongerTimeout(2); diff --git a/dom/crypto/test/test-vectors.js b/dom/crypto/test/test-vectors.js index ac4187e8490a..aebefdf84db8 100644 --- a/dom/crypto/test/test-vectors.js +++ b/dom/crypto/test/test-vectors.js @@ -2,7 +2,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -tv = { +// This file expects utils.js to be included in its scope +/* import-globals-from ./util.js */ +let tv = { raw: util.hex2abv("f3095c4fe5e299477643c2310b44f0aa"), // this key had an inappropriate length (18 octets) diff --git a/dom/crypto/test/test-worker.js b/dom/crypto/test/test-worker.js index 65edf0329a68..5b52ddf84511 100644 --- a/dom/crypto/test/test-worker.js +++ b/dom/crypto/test/test-worker.js @@ -2,6 +2,10 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +/* eslint-env worker */ + +// This file expects utils.js to be included in its scope +/* import-globals-from ./util.js */ importScripts("util.js"); importScripts("test-vectors.js"); @@ -34,6 +38,7 @@ function error(test) { } onmessage = function(msg) { + // eslint-disable-next-line no-eval var test = eval("(" + msg.data + ")"); try { diff --git a/dom/crypto/test/test_WebCrypto.html b/dom/crypto/test/test_WebCrypto.html index 7d95ee6796f6..d3cbb1243cd2 100644 --- a/dom/crypto/test/test_WebCrypto.html +++ b/dom/crypto/test/test_WebCrypto.html @@ -26,7 +26,6 @@ TestArray.addTest( "Test for presence of WebCrypto API methods", function() { - var that = this; this.complete( exists(window.crypto.subtle) && exists(window.crypto.subtle.encrypt) && @@ -630,11 +629,6 @@ TestArray.addTest( x, tv.aes_ctr_dec.data); } - function decrypt(x) { - return decrypt(x, new Uint8Array(15)) - .catch(function() { return decrypt(x, new Uint8Array(17)); }); - } - crypto.subtle.importKey("raw", tv.aes_ctr_dec.key, "AES-CTR", false, ["decrypt"]) .then(doDecrypt) .then( @@ -1004,7 +998,6 @@ TestArray.addTest( function() { var that = this; var alg = { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" }; - var use = ["sign", "verify"]; function doVerify(x) { return crypto.subtle.verify(alg.name, x, tv.rsassa.sig_fail, tv.rsassa.data); @@ -1103,7 +1096,7 @@ TestArray.addTest( error(that)(); } - Promise.all([p1, p2, p3]).then(complete(that, keys => { + return Promise.all([p1, p2, p3]).then(complete(that, keys => { return keys.every(key => { if (key instanceof CryptoKey) { return checkPrototypes(key, "CryptoKey"); diff --git a/dom/crypto/test/test_WebCrypto_DH.html b/dom/crypto/test/test_WebCrypto_DH.html index d6bc48710c04..09924c78b30a 100644 --- a/dom/crypto/test/test_WebCrypto_DH.html +++ b/dom/crypto/test/test_WebCrypto_DH.html @@ -21,7 +21,6 @@