Bug 1876988 - Enable remaining ESLint rules on dom/file/ipc. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D199813
This commit is contained in:
Mark Banner 2024-01-29 11:23:59 +00:00
parent 2cdfd413a4
commit 30b1ef027d
5 changed files with 53 additions and 44 deletions

View File

@ -432,7 +432,6 @@ module.exports = {
"dom/canvas/test/**",
"dom/events/test/**",
"dom/fetch/tests/**",
"dom/file/ipc/tests/**",
"dom/file/tests/**",
"dom/html/test/**",
"dom/jsurl/test/**",

View File

@ -10,8 +10,8 @@ add_task(async function test_CtoPtoC_big() {
let browser1 = gBrowser.getBrowserForTab(tab1);
let blob = await SpecialPowers.spawn(browser1, [], function () {
let blob = new Blob([new Array(1024 * 1024).join("123456789ABCDEF")]);
return blob;
let innerBlob = new Blob([new Array(1024 * 1024).join("123456789ABCDEF")]);
return innerBlob;
});
ok(blob, "CtoPtoC-big: We have a blob!");
@ -24,15 +24,19 @@ add_task(async function test_CtoPtoC_big() {
let tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
let browser2 = gBrowser.getBrowserForTab(tab2);
let status = await SpecialPowers.spawn(browser2, [blob], function (blob) {
return new Promise(resolve => {
let fr = new content.FileReader();
fr.readAsText(blob);
fr.onloadend = function () {
resolve(fr.result == new Array(1024 * 1024).join("123456789ABCDEF"));
};
});
});
let status = await SpecialPowers.spawn(
browser2,
[blob],
function (innerBlob) {
return new Promise(resolve => {
let fr = new content.FileReader();
fr.readAsText(innerBlob);
fr.onloadend = function () {
resolve(fr.result == new Array(1024 * 1024).join("123456789ABCDEF"));
};
});
}
);
ok(status, "CtoPtoC-big: Data match!");
@ -46,8 +50,8 @@ add_task(async function test_CtoPtoC_small() {
let browser1 = gBrowser.getBrowserForTab(tab1);
let blob = await SpecialPowers.spawn(browser1, [], function () {
let blob = new Blob(["hello world!"]);
return blob;
let innerBlob = new Blob(["hello world!"]);
return innerBlob;
});
ok(blob, "CtoPtoC-small: We have a blob!");
@ -56,15 +60,19 @@ add_task(async function test_CtoPtoC_small() {
let tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
let browser2 = gBrowser.getBrowserForTab(tab2);
let status = await SpecialPowers.spawn(browser2, [blob], function (blob) {
return new Promise(resolve => {
let fr = new content.FileReader();
fr.readAsText(blob);
fr.onloadend = function () {
resolve(fr.result == "hello world!");
};
});
});
let status = await SpecialPowers.spawn(
browser2,
[blob],
function (innerBlob) {
return new Promise(resolve => {
let fr = new content.FileReader();
fr.readAsText(innerBlob);
fr.onloadend = function () {
resolve(fr.result == "hello world!");
};
});
}
);
ok(status, "CtoPtoC-small: Data match!");
@ -161,10 +169,10 @@ add_task(async function test_CtoPtoC_bc_small() {
let status = await SpecialPowers.spawn(
browser2,
[blobURL],
function (blobURL) {
function (innerBlobURL) {
return new Promise(resolve => {
var xhr = new content.XMLHttpRequest();
xhr.open("GET", blobURL);
xhr.open("GET", innerBlobURL);
xhr.onloadend = function () {
resolve(xhr.response == "hello world!");
};
@ -197,15 +205,19 @@ add_task(async function test_CtoPtoC_multipart() {
let tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
let browser2 = gBrowser.getBrowserForTab(tab2);
let status = await SpecialPowers.spawn(browser2, [newBlob], function (blob) {
return new Promise(resolve => {
let fr = new content.FileReader();
fr.readAsText(new Blob(["hello ", blob]));
fr.onloadend = function () {
resolve(fr.result == "hello world!");
};
});
});
let status = await SpecialPowers.spawn(
browser2,
[newBlob],
function (innerBlob) {
return new Promise(resolve => {
let fr = new content.FileReader();
fr.readAsText(new Blob(["hello ", innerBlob]));
fr.onloadend = function () {
resolve(fr.result == "hello world!");
};
});
}
);
ok(status, "CtoPtoC-multipart: Data match!");

View File

@ -23,7 +23,7 @@ add_task(async function test() {
let bc = new content.window.BroadcastChannel("foobar");
bc.onmessage = e => {
function realTest() {
return new content.window.Promise(resolve => {
return new content.window.Promise(innerResolve => {
let count = 10;
for (let i = 0; i < count; ++i) {
info("FileReader at the same time: " + i);
@ -36,7 +36,7 @@ add_task(async function test() {
fr.onloadend = () => {
is(fr.result.length, e.data.size, "FileReader worked fine.");
if (!--count) {
resolve(true);
innerResolve(true);
}
};
}

View File

@ -4,8 +4,7 @@
Cu.importGlobalProperties(["File"]);
addMessageListener("file.open", function (e) {
var testFile = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIDirectoryService)
var testFile = Services.dirsvc
.QueryInterface(Ci.nsIProperties)
.get("ProfD", Ci.nsIFile);
testFile.append("ipc_fileReader_testing");
@ -31,8 +30,7 @@ addMessageListener("file.open", function (e) {
});
addMessageListener("emptyfile.open", function (e) {
var testFile = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIDirectoryService)
var testFile = Services.dirsvc
.QueryInterface(Ci.nsIProperties)
.get("ProfD", Ci.nsIFile);
testFile.append("ipc_fileReader_testing");

View File

@ -22,8 +22,8 @@ function test_mainThread() {
}
fetch('green.jpg').then(r => r.blob()).then(blob => {
let bc = new BroadcastChannel('testMainThread');
bc.postMessage(blob);
let innerBc = new BroadcastChannel('testMainThread');
innerBc.postMessage(blob);
});
}
@ -42,8 +42,8 @@ function test_worker() {
}
fetch('http://mochi.test:8888/tests/dom/file/ipc/tests/green.jpg').then(r => r.blob()).then(blob => {
let bc = new BroadcastChannel('testWorker');
bc.postMessage(blob);
let innerBc = new BroadcastChannel('testWorker');
innerBc.postMessage(blob);
});
}
let workerUrl = URL.createObjectURL(new Blob(["(", workerScript.toString(), ")()"]));