From 6a56241703c2196a5d5f2dda329b8f3cecb1e6a6 Mon Sep 17 00:00:00 2001 From: Alec Gibson Date: Tue, 25 Jun 2019 20:12:47 +0000 Subject: [PATCH] Bug 1532935 - Enable ESLint for dom/promise (manual changes). r=mccr8 Patch by Alec, updated by Standard8. Differential Revision: https://phabricator.services.mozilla.com/D29646 --HG-- extra : moz-landing-system : lando --- .eslintignore | 1 - .../tests/file_promise_argument_tests.js | 3 ++ .../tests/file_promise_retval_tests.js | 3 ++ dom/promise/tests/file_promise_xrays.html | 4 +- .../tests/promise_uncatchable_exception.js | 2 + dom/promise/tests/test_on_new_promise.html | 1 + dom/promise/tests/test_promise.html | 54 ++++++++++++------- .../test_promise_and_timeout_ordering.html | 1 + ..._promise_and_timeout_ordering_workers.html | 1 + .../tests/test_promise_callback_retval.html | 2 + dom/promise/tests/test_promise_retval.html | 2 +- dom/promise/tests/test_promise_utils.html | 16 ++---- dom/promise/tests/test_promise_xrays.html | 4 +- dom/promise/tests/test_species_getter.html | 2 + .../test_thenable_vs_promise_ordering.html | 2 + .../tests/test_webassembly_compile.html | 8 +-- .../tests/test_webassembly_compile_worker.js | 8 +-- .../tests/unit/test_monitor_uncaught.js | 5 ++ 18 files changed, 77 insertions(+), 42 deletions(-) diff --git a/.eslintignore b/.eslintignore index 60ad59e59a46..5a047f0bd273 100644 --- a/.eslintignore +++ b/.eslintignore @@ -15,7 +15,6 @@ obj*/** dom/base/*.* dom/media/test/** !dom/media/test/marionette/yttest/*.js -dom/promise/** dom/xhr/** # build/ third-party code diff --git a/dom/promise/tests/file_promise_argument_tests.js b/dom/promise/tests/file_promise_argument_tests.js index e0659c7cf986..ac58c1e5a0c5 100644 --- a/dom/promise/tests/file_promise_argument_tests.js +++ b/dom/promise/tests/file_promise_argument_tests.js @@ -14,6 +14,9 @@ * 4) A subframe (frames[0]) which can be used as a second global for creating * promises. */ + +/* global verifyPromiseGlobal, getPromise, isXrayArgumentTest */ + var label = "parent"; function passBasicPromise() { diff --git a/dom/promise/tests/file_promise_retval_tests.js b/dom/promise/tests/file_promise_retval_tests.js index 35a4d8eaa083..e0438b9bed66 100644 --- a/dom/promise/tests/file_promise_retval_tests.js +++ b/dom/promise/tests/file_promise_retval_tests.js @@ -11,6 +11,9 @@ * 3) A subframe (frames[0]) which can be used as a second global for creating * promises. */ + +/* global verifyPromiseGlobal, expectedExceptionGlobal */ + var label = "parent"; function testThrownException(global) { diff --git a/dom/promise/tests/file_promise_xrays.html b/dom/promise/tests/file_promise_xrays.html index 0ba82a1f38c7..e08014a33702 100644 --- a/dom/promise/tests/file_promise_xrays.html +++ b/dom/promise/tests/file_promise_xrays.html @@ -2,16 +2,18 @@
diff --git a/dom/promise/tests/test_promise_utils.html b/dom/promise/tests/test_promise_utils.html index 3f49ed2d5598..39777bbdc97d 100644 --- a/dom/promise/tests/test_promise_utils.html +++ b/dom/promise/tests/test_promise_utils.html @@ -136,7 +136,9 @@ function promiseAllRejectFails() { } function promiseAllCastError() { - var p = Promise.all([Promise.resolve(2), { then() { foo(); } }]); + var p = Promise.all([Promise.resolve(2), { then() { + throw new ReferenceError("placeholder for nonexistent function call"); + } }]); ok(p instanceof Promise, "Should cast to a Promise."); p.then(function(v) { ok(false, "promiseAllCastError: should've rejected."); @@ -152,7 +154,7 @@ function promiseAllEnumerable() { var p = Promise.all([1, new Date(), Promise.resolve("firefox")]); p.then(function(v) { var count = 0; - for (key in v) { + for (let key in v) { ++count; ok(v[key] === 1 || v[key] instanceof Date || v[key] === "firefox", "Enumerated properties don't match."); @@ -193,14 +195,6 @@ function promiseRaceValuesArray() { } function promiseRacePromiseArray() { - function timeoutPromise(n) { - return new Promise(function(resolve) { - setTimeout(function() { - resolve(n); - }, n); - }); - } - var arr = [ new Promise(function(resolve) { resolve("first"); @@ -264,7 +258,7 @@ function promiseRaceReject() { function promiseRaceThrow() { var p = Promise.race([ new Promise(function(resolve) { - nonExistent(); + throw new ReferenceError("placeholder for nonexistent function call"); }), new Promise(function(resolve) { setTimeout(resolve, 0); diff --git a/dom/promise/tests/test_promise_xrays.html b/dom/promise/tests/test_promise_xrays.html index 0982620e2cd4..89f9afd94fb9 100644 --- a/dom/promise/tests/test_promise_xrays.html +++ b/dom/promise/tests/test_promise_xrays.html @@ -82,7 +82,7 @@ function testRace1() { function testRace2() { var p = win.Promise.race( - new Array(win.Promise.resolve(1), win.Promise.resolve(2))); + [win.Promise.resolve(1), win.Promise.resolve(2)]); p.then( function(arg) { ok(arg == 1 || arg == 2, @@ -140,7 +140,7 @@ function testAll1() { function testAll2() { var p = win.Promise.all( - new Array(win.Promise.resolve(1), win.Promise.resolve(2))); + [win.Promise.resolve(1), win.Promise.resolve(2)]); p.then( function(arg) { ok(arg instanceof win.Array, "Should get an Array from Promise.all (2)"); diff --git a/dom/promise/tests/test_species_getter.html b/dom/promise/tests/test_species_getter.html index b58a587905e0..23cb7d8ae00d 100644 --- a/dom/promise/tests/test_species_getter.html +++ b/dom/promise/tests/test_species_getter.html @@ -6,6 +6,8 @@