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/fenced-frame/background-sync.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/fenced-frame/background-sync.https.html')
-rw-r--r-- | testing/web-platform/tests/fenced-frame/background-sync.https.html | 218 |
1 files changed, 218 insertions, 0 deletions
diff --git a/testing/web-platform/tests/fenced-frame/background-sync.https.html b/testing/web-platform/tests/fenced-frame/background-sync.https.html new file mode 100644 index 0000000000..72eb44750b --- /dev/null +++ b/testing/web-platform/tests/fenced-frame/background-sync.https.html @@ -0,0 +1,218 @@ +<!DOCTYPE html> +<title>Test fenced frame does not allow to register background sync</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="resources/utils.js"></script> +<script src="/common/get-host-info.sub.js"></script> +<script src="/common/utils.js"></script> +<body> +<script> +const background_sync_register_key = token(); +const fenced_frame_url = 'resources/background-sync-inner.https.html'; +const fenced_frame_url_for_service_worker_test = + 'resources/background-sync-sw-inner.https.html'; + +const generateFencedFrameUrl = (params, is_worker_test = false) => { + const searchParams = new URLSearchParams(params); + const frame_url = is_worker_test ? + fenced_frame_url_for_service_worker_test : fenced_frame_url; + + return generateURL(`${frame_url}?${searchParams.toString()}`, + [background_sync_register_key]); +}; + +async function background_sync_test(url, expected_text, message) { + attachFencedFrame(url) + + // Get the result for the top-level fenced frame. + const fenced_frame_result = + await nextValueFromServer(background_sync_register_key); + assert_equals(fenced_frame_result, expected_text, message); +}; + +const background_sync_message = + "Background Sync is not allowed in fenced frames."; +const periodic_background_sync_message = + "Periodic Background Sync is not allowed in fenced frames."; + +promise_test(async (t) => { + const method = 'register'; + const frame_url = generateFencedFrameUrl({method}); + const expected_message = "Failed to execute 'register' on 'SyncManager': " + + background_sync_message; + await background_sync_test( + frame_url, + expected_message, + 'register() is disallowed inside a same-origin fenced frame'); + + const cross_origin_frame_url = getRemoteOriginURL(frame_url); + await background_sync_test( + cross_origin_frame_url, + expected_message, + 'register() is disallowed inside a cross-origin fenced frame'); +}, 'background sync register'); + +promise_test(async (t) => { + const method = 'getTags'; + const frame_url = generateFencedFrameUrl({method}); + const expected_message = background_sync_message; + await background_sync_test( + frame_url, + expected_message, + 'getTags() is disallowed inside a same-origin fenced frame'); + + const cross_origin_frame_url = getRemoteOriginURL(frame_url); + await background_sync_test( + cross_origin_frame_url, + expected_message, + 'getTags() is disallowed inside a cross-origin fenced frame'); +}, 'background sync getTags'); + +promise_test(async (t) => { + const method = 'register'; + const frame_url = generateFencedFrameUrl({method}, true); + const expected_message = "Failed to execute 'register' on 'SyncManager': " + + background_sync_message; + await background_sync_test( + frame_url, + expected_message, + 'register() is disallowed inside a same-origin fenced frame'); + const cross_origin_frame_url = getRemoteOriginURL(frame_url); + await background_sync_test( + cross_origin_frame_url, + expected_message, + 'register() is disallowed inside a cross-origin fenced frame'); +}, 'background sync register in service worker'); + +promise_test(async (t) => { + const method = 'getTags'; + const frame_url = generateFencedFrameUrl({method}, true); + const expected_message = background_sync_message; + await background_sync_test( + frame_url, + expected_message, + 'getTags() is disallowed inside a same-origin fenced frame'); + const cross_origin_frame_url = getRemoteOriginURL(frame_url); + await background_sync_test( + cross_origin_frame_url, + expected_message, + 'getTags() is disallowed inside a cross-origin fenced frame'); +}, 'background sync getTags in service worker'); + +promise_test(async (t) => { + const params = { + method: 'register', + periodic: true + }; + const frame_url = generateFencedFrameUrl(params) + const expected_message = "Failed to execute 'register' on " + + "'PeriodicSyncManager': " + periodic_background_sync_message; + await background_sync_test( + frame_url, + expected_message, + 'register() is disallowed inside a same-origin fenced frame'); + + const cross_origin_frame_url = getRemoteOriginURL(frame_url); + await background_sync_test( + cross_origin_frame_url, + expected_message, + 'register() is disallowed inside a cross-origin fenced frame'); +}, 'periodic sync register'); + +promise_test(async (t) => { + const params = { + method: 'getTags', + periodic: true + }; + const frame_url = generateFencedFrameUrl(params) + const expected_message = periodic_background_sync_message; + await background_sync_test( + frame_url, + expected_message, + 'getTags() is disallowed inside a same-origin fenced frame'); + + const cross_origin_frame_url = getRemoteOriginURL(frame_url); + await background_sync_test( + cross_origin_frame_url, + expected_message, + 'getTags() is disallowed inside a cross-origin fenced frame'); +}, 'periodic sync getTags'); + +promise_test(async (t) => { + const params = { + method: 'unregister', + periodic: true + }; + const frame_url = generateFencedFrameUrl(params) + const expected_message = periodic_background_sync_message; + await background_sync_test( + frame_url, + expected_message, + 'unregister() is disallowed inside a same-origin fenced frame'); + + const cross_origin_frame_url = getRemoteOriginURL(frame_url); + await background_sync_test( + cross_origin_frame_url, + expected_message, + 'unregister() is disallowed inside a cross-origin fenced frame'); +}, 'periodic sync unregister'); + +promise_test(async (t) => { + const params = { + method: 'register', + periodic: true + }; + const frame_url = generateFencedFrameUrl(params, true) + const expected_message = "Failed to execute 'register' on " + + "'PeriodicSyncManager': " + periodic_background_sync_message; + await background_sync_test( + frame_url, + expected_message, + 'register() is disallowed inside a same-origin fenced frame'); + + const cross_origin_frame_url = getRemoteOriginURL(frame_url); + await background_sync_test( + cross_origin_frame_url, + expected_message, + 'register() is disallowed inside a cross-origin fenced frame'); +}, 'periodic sync register in service worker'); + +promise_test(async (t) => { + const params = { + method: 'getTags', + periodic: true + }; + const frame_url = generateFencedFrameUrl(params, true) + const expected_message = periodic_background_sync_message; + await background_sync_test( + frame_url, + expected_message, + 'getTags() is disallowed inside a same-origin fenced frame'); + + const cross_origin_frame_url = getRemoteOriginURL(frame_url); + await background_sync_test( + cross_origin_frame_url, + expected_message, + 'getTags() is disallowed inside a cross-origin fenced frame'); +}, 'periodic sync getTags in service worker'); + +promise_test(async (t) => { + const params = { + method: 'unregister', + periodic: true + }; + const frame_url = generateFencedFrameUrl(params, true) + const expected_message = periodic_background_sync_message; + await background_sync_test( + frame_url, + expected_message, + 'unregister() is disallowed inside a same-origin fenced frame'); + + const cross_origin_frame_url = getRemoteOriginURL(frame_url); + await background_sync_test( + cross_origin_frame_url, + expected_message, + 'unregister() is disallowed inside a cross-origin fenced frame'); +}, 'periodic sync unregister in service worker'); +</script> +</body> |