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/storage-access-api/requestStorageAccess-web-socket.tentative.sub.https.window.js | |
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/storage-access-api/requestStorageAccess-web-socket.tentative.sub.https.window.js')
-rw-r--r-- | testing/web-platform/tests/storage-access-api/requestStorageAccess-web-socket.tentative.sub.https.window.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/testing/web-platform/tests/storage-access-api/requestStorageAccess-web-socket.tentative.sub.https.window.js b/testing/web-platform/tests/storage-access-api/requestStorageAccess-web-socket.tentative.sub.https.window.js new file mode 100644 index 0000000000..bc323bd95a --- /dev/null +++ b/testing/web-platform/tests/storage-access-api/requestStorageAccess-web-socket.tentative.sub.https.window.js @@ -0,0 +1,51 @@ +// META: script=helpers.js +// META: script=/cookies/resources/cookie-helper.sub.js +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.js + +'use strict'; + +const altRoot = "https://{{hosts[alt][]}}:{{ports[https][0]}}"; +const altRootWss = "wss://{{hosts[alt][]}}:{{ports[wss][0]}}"; + +const responderPath = "/storage-access-api/resources/script-with-cookie-header.py?script=embedded_responder.js"; +const altRootResponder = `${altRoot}${responderPath}`; + +async function SetUpResponderFrame(t, url) { + const frame = await CreateFrame(url); + + await SetPermissionInFrame(frame, [{ name: 'storage-access' }, 'granted']); + t.add_cleanup(async () => { + await test_driver.delete_all_cookies(); + await SetPermissionInFrame(frame, [{ name: 'storage-access' }, 'prompt']); + await MaybeSetStorageAccess("*", "*", "allowed"); + }); + + return frame; +} + +promise_test(async (t) => { + await MaybeSetStorageAccess("*", "*", "blocked"); + await SetFirstPartyCookieAndUnsetStorageAccessPermission(altRoot); + + const frame = await SetUpResponderFrame(t, altRootResponder); + + assert_true(await RequestStorageAccessInFrame(frame), "requestStorageAccess resolves without requiring a gesture."); + assert_true(await FrameHasStorageAccess(frame), "frame has storage access after request."); + assert_true(await HasUnpartitionedCookie(frame), "frame has access to cookies after request."); + + assert_true(cookieStringHasCookie("cookie", "unpartitioned", + await ReadCookiesFromWebSocketConnection(frame, altRootWss)), + "WebSocket handshake should include unpartitioned cookie"); +}, "WebSocket inherits storage access"); + +promise_test(async (t) => { + + await MaybeSetStorageAccess("*", "*", "blocked"); + await SetFirstPartyCookieAndUnsetStorageAccessPermission(altRoot); + const frame = await SetUpResponderFrame(t, altRootResponder); + + assert_false(cookieStringHasCookie("cookie", "unpartitioned", + await ReadCookiesFromWebSocketConnection(frame, altRootWss)), + "request should not contain cookies"); +}, "WebSocket omits unpartitioned cookies without storage access"); |