diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/cache/test/mochitest/test_cache_worker_gc.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | dom/cache/test/mochitest/test_cache_worker_gc.html | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/dom/cache/test/mochitest/test_cache_worker_gc.html b/dom/cache/test/mochitest/test_cache_worker_gc.html new file mode 100644 index 0000000000..798bafaf9b --- /dev/null +++ b/dom/cache/test/mochitest/test_cache_worker_gc.html @@ -0,0 +1,58 @@ +<!-- Any copyright is dedicated to the Public Domain. + - http://creativecommons.org/publicdomain/zero/1.0/ --> +<!DOCTYPE HTML> +<html> +<head> + <title>Test CacheStorage does not prevent worker GC</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> + <script type="text/javascript" src="driver.js"></script> +</head> +<body> +<iframe id="frame"></iframe> +<script class="testbody" type="text/javascript"> +function startWorker() { + return new Promise(resolve => { + var w = new Worker("idle_worker.js"); + w.addEventListener("message", function onMessage(evt) { + if (evt.data === "LOADED") { + w.removeEventListener("message", onMessage); + resolve(w); + } + }); + }); +} + +function gc() { + return new Promise(resolve => { + SpecialPowers.exactGC(resolve); + }); +} + +SimpleTest.waitForExplicitFinish(); + +async function test() { + let w = await startWorker(); + let weakWorker = SpecialPowers.Cu.getWeakReference(w); + ok(weakWorker, "worker supports weak reference"); + w = null; + await gc(); + await gc(); + ok(!weakWorker.get(), "worker weak reference should be garbage collected"); + SimpleTest.finish(); +} +// Bug 1746646: Make mochitests work with TCP enabled (cookieBehavior = 5) +// Acquire storage access permission here so that the Cache API is avaialable +SpecialPowers.wrap(document).notifyUserGestureActivation(); +SpecialPowers.addPermission("storageAccessAPI", true, window.location.href).then(() => { + SpecialPowers.wrap(document).requestStorageAccess().then(() => { + SpecialPowers.pushPrefEnv({ + set: [["privacy.partition.always_partition_third_party_non_cookie_storage", false]], + }).then(() => { + test(); + }); + }); +}); +</script> +</body> +</html> |