Bug 1855697 - Enable ESLint rule no-implied-eval for all of dom/. r=dom-core,edgar

Depends on D189496

Differential Revision: https://phabricator.services.mozilla.com/D189497
This commit is contained in:
Mark Banner 2023-10-06 16:45:53 +00:00
parent c7ac816c46
commit 3a2f5a75d2
21 changed files with 27 additions and 9 deletions

View File

@ -448,7 +448,6 @@ module.exports = {
"no-empty": "off",
"no-func-assign": "off",
"no-global-assign": "off",
"no-implied-eval": "off",
"no-lone-blocks": "off",
"no-lonely-if": "off",
"no-nested-ternary": "off",

View File

@ -1 +1,6 @@
<script>window.onload = function runTest1() { document.open(); setTimeout('parent.test1Done();'); document.close(); }</script>
<script>window.onload = function runTest1() {
document.open();
// eslint-disable-next-line no-implied-eval
setTimeout('parent.test1Done();');
document.close();
}</script>

View File

@ -18,7 +18,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1100912
}
function didRunTests() {
setTimeout("SimpleTest.finish()");
setTimeout(SimpleTest.finish);
}
</script>

View File

@ -414,7 +414,7 @@ function runTest() {
function nextTest() {
if (tests.length) {
setTimeout("runTest()", 0);
setTimeout(runTest, 0);
} else {
SimpleTest.finish();
}

View File

@ -25,7 +25,7 @@ window.open("file_bug557892.html", "", "width=100,height=100");
function done() {
ok(true, "Should not crash");
setTimeout("SimpleTest.finish();", 0);
setTimeout(SimpleTest.finish, 0);
}
</script>

View File

@ -23,7 +23,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1453693
}
function didRunTests() {
setTimeout("SimpleTest.finish()");
setTimeout(SimpleTest.finish);
}
;

View File

@ -8,6 +8,7 @@
<script>
var x = 0;
// eslint-disable-next-line no-implied-eval
setTimeout("x++; '\x00'; x++;");
setTimeout(function() {
is(x, 2, "We want to see 2 here");

View File

@ -7,6 +7,8 @@
<script>
t1 = async_test("setTimeout with more than 2 arguments, first argument a string, should work");
t2 = async_test("setInterval with more than 2 arguments, first argument a string, should work");
// eslint-disable-next-line no-implied-eval
setTimeout("t1.done()", 0, {});
// eslint-disable-next-line no-implied-eval
var interval = setInterval("clearInterval(interval); t2.done()", 0, {});
</script>

View File

@ -26,7 +26,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1429572
}
function done() {
setTimeout("SimpleTest.finish();");
setTimeout(SimpleTest.finish);
}
</script>

View File

@ -24,7 +24,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1447993
}
function done() {
setTimeout("SimpleTest.finish();");
setTimeout(SimpleTest.finish);
}
</script>

View File

@ -27,6 +27,7 @@ window.addEventListener("load",
is(evt.originalTarget, window.document, "Wrong originalTarget!");
ok(evt.isTrusted, "Event should be trusted!");
loadEvent = evt;
// eslint-disable-next-line no-implied-eval
setTimeout("st.dispatchEvent(loadEvent)", 0);
}, true);

View File

@ -33,6 +33,7 @@ function doTest() {
document.body.appendChild(script);
break;
case 2:
// eslint-disable-next-line no-implied-eval
window.setTimeout("queueNextTest(); throw 'Got click 3'", 0);
break;
case 3:

View File

@ -229,7 +229,7 @@
await testManySingleWheelEvents();
await testMixedWheelEvents();
setTimeout("SimpleTest.finish()");
setTimeout(SimpleTest.finish);
window.close();
}

View File

@ -39,6 +39,7 @@ function initializeNextTest()
var element = document.createElement("input");
element.id = 'i';
element.type = gTestData[gCurrentTest];
// eslint-disable-next-line no-implied-eval
element.onclick = function() { setTimeout("document.forms[0].submit();",0); return false; };
form.appendChild(element);
form.action = gTestData[gCurrentTest];

View File

@ -8,6 +8,7 @@
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
/* eslint-disable no-implied-eval */
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("This test is generated by a fuzzer, so we leave these setTimeouts untouched.");

View File

@ -8,6 +8,7 @@
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
/* eslint-disable no-implied-eval */
SimpleTest.waitForExplicitFinish();

View File

@ -73,6 +73,7 @@ addEventListener(
}
}
setTimeout(fcn_setTimeoutWithStringCheck.bind(window), 10);
// eslint-disable-next-line no-implied-eval
var res = setTimeout(str_setTimeoutWithStringRan, 10);
verifyZeroRetVal(res, "setTimeout(String)");
}
@ -92,6 +93,7 @@ addEventListener(
}
}
setTimeout(fcn_setIntervalWithStringCheck.bind(window), 10);
// eslint-disable-next-line no-implied-eval
var res = setInterval(str_setIntervalWithStringRan, 10);
verifyZeroRetVal(res, "setInterval(String)");

View File

@ -45,6 +45,7 @@ addEventListener(
function () {
// setTimeout(String) test -- should pass
try {
// eslint-disable-next-line no-implied-eval
setTimeout(
'onevalexecuted(true, "setTimeout(String)", "setTimeout with a string was enabled.");',
10

View File

@ -34,6 +34,7 @@ function messageListener(event) {
postMessage("intervalCanceled");
break;
case "startExpression":
// eslint-disable-next-line no-implied-eval
setTimeout("this.postMessage('expressionFinished');", 2000);
break;
default:

View File

@ -10,6 +10,7 @@ onmessage = function (event) {
setInterval(function () {
postMessage("Still alive!");
}, 20);
// eslint-disable-next-line no-implied-eval
setInterval(";", 20);
postMessage("Begin!");

View File

@ -1,3 +1,4 @@
/* eslint-disable no-implied-eval */
var x = 0;
setTimeout("x++; '\x00'; x++;");
setTimeout("postMessage(x);");