diff --git a/.eslintignore b/.eslintignore index 0d6164650788..60ad59e59a46 100644 --- a/.eslintignore +++ b/.eslintignore @@ -13,8 +13,6 @@ obj*/** # dom/ exclusions which should be removed (aka ESLint enabled) dom/base/*.* -dom/base/test/*.* -dom/base/test/jsmodules/** dom/media/test/** !dom/media/test/marionette/yttest/*.js dom/promise/** @@ -169,6 +167,7 @@ dom/svg/test/test_nonAnimStrings.xhtml dom/svg/test/test_SVG_namespace_ids.html # Strange encodings +dom/base/test/file_bug687859-16.js dom/encoding/test/test_utf16_files.html dom/encoding/test/file_utf16_be_bom.js dom/encoding/test/file_utf16_le_bom.js @@ -179,6 +178,12 @@ dom/html/test/test_bug677658.html # Intentional broken files dom/base/test/file_js_cache_syntax_error.js +dom/base/test/jsmodules/test_syntaxError.html +dom/base/test/jsmodules/test_syntaxErrorAsync.html +dom/base/test/jsmodules/module_badSyntax.js +dom/base/test/jsmodules/test_syntaxErrorInline.html +dom/base/test/jsmodules/test_syntaxErrorInlineAsync.html +dom/base/test/test_bug687859.html dom/media/tests/mochitest/identity/idp-bad.js dom/serviceworkers/test/file_js_cache_syntax_error.js dom/serviceworkers/test/parse_error_worker.js diff --git a/dom/base/test/browser_aboutnewtab_process_selection.js b/dom/base/test/browser_aboutnewtab_process_selection.js index 5c426343003d..d8d88f42e6a2 100644 --- a/dom/base/test/browser_aboutnewtab_process_selection.js +++ b/dom/base/test/browser_aboutnewtab_process_selection.js @@ -62,10 +62,12 @@ add_task(async function(){ // Navigate to a content page from the child side. await BrowserTestUtils.switchTab(gBrowser, tab1); + /* eslint-disable no-shadow */ await ContentTask.spawn(tab1.linkedBrowser, null, async function() { const TEST_URL = "http://www.example.com/browser/dom/base/test/dummy.html"; content.location.href = TEST_URL; }); + /* eslint-enable no-shadow */ await BrowserTestUtils.browserLoaded(tab1.linkedBrowser, false, TEST_URL); is(ppmm.childCount, originalChildCount + 2, "Navigating away from the preloaded browser (child side) should create a new content process.") @@ -106,4 +108,3 @@ add_task(async function preloaded_state_attribute() { BrowserTestUtils.removeTab(gBrowser.selectedTab); NewTabPagePreloading.removePreloadedBrowser(window); }); - diff --git a/dom/base/test/browser_force_process_selector.js b/dom/base/test/browser_force_process_selector.js index b0b3abb93451..0ec280c97f83 100644 --- a/dom/base/test/browser_force_process_selector.js +++ b/dom/base/test/browser_force_process_selector.js @@ -20,7 +20,7 @@ async function spawnNewAndTest(recur, pids) { }; Services.obs.addObserver(observer, CONTENT_CREATED); - await BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, function(browser) { + await BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, function() { // If this new tab caused us to create a new process, the ok(false) // should have already happened. Therefore, if we get here, we've // passed. Simply remove the observer. diff --git a/dom/base/test/browser_inputStream_structuredClone.js b/dom/base/test/browser_inputStream_structuredClone.js index d0a772c3f521..de6ec0e733fa 100644 --- a/dom/base/test/browser_inputStream_structuredClone.js +++ b/dom/base/test/browser_inputStream_structuredClone.js @@ -22,6 +22,7 @@ async function runTest(input, url) { is(data.inputStream.available(), input.length, "The length of the inputStream matches: " + input.length); + /* eslint-disable no-shadow */ let dataBack = await ContentTask.spawn(browser, data, function(data) { let dataBack = { inputStream: data.inputStream, @@ -34,6 +35,8 @@ async function runTest(input, url) { return dataBack; }); + /* eslint-enable no-shadow */ + ok(dataBack.check, "The inputStream is a nsIInputStream also on content."); ok(data.inputStream instanceof Ci.nsIInputStream, "The original object was an inputStream"); diff --git a/dom/base/test/browser_state_notifications.js b/dom/base/test/browser_state_notifications.js index 865bc3db73c2..16576f561e35 100644 --- a/dom/base/test/browser_state_notifications.js +++ b/dom/base/test/browser_state_notifications.js @@ -50,6 +50,7 @@ const receive = (topic, p, syncCallback) => { } } }; + // eslint-disable-next-line mozilla/no-arbitrary-setTimeout const id = setTimeout(timeout, 90000); addObserver(observer, topic, false); queue.push(topic, resolve); @@ -59,6 +60,7 @@ receive.queue = []; const openTab = uri => gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, uri); +// eslint-disable-next-line mozilla/no-arbitrary-setTimeout const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); const isData = document => document.URL.startsWith("data:"); diff --git a/dom/base/test/file_bug416317.xhtml b/dom/base/test/file_bug416317.xhtml index 9c6d219c60b7..b365e364ac2f 100644 --- a/dom/base/test/file_bug416317.xhtml +++ b/dom/base/test/file_bug416317.xhtml @@ -226,6 +226,8 @@ .bar. { background: red; color: yellow; } + diff --git a/dom/base/test/jsmodules/.eslintrc.js b/dom/base/test/jsmodules/.eslintrc.js new file mode 100644 index 000000000000..b6eb63514520 --- /dev/null +++ b/dom/base/test/jsmodules/.eslintrc.js @@ -0,0 +1,7 @@ +"use strict"; + +module.exports = { + "parserOptions": { + "sourceType": "module", + } +}; diff --git a/dom/base/test/referrer_helper.js b/dom/base/test/referrer_helper.js index 8f1adb13660d..cd47b04e6950 100644 --- a/dom/base/test/referrer_helper.js +++ b/dom/base/test/referrer_helper.js @@ -1,3 +1,6 @@ +// This helper expects these globals to be defined. +/* global PARAMS, SJS, testCases */ + /* * common functionality for iframe, anchor, and area referrer attribute tests */ @@ -80,22 +83,22 @@ var tests = (function*() { } var actions = testCases[j].ACTION; - var tests = testCases[j].TESTS; + var subTests = testCases[j].TESTS; for (var k = 0; k < actions.length; k++) { var actionString = actions[k]; - for (var i = 0; i < tests.length; i++) { + for (var i = 0; i < subTests.length; i++) { yield resetState(); var searchParams = new URLSearchParams(); searchParams.append("ACTION", actionString); - searchParams.append("NAME", tests[i].NAME); + searchParams.append("NAME", subTests[i].NAME); for (var l of PARAMS) { - if (tests[i][l]) { - searchParams.append(l, tests[i][l]); + if (subTests[i][l]) { + searchParams.append(l, subTests[i][l]); } } - var schemeFrom = tests[i].SCHEME_FROM || "http"; + var schemeFrom = subTests[i].SCHEME_FROM || "http"; yield iframe.src = schemeFrom + SJS + searchParams.toString(); - yield checkIndividualResults(tests[i].DESC, tests[i].RESULT, tests[i].NAME); + yield checkIndividualResults(subTests[i].DESC, subTests[i].RESULT, subTests[i].NAME); }; }; }; diff --git a/dom/base/test/test_NodeIterator_basics_filters.xhtml b/dom/base/test/test_NodeIterator_basics_filters.xhtml index c9cca97157da..47504eebbe41 100644 --- a/dom/base/test/test_NodeIterator_basics_filters.xhtml +++ b/dom/base/test/test_NodeIterator_basics_filters.xhtml @@ -21,7 +21,7 @@ function compare_arrays(e, f, label) { var length = (e.length > f.length) ? e.length : f.length; for (var i = 0; i < length; i += 1) { - if (e[i] > 0) + if (e[i] > 0) is(f[i], e[i], label + " - index " + i + ": "); else todo_is(f[i], -e[i], label + " - index " + i + ": "); @@ -110,17 +110,17 @@ compare_arrays(expect_f, found, 'filtered backward'); function checkBadFilter(method, n) { - var iterator = + var iter = document.createNodeIterator(document, NodeFilter.SHOW_ALL, function() { if (n < 0) - iterator.detach(); + iter.detach(); return NodeFilter.FILTER_ACCEPT; }); while (--n >= 0) - iterator.nextNode(); + iter.nextNode(); try { - iterator[method](); + iter[method](); ok(true, "Able to call " + method + " on a NodeIterator after calling no-op detach()"); } catch (x) { ok(false, x) } } @@ -131,7 +131,7 @@ // Implementing the scenario outlined in // http://bugzilla.mozilla.org/show_bug.cgi?id=552110#c4 - var iterator = (function(filter) { + var iter = (function(filt) { var grandparent = document.createElement("div"), parent = document.createElement("span"); @@ -141,12 +141,12 @@ return document.createNodeIterator(grandparent, NodeFilter.SHOW_ALL, - filter); - })(function filter(n) { + filt); + })(function(n) { if (n.nodeName != "img") return NodeFilter.FILTER_ACCEPT; - iterator.detach(); + iter.detach(); n.parentNode.remove(); // Drop any node references passed into this function. @@ -162,16 +162,16 @@ return NodeFilter.FILTER_SKIP; }); - is(iterator.nextNode().nodeName, "div", - "iterator.nextNode() returned the wrong node"); - is(iterator.nextNode().nodeName, "span", - "iterator.nextNode() returned the wrong node"); + is(iter.nextNode().nodeName, "div", + "iter.nextNode() returned the wrong node"); + is(iter.nextNode().nodeName, "span", + "iter.nextNode() returned the wrong node"); try { - var p = iterator.nextNode(); - ok(false, "iterator.nextNode() should have thrown, but instead it returned <" + p.nodeName + ">"); + var p = iter.nextNode(); + ok(false, "iter.nextNode() should have thrown, but instead it returned <" + p.nodeName + ">"); } catch (x) { ok(true, x) } })(); - + ]]> diff --git a/dom/base/test/test_bug1037687_subframe.html b/dom/base/test/test_bug1037687_subframe.html index 141cddaa5a25..4258f772b677 100644 --- a/dom/base/test/test_bug1037687_subframe.html +++ b/dom/base/test/test_bug1037687_subframe.html @@ -7,7 +7,6 @@ var is = window.parent.is; var host; - var sr; var embed; var object; var iframe; @@ -34,7 +33,7 @@ function test() { host = document.getElementById("host"); - sr = host.attachShadow({mode: 'open'}); + let sr = host.attachShadow({mode: 'open'}); embed = createResource(sr, "embed"); object = createResource(sr, "object"); iframe = createResource(sr, "iframe"); diff --git a/dom/base/test/test_bug1091883.html b/dom/base/test/test_bug1091883.html index a3d5f2d4fc4a..0b38c59d43ba 100644 --- a/dom/base/test/test_bug1091883.html +++ b/dom/base/test/test_bug1091883.html @@ -43,7 +43,7 @@ function getTargetOrigin(i) { } // Create the frames, and tell them which subframes to load. -for (var i = 0; i < numTests; i++) { +for (let i = 0; i < numTests; i++) { var frame = document.createElement("iframe"); frame.src = getFrameOrigin(i) + "/tests/dom/base/test/file_bug1091883_frame.html#" + @@ -53,7 +53,7 @@ for (var i = 0; i < numTests; i++) { // Navigate all subframes to the target. window.onload = function() { - for (var i = 0; i < numTests; i++) { + for (let i = 0; i < numTests; i++) { frames[i].frames[0].location = getTargetOrigin(i) + "/tests/dom/base/test/file_bug1091883_target.html#" + i; } diff --git a/dom/base/test/test_bug338583.html b/dom/base/test/test_bug338583.html index 18ea2194ef39..87cd83561017 100644 --- a/dom/base/test/test_bug338583.html +++ b/dom/base/test/test_bug338583.html @@ -58,14 +58,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583 doTest5, doTest5_b, doTest5_c, doTest5_e, doTest6, doTest7 ]; - for (var test_id=0; test_id < all_tests.length; ++test_id) { + for (let test_id=0; test_id < all_tests.length; ++test_id) { gTestsHaveFinished[test_id] = false; var fn = all_tests[test_id]; fn(test_id); } setTimeout(function() { - for (var test_id=0; test_id < all_tests.length; ++test_id) { + for (let test_id=0; test_id < all_tests.length; ++test_id) { if (!gTestsHaveFinished[test_id]) { ok(false, "Test " + test_id + " took too long"); setTestHasFinished(test_id); @@ -181,7 +181,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583 function doTest1_f(test_id) { var called_on_error = false; - + gEventSourceObj1_f = new EventSource("file_bug869432.eventsource"); gEventSourceObj1_f.onopen = function(e) { ok(false, "Test 1.f failed: onopen was called"); @@ -429,8 +429,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583 // b) invalid access-control xsite request // c) valid access-control xsite request on a restricted page with credentials // d) valid access-control xsite request on a restricted page without credentials -// e) valid access-control xsite request on a restricted page when the parameter withCredentials is a getter -// f) valid access-control xsite request on a restricted page when the parameter withCredentials is missing +// e) valid access-control xsite request on a restricted page when the parameter withCredentials is a getter +// f) valid access-control xsite request on a restricted page when the parameter withCredentials is missing function doTest5(test_id) { @@ -498,17 +498,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583 xhr.send(); xhr.onloadend = function() { ok(xhr.status == 200, "Failed to set credentials in test 5.d"); - + gEventSourceObj5_d = new EventSource("https://example.com/tests/dom/base/test/file_restrictedEventSource.sjs?test=user2_evtsrc"); ok(!gEventSourceObj5_d.withCredentials, "Wrong withCredentials in test 5.d"); - + gEventSourceObj5_d.onmessage = function(e) { ok(e.origin == "https://example.com", "Wrong Origin in test 5.d"); fn_onmessage(e); }; gEventSourceObj5_d.hits = []; gEventSourceObj5_d.hits['fn_onmessage'] = 0; - + setTimeout(function() { ok(gEventSourceObj5_d.hits['fn_onmessage'] == 0, "Test 5.d failed"); gEventSourceObj5_d.close(); @@ -605,10 +605,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583 { e.target.msg_received.push(e.data); } - + setTimeout(function() { gEventSourceObj7.close(); - + ok(gEventSourceObj7.msg_received[0] == "" && gEventSourceObj7.msg_received[1] == "delayed1" && gEventSourceObj7.msg_received[2] == "delayed2", "Test 7 failed"); @@ -663,4 +663,3 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338583 Wait please... - diff --git a/dom/base/test/test_bug409380.html b/dom/base/test/test_bug409380.html index 5917059efe86..ddc796b22375 100644 --- a/dom/base/test/test_bug409380.html +++ b/dom/base/test/test_bug409380.html @@ -12,13 +12,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=409380 Mozilla Bug 409380

 
 
 
-
diff --git a/dom/base/test/test_messagemanager_targetchain.html b/dom/base/test/test_messagemanager_targetchain.html
index f7e056b7d728..0be6fb1f7be8 100644
--- a/dom/base/test/test_messagemanager_targetchain.html
+++ b/dom/base/test/test_messagemanager_targetchain.html
@@ -75,7 +75,7 @@
             info("Third iframe loaded");
             let doc3 = SpecialPowers.wrap(iframe3).contentDocument;
             let target = doc3.getElementById("target");
-            target.addEventListener("test-event", function onEvent(e) {
+            target.addEventListener("test-event", function onEvent() {
               is(messageIndex, 2,
                  "target should be the last one to receive the test event");
               messageIndex++;
diff --git a/dom/base/test/test_mutationobservers.html b/dom/base/test/test_mutationobservers.html
index c768708900ba..450f55ab7ad9 100644
--- a/dom/base/test/test_mutationobservers.html
+++ b/dom/base/test/test_mutationobservers.html
@@ -9,11 +9,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=641821
   
   
 
-                                                  
+
 Mozilla Bug 641821