diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /dom/localstorage/test/unit/test_preloading.js | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/localstorage/test/unit/test_preloading.js')
-rw-r--r-- | dom/localstorage/test/unit/test_preloading.js | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/dom/localstorage/test/unit/test_preloading.js b/dom/localstorage/test/unit/test_preloading.js new file mode 100644 index 0000000000..bf7bad6ae3 --- /dev/null +++ b/dom/localstorage/test/unit/test_preloading.js @@ -0,0 +1,81 @@ +/** + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +async function testSteps() { + const principals = [ + getPrincipal("http://example.com", {}), + getPrincipal("http://example.com", { privateBrowsingId: 1 }), + ]; + + async function isPreloaded(principal) { + return Services.domStorageManager.isPreloaded(principal); + } + + info("Setting prefs"); + + Services.prefs.setBoolPref("dom.storage.next_gen", true); + Services.prefs.setBoolPref("dom.storage.snapshot_reusing", false); + + for (const principal of principals) { + info("Getting storage"); + + let storage = getLocalStorage(principal); + + ok( + !(await isPreloaded(principal)), + "Data is not preloaded after getting storage" + ); + + info("Opening storage"); + + storage.open(); + + ok(await isPreloaded(principal), "Data is preloaded after opening storage"); + + info("Closing storage"); + + storage.close(); + + if (principal.privateBrowsingId > 0) { + ok( + await isPreloaded(principal), + "Data is still preloaded after closing storage" + ); + + info("Closing private session"); + + Services.obs.notifyObservers(null, "last-pb-context-exited"); + + ok( + !(await isPreloaded(principal)), + "Data is not preloaded anymore after closing private session" + ); + } else { + ok( + !(await isPreloaded(principal)), + "Data is not preloaded anymore after closing storage" + ); + } + + info("Opening storage again"); + + storage.open(); + + ok( + await isPreloaded(principal), + "Data is preloaded after opening storage again" + ); + + info("Clearing origin"); + + let request = clearOrigin(principal, "default"); + await requestFinished(request); + + ok( + !(await isPreloaded(principal)), + "Data is not preloaded after clearing origin" + ); + } +} |