// Verify the service worker script cache has the worker script stored.
let chromeCaches = SpecialPowers.createChromeCache('chrome', window.origin);
let scriptURL = new URL(script, window.location.href);
let response = await chromeCaches.match(scriptURL.href);
is(response.url, scriptURL.href, 'worker script should be stored');
// Force delete the service worker script out from under the service worker.
// Note: Prefs are set to kill the SW thread immediately on idle.
await deleteCaches(chromeCaches);
// Verify the service script cache no longer knows about the worker script.
response = await chromeCaches.match(scriptURL.href);
is(response, undefined, 'worker script should not be stored');
// Force an update and wait for it to fire an update event.
reg.update();
await waitForUpdate(reg);
await waitForState(reg.installing, 'activated');
// Verify that the script cache knows about the worker script again.
response = await chromeCaches.match(scriptURL.href);
is(response.url, scriptURL.href, 'worker script should be stored');
} catch (e) {
ok(false, e);
}
if (reg) {
await reg.unregister();
}
// If this test is run on windows and the process shuts down immediately after, then
// we may fail to remove some of the Cache API body files. This is because the GC
// runs late causing Cache API to cleanup after shutdown begins. It seems something
// during shutdown scans these files and conflicts with removing the file on windows.
//
// To avoid this we perform an explict GC here to ensure that Cache API can cleanup
// earlier.
await new Promise(resolve => SpecialPowers.exactGC(resolve));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.