mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1786094 - Enable ESlint rule no-unused-vars on the global scope for dom/localstorage xpcshell-tests. r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D155122
This commit is contained in:
parent
a76d24cb29
commit
66dfc61a41
@ -190,7 +190,6 @@ module.exports = {
|
||||
// investigation or different solutions. They are also likely to be
|
||||
// a reasonable size.
|
||||
"dom/indexedDB/**",
|
||||
"dom/localstorage/**",
|
||||
],
|
||||
rules: {
|
||||
// No declaring variables that are never used
|
||||
|
@ -38,17 +38,9 @@ if (!window.runTest) {
|
||||
|
||||
await requestFinished(clearAllDatabases());
|
||||
|
||||
ok(typeof testSteps === "function", "There should be a testSteps function");
|
||||
ok(
|
||||
testSteps.constructor.name === "AsyncFunction",
|
||||
"testSteps should be an async function"
|
||||
);
|
||||
|
||||
SimpleTest.registerCleanupFunction(async function() {
|
||||
await requestFinished(clearAllDatabases());
|
||||
});
|
||||
|
||||
add_task(testSteps);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -16,36 +16,15 @@ function ok(cond, msg) {
|
||||
Assert.ok(!!cond, msg);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
runTest();
|
||||
}
|
||||
add_setup(function() {
|
||||
do_get_profile();
|
||||
|
||||
if (!this.runTest) {
|
||||
this.runTest = function() {
|
||||
do_get_profile();
|
||||
enableTesting();
|
||||
|
||||
enableTesting();
|
||||
Cu.importGlobalProperties(["crypto"]);
|
||||
|
||||
Cu.importGlobalProperties(["crypto"]);
|
||||
|
||||
Assert.ok(
|
||||
typeof testSteps === "function",
|
||||
"There should be a testSteps function"
|
||||
);
|
||||
Assert.ok(
|
||||
testSteps.constructor.name === "AsyncFunction",
|
||||
"testSteps should be an async function"
|
||||
);
|
||||
|
||||
registerCleanupFunction(resetTesting);
|
||||
|
||||
add_task(testSteps);
|
||||
|
||||
// Since we defined run_test, we must invoke run_next_test() to start the
|
||||
// async test.
|
||||
run_next_test();
|
||||
};
|
||||
}
|
||||
registerCleanupFunction(resetTesting);
|
||||
});
|
||||
|
||||
function returnToEventLoop() {
|
||||
return new Promise(function(resolve) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
const lsArchiveFile = "storage/ls-archive.sqlite";
|
||||
|
||||
const principalInfo = {
|
||||
@ -75,4 +75,4 @@ async function testSteps() {
|
||||
ok(fileSize > 0, "archive file size is greater than zero");
|
||||
|
||||
checkStorage();
|
||||
}
|
||||
});
|
||||
|
@ -8,7 +8,7 @@
|
||||
* We turn on client validation for LocalStorage and ensure that we don't have
|
||||
* access to LocalStorage.
|
||||
*/
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
const principal = getPrincipal("http://example.com");
|
||||
|
||||
info("Setting prefs");
|
||||
@ -29,4 +29,4 @@ async function testSteps() {
|
||||
is(ex.name, "NS_ERROR_FAILURE", "Threw right Exception");
|
||||
is(ex.result, Cr.NS_ERROR_FAILURE, "Threw with right result");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -36,7 +36,7 @@ async function doTest(profile) {
|
||||
is(request.result.usage, 0, "Correct usage");
|
||||
}
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
info("Setting pref");
|
||||
|
||||
Services.prefs.setBoolPref(
|
||||
@ -70,4 +70,4 @@ async function testSteps() {
|
||||
for (const profile of profiles) {
|
||||
await doTest(profile);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* import-globals-from databaseShadowing-shared.js */
|
||||
loadSubscript("databaseShadowing-shared.js");
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
enableNextGenLocalStorage();
|
||||
|
||||
storeData();
|
||||
@ -20,4 +20,4 @@ async function testSteps() {
|
||||
exportShadowDatabase("shadowdb.sqlite");
|
||||
|
||||
// The shadow database is now prepared for test_databaseShadowing2.js
|
||||
}
|
||||
});
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* import-globals-from databaseShadowing-shared.js */
|
||||
loadSubscript("databaseShadowing-shared.js");
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
// The shadow database was prepared in test_databaseShadowing1.js
|
||||
|
||||
disableNextGenLocalStorage();
|
||||
@ -14,4 +14,4 @@ async function testSteps() {
|
||||
ok(importShadowDatabase("shadowdb.sqlite"), "Import succeeded");
|
||||
|
||||
verifyData([], /* migrated */ true);
|
||||
}
|
||||
});
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* import-globals-from databaseShadowing-shared.js */
|
||||
loadSubscript("databaseShadowing-shared.js");
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
enableNextGenLocalStorage();
|
||||
|
||||
storeData();
|
||||
@ -27,4 +27,4 @@ async function testSteps() {
|
||||
|
||||
// The shadow database is now prepared for
|
||||
// test_databaseShadowing_clearOrigin2.js
|
||||
}
|
||||
});
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* import-globals-from databaseShadowing-shared.js */
|
||||
loadSubscript("databaseShadowing-shared.js");
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
// The shadow database was prepared in test_databaseShadowing_clearOrigin1.js
|
||||
|
||||
disableNextGenLocalStorage();
|
||||
@ -14,4 +14,4 @@ async function testSteps() {
|
||||
ok(importShadowDatabase("shadowdb-clearedOrigin.sqlite"), "Import succeeded");
|
||||
|
||||
verifyData([1], /* migrated */ true);
|
||||
}
|
||||
});
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* import-globals-from databaseShadowing-shared.js */
|
||||
loadSubscript("databaseShadowing-shared.js");
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
enableNextGenLocalStorage();
|
||||
|
||||
storeData();
|
||||
@ -26,4 +26,4 @@ async function testSteps() {
|
||||
|
||||
// The shadow database is now prepared for
|
||||
// test_databaseShadowing_clearOriginsByPattern2.js
|
||||
}
|
||||
});
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* import-globals-from databaseShadowing-shared.js */
|
||||
loadSubscript("databaseShadowing-shared.js");
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
// The shadow database was prepared in
|
||||
// test_databaseShadowing_clearOriginsByPattern1.js
|
||||
|
||||
@ -18,4 +18,4 @@ async function testSteps() {
|
||||
);
|
||||
|
||||
verifyData([4, 5, 6], /* migrated */ true);
|
||||
}
|
||||
});
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* import-globals-from databaseShadowing-shared.js */
|
||||
loadSubscript("databaseShadowing-shared.js");
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
enableNextGenLocalStorage();
|
||||
|
||||
storeData();
|
||||
@ -25,4 +25,4 @@ async function testSteps() {
|
||||
|
||||
// The shadow database is now prepared for
|
||||
// test_databaseShadowing_clearOriginsByPrefix2.js
|
||||
}
|
||||
});
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* import-globals-from databaseShadowing-shared.js */
|
||||
loadSubscript("databaseShadowing-shared.js");
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
// The shadow database was prepared in
|
||||
// test_databaseShadowing_clearOriginsByPrefix1.js
|
||||
|
||||
@ -18,4 +18,4 @@ async function testSteps() {
|
||||
);
|
||||
|
||||
verifyData([2, 3], /* migrated */ true);
|
||||
}
|
||||
});
|
||||
|
@ -3,7 +3,7 @@
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
const globalLimitKB = 5 * 1024;
|
||||
|
||||
const data = {};
|
||||
@ -88,4 +88,4 @@ async function testSteps() {
|
||||
await requestFinished(request);
|
||||
|
||||
is(request.result.usage, 0, "Zero usage");
|
||||
}
|
||||
});
|
||||
|
@ -9,7 +9,7 @@
|
||||
* database in the event of early return due to error. See bug 1559029.
|
||||
*/
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
const principal1 = getPrincipal("http://example1.com");
|
||||
|
||||
const usageFile1 = getRelativeFile(
|
||||
@ -69,4 +69,4 @@ async function testSteps() {
|
||||
// Wait for all database connections to close.
|
||||
let request = reset();
|
||||
await requestFinished(request);
|
||||
}
|
||||
});
|
||||
|
@ -3,7 +3,7 @@
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
const groupLimitKB = 10 * 1024;
|
||||
|
||||
const globalLimitKB = groupLimitKB * 5;
|
||||
@ -82,4 +82,4 @@ async function testSteps() {
|
||||
for (let i = 0; i < urls.length; i++) {
|
||||
storages[i].setItem("B", "");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -9,7 +9,7 @@
|
||||
* quota object. See bug 1516333.
|
||||
*/
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
const principal = getPrincipal("https://foo.bar.mozilla-iot.org");
|
||||
|
||||
info("Clearing");
|
||||
@ -42,4 +42,4 @@ async function testSteps() {
|
||||
info("Adding item");
|
||||
|
||||
storage.setItem("foo", "bar");
|
||||
}
|
||||
});
|
||||
|
@ -10,7 +10,7 @@
|
||||
* IPC message size limit would be exceeded, resulting in a crash.
|
||||
*/
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
const globalLimitKB = 5 * 1024;
|
||||
|
||||
// 18 and more iterations would produce an IPC message with size greater than
|
||||
@ -85,4 +85,4 @@ async function testSteps() {
|
||||
await returnToEventLoop();
|
||||
|
||||
ok(!storage.hasSnapshot, "Snapshot successfully finished");
|
||||
}
|
||||
});
|
||||
|
@ -8,7 +8,6 @@
|
||||
* can lead to a data loss in a combination with disabled shadow writes.
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
ok(Services.domStorageManager.nextGenLocalStorageEnabled, "LSNG enabled");
|
||||
}
|
||||
});
|
||||
|
@ -3,7 +3,7 @@
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
const principalInfos = [
|
||||
{ url: "http://localhost", attrs: {} },
|
||||
{ url: "http://www.mozilla.org", attrs: {} },
|
||||
@ -124,4 +124,4 @@ async function testSteps() {
|
||||
|
||||
verifyData(clearedOrigins);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -3,8 +3,7 @@
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
const data = {
|
||||
key: "foo",
|
||||
value: "",
|
||||
@ -35,4 +34,4 @@ async function testSteps() {
|
||||
info("Verifying data");
|
||||
|
||||
is(storage.getItem(data.key), data.value, "Correct value");
|
||||
}
|
||||
});
|
||||
|
@ -8,11 +8,10 @@
|
||||
* implementations has no effect anymore.
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
info("Setting pref");
|
||||
|
||||
Services.prefs.setBoolPref("dom.storage.next_gen", false);
|
||||
|
||||
ok(Services.domStorageManager.nextGenLocalStorageEnabled, "LSNG enabled");
|
||||
}
|
||||
});
|
||||
|
@ -3,7 +3,7 @@
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
const url = "http://example.com";
|
||||
|
||||
info("Setting pref");
|
||||
@ -67,4 +67,4 @@ async function testSteps() {
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
is(keys[i], savedKeys[i], "Correct key");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -3,7 +3,7 @@
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
const storageDirName = "storage";
|
||||
const persistenceTypeDefaultDirName = "default";
|
||||
const persistenceTypePersistentDirName = "permanent";
|
||||
@ -369,4 +369,4 @@ async function testSteps() {
|
||||
ok(exists, "ls directory in permanent origin directory does exist");
|
||||
|
||||
await clearPersistentTestOrigin();
|
||||
}
|
||||
});
|
||||
|
@ -3,7 +3,7 @@
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
const principals = [
|
||||
getPrincipal("http://example.com", {}),
|
||||
getPrincipal("http://example.com", { privateBrowsingId: 1 }),
|
||||
@ -81,4 +81,4 @@ async function testSteps() {
|
||||
"Data is not preloaded after clearing origin"
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -3,7 +3,7 @@
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
const url = "http://example.com";
|
||||
|
||||
info("Setting pref");
|
||||
@ -36,4 +36,4 @@ async function testSteps() {
|
||||
|
||||
let storage = getLocalStorage(getPrincipal(url));
|
||||
storage.open();
|
||||
}
|
||||
});
|
||||
|
@ -2,9 +2,8 @@
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
/* eslint no-unused-vars: ["warn", { "varsIgnorePattern": "(testSteps)" }]*/
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
const url = "http://example.com";
|
||||
|
||||
info("Setting pref");
|
||||
@ -37,4 +36,4 @@ async function testSteps() {
|
||||
|
||||
let storage = getLocalStorage(getPrincipal(url));
|
||||
storage.open();
|
||||
}
|
||||
});
|
||||
|
@ -3,7 +3,7 @@
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
const url = "http://example.com";
|
||||
|
||||
info("Setting pref");
|
||||
@ -327,4 +327,4 @@ async function testSteps() {
|
||||
await returnToEventLoop();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -3,7 +3,7 @@
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
const principal = getPrincipal("http://example.org");
|
||||
|
||||
const data = {};
|
||||
@ -71,4 +71,4 @@ async function testSteps() {
|
||||
|
||||
value = storage.getItem(data.secondKey);
|
||||
ok(value.length === data.value.length, "Correct string length");
|
||||
}
|
||||
});
|
||||
|
@ -8,7 +8,7 @@
|
||||
* database values containing NULs. See bug 1541681.
|
||||
*/
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
const principal = getPrincipal("http://example.org");
|
||||
|
||||
const data = {};
|
||||
@ -76,4 +76,4 @@ async function testSteps() {
|
||||
|
||||
value = storage.getItem(data.secondKey);
|
||||
ok(value.length === data.value.length, "Correct string length");
|
||||
}
|
||||
});
|
||||
|
@ -135,8 +135,7 @@ const fetchFromNewSnapshotNewDatastore = async (itemKey, sample) => {
|
||||
});
|
||||
};
|
||||
|
||||
/* eslint no-unused-vars: ["warn", { "varsIgnorePattern": "(testSteps)" }]*/
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
/* This test is based on bug 1681300 */
|
||||
Services.prefs.setBoolPref(
|
||||
"dom.storage.enable_unsupported_legacy_implementation",
|
||||
@ -203,4 +202,4 @@ async function testSteps() {
|
||||
"NewSnapshotNewDatastore",
|
||||
fetchFromNewSnapshotNewDatastore
|
||||
);
|
||||
}
|
||||
});
|
||||
|
@ -11,7 +11,7 @@
|
||||
* of a null quota object. See bug 1516333.
|
||||
*/
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
/**
|
||||
* The edge cases are specified in this array of origins. Each edge case must
|
||||
* contain two properties uri and path (origin directory path relative to the
|
||||
@ -66,4 +66,4 @@ async function testSteps() {
|
||||
|
||||
ok(originDir.exists(), `The origin directory ${origin.path} should exist`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -3,7 +3,7 @@
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
const data = {};
|
||||
data.key = "key1";
|
||||
data.value = "value1";
|
||||
@ -66,4 +66,4 @@ async function testSteps() {
|
||||
await requestFinished(request);
|
||||
|
||||
is(request.result.usage, 0, "Correct usage");
|
||||
}
|
||||
});
|
||||
|
@ -3,7 +3,7 @@
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
async function testSteps() {
|
||||
add_task(async function testSteps() {
|
||||
const principal = getPrincipal("http://example.com");
|
||||
|
||||
const dataFile = getRelativeFile(
|
||||
@ -161,4 +161,4 @@ async function testSteps() {
|
||||
verifyData();
|
||||
|
||||
await verifyUsage(/* success */ true);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user