Bug 1778112 - Move dom/quota/test to use mjs files, rather than defining sourceType for ESLint. r=asuth

Differential Revision: https://phabricator.services.mozilla.com/D183371
This commit is contained in:
Mark Banner 2023-07-13 13:56:12 +00:00
Родитель 676bec4c48
Коммит 602952a200
11 изменённых файлов: 32 добавлений и 59 удалений

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

@ -6,16 +6,16 @@
async function require_module(id) {
if (!require_module.moduleLoader) {
const { ModuleLoader } = await import(
"/tests/dom/quota/test/modules/ModuleLoader.js"
"/tests/dom/quota/test/modules/ModuleLoader.mjs"
);
const base = window.location.href;
const depth = "../../../../";
const { Assert } = await import("/tests/dom/quota/test/modules/Assert.js");
const { Assert } = await import("/tests/dom/quota/test/modules/Assert.mjs");
const { Utils } = await import("/tests/dom/quota/test/modules/Utils.js");
const { Utils } = await import("/tests/dom/quota/test/modules/Utils.mjs");
const proto = {
Assert,
@ -33,7 +33,7 @@ async function require_module(id) {
async function run_test_in_worker(script) {
const { runTestInWorker } = await import(
"/tests/dom/quota/test/modules/WorkerDriver.js"
"/tests/dom/quota/test/modules/WorkerDriver.mjs"
);
const base = window.location.href;
@ -63,7 +63,7 @@ async function removeAllEntries() {
add_setup(async function () {
const { setStoragePrefs, clearStoragesForOrigin } = await import(
"/tests/dom/quota/test/modules/StorageUtils.js"
"/tests/dom/quota/test/modules/StorageUtils.mjs"
);
const optionalPrefsToSet = [

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

@ -1,24 +0,0 @@
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
"use strict";
module.exports = {
overrides: [
{
files: [
"Assert.js",
"ModuleLoader.js",
"StorageUtils.js",
"Utils.js",
"UtilsParent.js",
"WorkerDriver.js",
],
parserOptions: {
sourceType: "module",
},
},
],
};

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

@ -3,6 +3,10 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This file expectes the simpletest environment to be available in the scope
// it is loaded into.
/* eslint-env mozilla/simpletest */
// Just a wrapper around SimpleTest related functions for now.
export const Assert = {
ok,

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

@ -3,6 +3,10 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This file expectes the SpecialPowers to be available in the scope
// it is loaded into.
/* global SpecialPowers */
export function ModuleLoader(base, depth, proto) {
const modules = {};

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

@ -3,6 +3,10 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This file expectes the SpecialPowers to be available in the scope
// it is loaded into.
/* global SpecialPowers */
class RequestError extends Error {
constructor(resultCode, resultName) {
super(`Request failed (code: ${resultCode}, name: ${resultName})`);

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

@ -3,7 +3,11 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
import { getUsageForOrigin } from "/tests/dom/quota/test/modules/StorageUtils.js";
// This file expectes the SpecialPowers to be available in the scope
// it is loaded into.
/* global SpecialPowers */
import { getUsageForOrigin } from "./StorageUtils.mjs";
export const Utils = {
async getCachedOriginUsage() {

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

@ -3,7 +3,7 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
import { Utils } from "/tests/dom/quota/test/modules/Utils.js";
import { Utils } from "./Utils.mjs";
export const UtilsParent = {
async OnMessageReceived(worker, msg) {

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

@ -23,7 +23,7 @@ export async function runTestInWorker(script, base, listener) {
if (!modules[moduleName]) {
// eslint-disable-next-line no-unsanitized/method
modules[moduleName] = await import(
"/tests/dom/quota/test/modules/" + moduleName + ".js"
"/tests/dom/quota/test/modules/" + moduleName + ".mjs"
);
}
await modules[moduleName][objectName].OnMessageReceived(worker, data);

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

@ -1,21 +0,0 @@
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
"use strict";
module.exports = {
env: {
worker: true,
},
overrides: [
{
files: ["Assert.js", "ModuleLoader.js", "Utils.js"],
parserOptions: {
sourceType: "script",
},
},
],
};

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

@ -3,6 +3,8 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/* eslint-env worker */
const Cr = {
NS_ERROR_NOT_IMPLEMENTED: 2147500033,
};

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

@ -38,12 +38,12 @@ TEST_HARNESS_FILES.testing.mochitest.tests.dom.quota.test.common += [
]
TEST_HARNESS_FILES.testing.mochitest.tests.dom.quota.test.modules += [
"modules/content/Assert.js",
"modules/content/ModuleLoader.js",
"modules/content/StorageUtils.js",
"modules/content/Utils.js",
"modules/content/UtilsParent.js",
"modules/content/WorkerDriver.js",
"modules/content/Assert.mjs",
"modules/content/ModuleLoader.mjs",
"modules/content/StorageUtils.mjs",
"modules/content/Utils.mjs",
"modules/content/UtilsParent.mjs",
"modules/content/WorkerDriver.mjs",
]
TEST_HARNESS_FILES.testing.mochitest.tests.dom.quota.test.modules.worker += [