diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/service-workers/service-worker/unregister-immediately-during-extendable-events.https.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/service-workers/service-worker/unregister-immediately-during-extendable-events.https.html')
-rw-r--r-- | testing/web-platform/tests/service-workers/service-worker/unregister-immediately-during-extendable-events.https.html | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/testing/web-platform/tests/service-workers/service-worker/unregister-immediately-during-extendable-events.https.html b/testing/web-platform/tests/service-workers/service-worker/unregister-immediately-during-extendable-events.https.html new file mode 100644 index 0000000000..6ba87a7ce8 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/unregister-immediately-during-extendable-events.https.html @@ -0,0 +1,50 @@ +<!doctype html> +<meta charset=utf-8> +<title>Use Clear-Site-Data to immediately unregister service workers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="resources/test-helpers.sub.js"></script> +<script src="resources/unregister-immediately-helpers.js"></script> +<body> +<script> +'use strict'; + +// These tests use the Clear-Site-Data network response header to immediately +// unregister a service worker registration with a worker that has pending +// extendable events. Clear-Site-Data must delete the registration, +// abort all pending extendable events and then clear the registration by +// setting the worker's state to 'redundant' + +promise_test(async test => { + // Use a service worker script that can produce fetch events with pending + // respondWith() promises that never resolve. + const script_url = 'resources/onfetch-waituntil-forever.js'; + const scope_url = + 'resources/blank.html?unregister-immediately-with-fetch-event'; + + const registration = await service_worker_unregister_and_register( + test, script_url, scope_url); + + await wait_for_state(test, registration.installing, 'activated'); + + const frame = await add_controlled_iframe(test, scope_url); + + // Clear-Site-Data must cause the pending fetch promise to reject. + const fetch_promise = promise_rejects_js( + test, TypeError, frame.contentWindow.fetch('waituntil-forever')); + + const event_watcher = new EventWatcher( + test, frame.contentWindow.navigator.serviceWorker, 'controllerchange'); + + await Promise.all([ + clear_site_data(), + fetch_promise, + event_watcher.wait_for('controllerchange'), + wait_for_state(test, registration.active, 'redundant'),]); + + assert_equals(frame.contentWindow.navigator.serviceWorker.controller, null); + await assert_no_registrations_exist(); +}, 'Clear-Site-Data must fail pending subresource fetch events.'); + +</script> +</body> |