diff options
Diffstat (limited to 'testing/web-platform/mozilla/tests/webdriver/bidi/storage/get_cookies')
-rw-r--r-- | testing/web-platform/mozilla/tests/webdriver/bidi/storage/get_cookies/partition.py | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/testing/web-platform/mozilla/tests/webdriver/bidi/storage/get_cookies/partition.py b/testing/web-platform/mozilla/tests/webdriver/bidi/storage/get_cookies/partition.py index b037c30038..5503f13224 100644 --- a/testing/web-platform/mozilla/tests/webdriver/bidi/storage/get_cookies/partition.py +++ b/testing/web-platform/mozilla/tests/webdriver/bidi/storage/get_cookies/partition.py @@ -59,18 +59,22 @@ async def test_partition_context( ) recursive_compare( - {"cookies": [], "partitionKey": {"sourceOrigin": source_origin_2}}, cookies + { + "cookies": [], + "partitionKey": {"sourceOrigin": source_origin_2, "userContext": "default"}, + }, + cookies, ) -@pytest.mark.parametrize("domain", ["", "alt"], ids=["same_origin", "cross_origin"]) -async def test_partition_context_iframe( - bidi_session, new_tab, inline, domain_value, domain, add_cookie +# Because of Dynamic First-Party Isolation, adding the cookie with `document.cookie` +# works only with same-origin iframes. +async def test_partition_context_same_origin_iframe( + bidi_session, new_tab, inline, domain_value, add_cookie ): - iframe_url = inline("<div id='in-iframe'>foo</div>", domain=domain) - source_origin_for_iframe = get_origin_from_url(iframe_url) + iframe_url = inline("<div id='in-iframe'>foo</div>") + source_origin = get_origin_from_url(iframe_url) page_url = inline(f"<iframe src='{iframe_url}'></iframe>") - source_origin_for_page = get_origin_from_url(page_url) await bidi_session.browsing_context.navigate( context=new_tab["context"], url=page_url, wait="complete" ) @@ -89,7 +93,7 @@ async def test_partition_context_iframe( expected_cookies = [ { - "domain": domain_value(domain=domain), + "domain": domain_value(), "httpOnly": False, "name": cookie_name, "path": "/webdriver/tests/support", @@ -99,10 +103,11 @@ async def test_partition_context_iframe( "value": {"type": "string", "value": cookie_value}, } ] + recursive_compare( { "cookies": expected_cookies, - "partitionKey": {"sourceOrigin": source_origin_for_iframe}, + "partitionKey": {"sourceOrigin": source_origin}, }, cookies, ) @@ -110,22 +115,16 @@ async def test_partition_context_iframe( cookies = await bidi_session.storage.get_cookies( partition=BrowsingContextPartitionDescriptor(new_tab["context"]) ) - # When the iframe is on the different domain we can verify that top context has no iframe cookie. - if domain == "alt": - recursive_compare( - { - "cookies": [], - "partitionKey": {"sourceOrigin": source_origin_for_page}, - }, - cookies, - ) - else: - # When the iframe is on the same domain, since the browsing context partition is defined by user context and origin, - # which will be the same for the page, we get the same cookies as for the iframe - recursive_compare( - { - "cookies": expected_cookies, - "partitionKey": {"sourceOrigin": source_origin_for_page}, + + # When the iframe is on the same domain, since the browsing context partition is defined by user context and origin, + # which will be the same for the page, we get the same cookies as for the iframe. + recursive_compare( + { + "cookies": expected_cookies, + "partitionKey": { + "sourceOrigin": source_origin, + "userContext": "default", }, - cookies, - ) + }, + cookies, + ) |