blob: d355055d08aef8f570c82f1a2473109f3a5b1ff8 [file] [log] [blame]
self.GLOBAL = {
isWindow: function() { return false; },
isWorker: function() { return true; },
};
importScripts("/resources/testharness.js");
self.addEventListener('install', (event) => {
event.waitUntil((async () => {
await cookieStore.subscribeToChanges([]);
})());
});
// Workaround because add_cleanup doesn't support async functions yet.
// See https://github.com/w3c/web-platform-tests/issues/6075
async function async_cleanup(cleanup_function) {
try {
await cleanup_function();
} catch (e) {
// Errors in cleanup functions shouldn't result in test failures.
}
}
// Resolves when the service worker receives the 'activate' event.
const kServiceWorkerActivatedPromise = new Promise(resolve => {
self.addEventListener('activate', event => { resolve(); });
});
promise_test(async testCase => {
await kServiceWorkerActivatedPromise;
const subscriptions = await cookieStore.getChangeSubscriptions();
assert_equals(subscriptions.length, 0);
}, 'getChangeSubscriptions returns an empty array when there are no subscriptions');
done();