diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/service-workers/service-worker/update-bytecheck.https.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/service-workers/service-worker/update-bytecheck.https.html')
-rw-r--r-- | testing/web-platform/tests/service-workers/service-worker/update-bytecheck.https.html | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/testing/web-platform/tests/service-workers/service-worker/update-bytecheck.https.html b/testing/web-platform/tests/service-workers/service-worker/update-bytecheck.https.html new file mode 100644 index 0000000000..3e5a28bb67 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/update-bytecheck.https.html @@ -0,0 +1,92 @@ +<!doctype html> +<meta charset=utf-8> +<title></title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="resources/testharness-helpers.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="resources/test-helpers.sub.js"></script> +<script src="/common/get-host-info.sub.js"></script> +<script> +// Tests of updating a service worker. This file contains non-cors cases only. + +/* + * @param string main + * Decide the content of the main script, where 'default' is for constant + * content while 'time' is for time-variant content. + * @param string imported + * Decide the content of the imported script, where 'default' is for constant + * content while 'time' is for time-variant content. + */ +const settings = [{main: 'default', imported: 'default'}, + {main: 'default', imported: 'time' }, + {main: 'time', imported: 'default'}, + {main: 'time', imported: 'time' }]; + +const host_info = get_host_info(); +settings.forEach(({main, imported}) => { + promise_test(async (t) => { + // Empty path results in the same origin imported scripts. + const path = ''; + const script = 'resources/bytecheck-worker.py' + + '?main=' + main + + '&imported=' + imported + + '&path=' + path + + '&type=classic'; + const scope = 'resources/blank.html'; + + // Register a service worker. + const swr = await service_worker_unregister_and_register(t, script, scope); + t.add_cleanup(() => swr.unregister()); + const sw = await wait_for_update(t, swr); + await wait_for_state(t, sw, 'activated'); + assert_array_equals([swr.active, swr.waiting, swr.installing], + [sw, null, null]); + + // Update the service worker registration. + await swr.update(); + + // If there should be a new service worker. + if (main === 'time' || imported === 'time') { + return wait_for_update(t, swr); + } + // Otherwise, make sure there is no newly created service worker. + assert_array_equals([swr.active, swr.waiting, swr.installing], + [sw, null, null]); + }, `Test(main: ${main}, imported: ${imported})`); +}); + +settings.forEach(({main, imported}) => { + promise_test(async (t) => { + // Empty path results in the same origin imported scripts. + const path = './'; + const script = 'resources/bytecheck-worker.py' + + '?main=' + main + + '&imported=' + imported + + '&path=' + path + + '&type=module'; + const scope = 'resources/blank.html'; + + // Register a module service worker. + const swr = await service_worker_unregister_and_register(t, script, scope, + {type: 'module'}); + + t.add_cleanup(() => swr.unregister()); + const sw = await wait_for_update(t, swr); + await wait_for_state(t, sw, 'activated'); + assert_array_equals([swr.active, swr.waiting, swr.installing], + [sw, null, null]); + + // Update the service worker registration. + await swr.update(); + + // If there should be a new service worker. + if (main === 'time' || imported === 'time') { + return wait_for_update(t, swr); + } + // Otherwise, make sure there is no newly created service worker. + assert_array_equals([swr.active, swr.waiting, swr.installing], + [sw, null, null]); + }, `Test module script(main: ${main}, imported: ${imported})`); +}); +</script> |