зеркало из https://github.com/mozilla/gecko-dev.git
49 строки
1.2 KiB
HTML
49 строки
1.2 KiB
HTML
<!-- 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();
|
|
}
|
|
|
|
test();
|
|
</script>
|
|
</body>
|
|
</html>
|