summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/cookie-store/serviceworker_cookieStore_subscriptions_reset.https.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/cookie-store/serviceworker_cookieStore_subscriptions_reset.https.html
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/cookie-store/serviceworker_cookieStore_subscriptions_reset.https.html')
-rw-r--r--testing/web-platform/tests/cookie-store/serviceworker_cookieStore_subscriptions_reset.https.html55
1 files changed, 55 insertions, 0 deletions
diff --git a/testing/web-platform/tests/cookie-store/serviceworker_cookieStore_subscriptions_reset.https.html b/testing/web-platform/tests/cookie-store/serviceworker_cookieStore_subscriptions_reset.https.html
new file mode 100644
index 0000000000..a1124e9220
--- /dev/null
+++ b/testing/web-platform/tests/cookie-store/serviceworker_cookieStore_subscriptions_reset.https.html
@@ -0,0 +1,55 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>Cookie Store API: reset cookie change subscription list</title>
+<link rel="help" href="https://github.com/WICG/cookie-store">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/service-workers/service-worker/resources/test-helpers.sub.js">
+</script>
+<script src='resources/helpers.js'></script>
+<script>
+'use strict';
+
+promise_test(async t => {
+ const registration = await service_worker_unregister_and_register(
+ t, 'resources/empty_sw.js', 'resources/does/not/exist');
+ t.add_cleanup(() => registration.unregister());
+ await wait_for_state(t, registration.installing, 'activated');
+ await registration.cookies.subscribe(
+ [{ name: 'cookie-name' }]);
+ const original_subscriptions = await registration.cookies.getSubscriptions();
+ assert_equals(original_subscriptions.length, 1,
+ 'subscription count before unregistration');
+
+ await registration.unregister();
+
+ const new_registration = await navigator.serviceWorker.register(
+ 'resources/empty_sw.js', { scope: 'resources/does/not/exist' });
+ t.add_cleanup(() => new_registration.unregister());
+ await wait_for_state(t, new_registration.installing, 'activated');
+
+ const new_subscriptions = await new_registration.cookies.getSubscriptions();
+ assert_equals(new_subscriptions.length, 0,
+ 'subscription count after unregistration');
+}, 'cookiechange subscriptions reset across service worker unregistrations');
+
+promise_test(async t => {
+ const registration = await service_worker_unregister_and_register(
+ t, 'resources/always_changing_sw.sub.js', 'resources/does/not/exist');
+ t.add_cleanup(() => registration.unregister());
+ await wait_for_state(t, registration.installing, 'activated');
+ await registration.cookies.subscribe(
+ [{ name: 'cookie-name' }]);
+ const original_subscriptions = await registration.cookies.getSubscriptions();
+ assert_equals(original_subscriptions.length, 1,
+ 'subscription count before update');
+
+ await registration.update();
+ const worker = await wait_for_update(t, registration);
+ await wait_for_state(t, worker, 'activated');
+
+ const update_subscriptions = await registration.cookies.getSubscriptions();
+ assert_equals(update_subscriptions.length, 1,
+ 'subscription count after update');
+}, 'cookiechange subscriptions persist across service worker updates');
+</script>