Bug 1914617 - Enable ESLint rules no-undef and no-unused-vars on dom/worklet. r=dom-core,frontend-codestyle-reviewers,mccr8

Differential Revision: https://phabricator.services.mozilla.com/D219974
This commit is contained in:
Mark Banner 2024-08-28 11:23:07 +00:00
Родитель 97d2a8252a
Коммит 8e32b78ff7
16 изменённых файлов: 57 добавлений и 90 удалений

Просмотреть файл

@ -645,7 +645,6 @@ const rollouts = [
"dom/webauthn/tests/**",
"dom/websocket/tests/**",
"dom/workers/test/**",
"dom/worklet/tests/**",
],
rules: {
"mozilla/avoid-removeChild": "off",
@ -707,7 +706,6 @@ const rollouts = [
"dom/webgpu/mochitest/**",
"dom/websocket/tests/**",
"dom/workers/test/**",
"dom/worklet/tests/**",
],
rules: {
"no-undef": "off",

Просмотреть файл

@ -1,3 +1,6 @@
// This file expects runTestInIframe to be in the global scope.
/* global runTestInIframe */
window.onload = async function () {
// We are the parent. Let's load the test.
if (parent == this || !location.search.includes("worklet_iframe")) {

Просмотреть файл

@ -15,24 +15,17 @@ function configureTest() {
"@mozilla.org/consoleAPI-storage;1"
].getService(SpecialPowers.Ci.nsIConsoleAPIStorage);
function consoleListener() {
this.observe = this.observe.bind(this);
ConsoleAPIStorage.addLogEventListener(this.observe, SpecialPowers.wrap(document).nodePrincipal);
}
function observe(aSubject) {
var obj = aSubject.wrappedJSObject;
if (obj.arguments[0] == "So far so good") {
ok(true, "Message received \\o/");
consoleListener.prototype = {
observe(aSubject) {
var obj = aSubject.wrappedJSObject;
if (obj.arguments[0] == "So far so good") {
ok(true, "Message received \\o/");
ConsoleAPIStorage.removeLogEventListener(this.observe);
SimpleTest.finish();
}
ConsoleAPIStorage.removeLogEventListener(observe);
SimpleTest.finish();
}
}
var cl = new consoleListener();
ConsoleAPIStorage.addLogEventListener(observe, SpecialPowers.wrap(document).nodePrincipal);
}
// This function is called into an iframe.

Просмотреть файл

@ -35,29 +35,21 @@ function configureTest() {
"@mozilla.org/consoleAPI-storage;1"
].getService(SpecialPowers.Ci.nsIConsoleAPIStorage);
function consoleListener() {
this.observe = this.observe.bind(this);
ConsoleAPIStorage.addLogEventListener(this.observe, SpecialPowers.wrap(document).nodePrincipal);
}
function observe(aSubject) {
var obj = aSubject.wrappedJSObject;
if (obj.arguments[0] == expected_errors[expected_errors_i]) {
ok(true, "Expected error received: " + obj.arguments[0]);
expected_errors_i++;
}
consoleListener.prototype = {
observe(aSubject) {
var obj = aSubject.wrappedJSObject;
if (obj.arguments[0] == expected_errors[expected_errors_i]) {
ok(true, "Expected error received: " + obj.arguments[0]);
expected_errors_i++;
}
if (expected_errors_i == expected_errors.length) {
// All errors have been received, this test has been completed
// succesfully!
ConsoleAPIStorage.removeLogEventListener(this.observe);
SimpleTest.finish();
}
if (expected_errors_i == expected_errors.length) {
// All errors have been received, this test has been completed
// succesfully!
ConsoleAPIStorage.removeLogEventListener(observe);
SimpleTest.finish();
}
}
var cl = new consoleListener();
ConsoleAPIStorage.addLogEventListener(observe, SpecialPowers.wrap(document).nodePrincipal);
}
// This function is called into an iframe.

Просмотреть файл

@ -32,6 +32,7 @@ function create_wasmModule() {
ok(WebAssembly, "WebAssembly object should exist");
ok(WebAssembly.compile, "WebAssembly.compile function should exist");
// eslint-disable-next-line no-unused-vars
const wasmTextToBinary = SpecialPowers.unwrap(SpecialPowers.Cu.getJSTestingFunctions().wasmTextToBinary);
/*
js -e '
@ -44,7 +45,6 @@ function create_wasmModule() {
print(t)
'
*/
// eslint-disable-next-line
const fooModuleCode = new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,127,3,2,1,0,7,7,1,3,102,111,111,0,0,10,6,1,4,0,65,42,11,0,13,4,110,97,109,101,1,6,1,0,3,102,111,111]);
WebAssembly.compile(fooModuleCode).then(m => {

Просмотреть файл

@ -31,6 +31,7 @@ function create_wasmModule() {
ok(WebAssembly, "WebAssembly object should exist");
ok(WebAssembly.compile, "WebAssembly.compile function should exist");
// eslint-disable-next-line no-unused-vars
const wasmTextToBinary = SpecialPowers.unwrap(SpecialPowers.Cu.getJSTestingFunctions().wasmTextToBinary);
/*
@ -44,7 +45,6 @@ function create_wasmModule() {
print(t)
'
*/
// eslint-disable-next-line
const fooModuleCode = new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,127,3,2,1,0,7,7,1,3,102,111,111,0,0,10,6,1,4,0,65,42,11,0,13,4,110,97,109,101,1,6,1,0,3,102,111,111]);
WebAssembly.compile(fooModuleCode).then(m => {

Просмотреть файл

@ -16,26 +16,18 @@ function configureTest() {
"@mozilla.org/consoleAPI-storage;1"
].getService(SpecialPowers.Ci.nsIConsoleAPIStorage);
function consoleListener() {
this.observe = this.observe.bind(this);
ConsoleAPIStorage.addLogEventListener(this.observe, SpecialPowers.wrap(document).nodePrincipal);
}
function observe(aSubject) {
var obj = aSubject.wrappedJSObject;
if (obj.arguments[0] == "Hello world from a worklet") {
ok(true, "Message received \\o/");
is(obj.filename,
new URL(WORKLET_SCRIPT, document.baseURI).toString());
consoleListener.prototype = {
observe(aSubject) {
var obj = aSubject.wrappedJSObject;
if (obj.arguments[0] == "Hello world from a worklet") {
ok(true, "Message received \\o/");
is(obj.filename,
new URL(WORKLET_SCRIPT, document.baseURI).toString());
ConsoleAPIStorage.removeLogEventListener(this.observe);
SimpleTest.finish();
}
ConsoleAPIStorage.removeLogEventListener(observe);
SimpleTest.finish();
}
}
var cl = new consoleListener();
ConsoleAPIStorage.addLogEventListener(observe, SpecialPowers.wrap(document).nodePrincipal);
}
// This function is called into an iframe.

Просмотреть файл

@ -20,23 +20,16 @@ function configureTest() {
// have limitations to post the result back to the main document:
// Worklets have a different global, and they don't have postMessage() APIs,
// and static import SimpleTest.js in worklets also don't work.
function consoleListener() {
this.observe = this.observe.bind(this);
ConsoleAPIStorage.addLogEventListener(this.observe, SpecialPowers.wrap(document).nodePrincipal);
function observe(aSubject) {
var obj = aSubject.wrappedJSObject;
info("Got console message:" + obj.arguments[0]);
is(TypeError.name + ": Success", obj.arguments[0], "import() should throw");
ConsoleAPIStorage.removeLogEventListener(observe);
SimpleTest.finish();
}
consoleListener.prototype = {
observe(aSubject) {
var obj = aSubject.wrappedJSObject;
info("Got console message:" + obj.arguments[0]);
is(TypeError.name + ": Success", obj.arguments[0], "import() should throw");
ConsoleAPIStorage.removeLogEventListener(this.observe);
SimpleTest.finish();
}
}
var cl = new consoleListener();
ConsoleAPIStorage.addLogEventListener(observe, SpecialPowers.wrap(document).nodePrincipal);
}
// This function is called into an iframe.

Просмотреть файл

@ -15,29 +15,23 @@ function configureTest() {
"@mozilla.org/consoleAPI-storage;1"
].getService(SpecialPowers.Ci.nsIConsoleAPIStorage);
function consoleListener() {
this.observe = this.observe.bind(this);
ConsoleAPIStorage.addLogEventListener(this.observe, SpecialPowers.wrap(document).nodePrincipal);
}
function observe(aSubject) {
var obj = aSubject.wrappedJSObject;
if (obj.arguments[0] == "So far so good") {
ok(true, "Message received \\o/");
consoleListener.prototype = {
observe(aSubject) {
var obj = aSubject.wrappedJSObject;
if (obj.arguments[0] == "So far so good") {
ok(true, "Message received \\o/");
ConsoleAPIStorage.removeLogEventListener(this.observe);
SimpleTest.finish();
}
ConsoleAPIStorage.removeLogEventListener(observe);
SimpleTest.finish();
}
}
var cl = new consoleListener();
ConsoleAPIStorage.addLogEventListener(observe, SpecialPowers.wrap(document).nodePrincipal);
return SpecialPowers.pushPrefEnv({ "set": [["dom.paintWorklet.enabled", true]] });
}
// This function is called into an iframe.
/* global paintWorklet */
function runTestInIframe() {
paintWorklet.addModule("worklet_paintWorklet.js")
}

Просмотреть файл

@ -31,6 +31,7 @@ async function runTestInIframe() {
SimpleTest.finish();
}
// eslint-disable-next-line no-unused-vars
const wasmTextToBinary = SpecialPowers.unwrap(SpecialPowers.Cu.getJSTestingFunctions().wasmTextToBinary);
/*
js -e '
@ -43,7 +44,6 @@ async function runTestInIframe() {
print(t)
'
*/
// eslint-disable-next-line
const fooModuleCode = new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,127,3,2,1,0,7,7,1,3,102,111,111,0,0,10,6,1,4,0,65,42,11,0,13,4,110,97,109,101,1,6,1,0,3,102,111,111]);
node.port.postMessage(fooModuleCode);

Просмотреть файл

@ -7,7 +7,7 @@ class WasmProcessWorkletProcessor extends AudioWorkletProcessor {
};
}
process(inputs, outputs, parameters) {
process() {
// Do nothing, output silence
return true;
}

Просмотреть файл

@ -4,7 +4,7 @@ class WasmProcessWorkletProcessor extends AudioWorkletProcessor {
this.port.postMessage(testModules());
}
process(inputs, outputs, parameters) {
process() {
// Do nothing, output silence
return true;
}
@ -12,7 +12,7 @@ class WasmProcessWorkletProcessor extends AudioWorkletProcessor {
function testModule(binary) {
try {
let wasmModule = new WebAssembly.Module(binary);
new WebAssembly.Module(binary);
} catch (error) {
if (error instanceof WebAssembly.CompileError) {
return error.message;

Просмотреть файл

@ -4,7 +4,7 @@ class OptionsProcessWorkletProcessor extends AudioWorkletProcessor {
this.port.postMessage(args[0].processorOptions);
}
process(inputs, outputs, parameters) {
process() {
return true;
}
}

Просмотреть файл

@ -1 +1,2 @@
// eslint-disable-next-line no-undef
foobar();

Просмотреть файл

@ -1,3 +1,4 @@
/* global registerPaint, PaintWorkletGlobalScope */
// This should work for real... at some point.
registerPaint("sure!", () => {});
console.log(

Просмотреть файл

@ -13,7 +13,7 @@ class WasmProcessWorkletProcessor extends AudioWorkletProcessor {
};
}
process(inputs, outputs, parameters) {
process() {
// Do nothing, output silence
return true;
}