forked from Floorp-Projects/Floorp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1750933 - Add testing infrastructure for OPFS; r=dom-storage-revi…
…ewers,jari Differential Revision: https://phabricator.services.mozilla.com/D136317
- Loading branch information
Showing
29 changed files
with
787 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
"use strict"; | ||
|
||
module.exports = { | ||
globals: { | ||
Assert: true, | ||
exported_symbols: true, | ||
require_module: true, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* Any copyright is dedicated to the Public Domain. | ||
* http://creativecommons.org/publicdomain/zero/1.0/ | ||
*/ | ||
|
||
const nsresult = { | ||
NS_ERROR_NOT_IMPLEMENTED: Cr.NS_ERROR_NOT_IMPLEMENTED, | ||
}; | ||
exported_symbols.nsresult = nsresult; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Any copyright is dedicated to the Public Domain. | ||
* http://creativecommons.org/publicdomain/zero/1.0/ | ||
*/ | ||
|
||
async function test1() { | ||
const { nsresult } = await require_module("dom/fs/test/common/nsresult.js"); | ||
|
||
try { | ||
await navigator.storage.getDirectory(); | ||
|
||
Assert.ok(false, "Should have thrown"); | ||
} catch (e) { | ||
Assert.ok(true, "Should have thrown"); | ||
Assert.ok( | ||
e.result === nsresult.NS_ERROR_NOT_IMPLEMENTED, | ||
"Threw right result code" | ||
); | ||
} | ||
} | ||
exported_symbols.test1 = test1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* Any copyright is dedicated to the Public Domain. | ||
* http://creativecommons.org/publicdomain/zero/1.0/ | ||
*/ | ||
|
||
async function require_module(id) { | ||
if (!require_module.moduleLoader) { | ||
const { ModuleLoader } = await import( | ||
"/tests/dom/quota/test/modules/ModuleLoader.js" | ||
); | ||
|
||
const base = window.location.href; | ||
|
||
const depth = "../../../../"; | ||
|
||
const { Assert } = await import("/tests/dom/quota/test/modules/Assert.js"); | ||
|
||
const proto = { | ||
Assert, | ||
Cr: SpecialPowers.Cr, | ||
navigator, | ||
}; | ||
|
||
require_module.moduleLoader = new ModuleLoader(base, depth, proto); | ||
} | ||
|
||
return require_module.moduleLoader.require(id); | ||
} | ||
|
||
async function run_test_in_worker(script) { | ||
const { runTestInWorker } = await import( | ||
"/tests/dom/quota/test/modules/WorkerDriver.js" | ||
); | ||
await runTestInWorker(script); | ||
} | ||
|
||
// XXX It would be nice if we could call add_setup here (xpcshell-test and | ||
// browser-test support it. | ||
add_task(async function() { | ||
const { setStoragePrefs, clearStoragesForOrigin } = await import( | ||
"/tests/dom/quota/test/modules/StorageUtils.js" | ||
); | ||
|
||
const optionalPrefsToSet = [["dom.fs.enabled", true]]; | ||
|
||
await setStoragePrefs(optionalPrefsToSet); | ||
|
||
SimpleTest.registerCleanupFunction(async function() { | ||
await clearStoragesForOrigin(SpecialPowers.wrap(document).nodePrincipal); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
[DEFAULT] | ||
support-files = | ||
head.js | ||
|
||
[test_basics.html] | ||
scheme=https | ||
[test_basics_worker.html] | ||
scheme=https |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!-- | ||
Any copyright is dedicated to the Public Domain. | ||
http://creativecommons.org/publicdomain/zero/1.0/ | ||
--> | ||
<html> | ||
<head> | ||
<title>File System Test</title> | ||
|
||
<script src="/tests/SimpleTest/SimpleTest.js"></script> | ||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> | ||
|
||
<script type="text/javascript" src="head.js"></script> | ||
<script type="text/javascript"> | ||
add_task(async function test_1() { | ||
const { test1 } = await require_module("dom/fs/test/common/test_basics.js"); | ||
|
||
await test1(); | ||
}); | ||
</script> | ||
</head> | ||
|
||
<body></body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!-- | ||
Any copyright is dedicated to the Public Domain. | ||
http://creativecommons.org/publicdomain/zero/1.0/ | ||
--> | ||
<html> | ||
<head> | ||
<title>File System Test</title> | ||
|
||
<script src="/tests/SimpleTest/SimpleTest.js"></script> | ||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> | ||
|
||
<script type="text/javascript" src="head.js"></script> | ||
<script type="text/javascript"> | ||
add_task(async function worker() { | ||
await run_test_in_worker("worker/test_basics_worker.js"); | ||
}); | ||
</script> | ||
</head> | ||
|
||
<body></body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* Any copyright is dedicated to the Public Domain. | ||
* http://creativecommons.org/publicdomain/zero/1.0/ | ||
*/ | ||
|
||
"use strict"; | ||
|
||
module.exports = { | ||
env: { | ||
worker: true, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Any copyright is dedicated to the Public Domain. | ||
* http://creativecommons.org/publicdomain/zero/1.0/ | ||
*/ | ||
|
||
async function require_module(id) { | ||
if (!require_module.moduleLoader) { | ||
importScripts("/tests/dom/quota/test/modules/worker/ModuleLoader.js"); | ||
|
||
const base = location.href; | ||
|
||
const depth = "../../../../../"; | ||
|
||
importScripts("/tests/dom/quota/test/modules/worker/Assert.js"); | ||
|
||
require_module.moduleLoader = new globalThis.ModuleLoader(base, depth); | ||
} | ||
|
||
return require_module.moduleLoader.require(id); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* Any copyright is dedicated to the Public Domain. | ||
* http://creativecommons.org/publicdomain/zero/1.0/ | ||
*/ | ||
|
||
add_task(async function test_1() { | ||
const { test1 } = await require_module("dom/fs/test/common/test_basics.js"); | ||
|
||
await test1(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- | ||
# vim: set filetype=python: | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
MOCHITEST_MANIFESTS += [ | ||
"mochitest/mochitest.ini", | ||
] | ||
|
||
XPCSHELL_TESTS_MANIFESTS += [ | ||
"xpcshell/xpcshell.ini", | ||
] | ||
|
||
TEST_HARNESS_FILES.testing.mochitest.tests.dom.fs.test.common += [ | ||
"common/nsresult.js", | ||
"common/test_basics.js", | ||
] | ||
|
||
TEST_HARNESS_FILES.testing.mochitest.tests.dom.fs.test.mochitest.worker += [ | ||
"mochitest/worker/head.js", | ||
"mochitest/worker/test_basics_worker.js", | ||
] | ||
|
||
TEST_HARNESS_FILES.xpcshell.dom.fs.test.common += [ | ||
"common/nsresult.js", | ||
"common/test_basics.js", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* Any copyright is dedicated to the Public Domain. | ||
* http://creativecommons.org/publicdomain/zero/1.0/ | ||
*/ | ||
|
||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); | ||
|
||
async function require_module(id) { | ||
if (!require_module.moduleLoader) { | ||
const { ModuleLoader } = ChromeUtils.import( | ||
"resource://testing-common/dom/quota/test/modules/ModuleLoader.jsm" | ||
); | ||
|
||
const base = Services.io.newFileURI(do_get_file("")).spec; | ||
|
||
const depth = "../../../../"; | ||
|
||
Cu.importGlobalProperties(["storage"]); | ||
|
||
const proto = { | ||
Assert, | ||
Cr, | ||
navigator: { | ||
storage, | ||
}, | ||
}; | ||
|
||
require_module.moduleLoader = new ModuleLoader(base, depth, proto); | ||
} | ||
|
||
return require_module.moduleLoader.require(id); | ||
} | ||
|
||
add_setup(async function() { | ||
const { | ||
setStoragePrefs, | ||
clearStoragePrefs, | ||
clearStoragesForOrigin, | ||
} = ChromeUtils.import( | ||
"resource://testing-common/dom/quota/test/modules/StorageUtils.jsm" | ||
); | ||
|
||
const optionalPrefsToSet = [["dom.fs.enabled", true]]; | ||
|
||
setStoragePrefs(optionalPrefsToSet); | ||
|
||
registerCleanupFunction(async function() { | ||
const principal = Cc["@mozilla.org/systemprincipal;1"].createInstance( | ||
Ci.nsIPrincipal | ||
); | ||
|
||
await clearStoragesForOrigin(principal); | ||
|
||
const optionalPrefsToClear = ["dom.fs.enabled"]; | ||
|
||
clearStoragePrefs(optionalPrefsToClear); | ||
}); | ||
|
||
do_get_profile(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* Any copyright is dedicated to the Public Domain. | ||
* http://creativecommons.org/publicdomain/zero/1.0/ | ||
*/ | ||
|
||
add_task(async function test_1() { | ||
const { test1 } = await require_module("dom/fs/test/common/test_basics.js"); | ||
|
||
await test1(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
[DEFAULT] | ||
head = head.js | ||
|
||
[test_basics.js] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* Any copyright is dedicated to the Public Domain. | ||
* http://creativecommons.org/publicdomain/zero/1.0/ | ||
*/ | ||
|
||
"use strict"; | ||
|
||
module.exports = { | ||
extends: ["plugin:mozilla/mochitest-test"], | ||
|
||
overrides: [ | ||
{ | ||
files: [ | ||
"Assert.js", | ||
"ModuleLoader.js", | ||
"StorageUtils.js", | ||
"WorkerDriver.js", | ||
], | ||
parserOptions: { | ||
sourceType: "module", | ||
}, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Any copyright is dedicated to the Public Domain. | ||
* http://creativecommons.org/publicdomain/zero/1.0/ | ||
*/ | ||
|
||
// Just a wrapper around SimpleTest related functions for now. | ||
export const Assert = { | ||
ok(value, message) { | ||
ok(value, message); | ||
}, | ||
}; |
Oops, something went wrong.