forked from mirrors/gecko-dev
Bug 1884647 - [wdpspec] Add more tests for partitioning. r=webdriver-reviewers,jdescottes
Differential Revision: https://phabricator.services.mozilla.com/D204221
This commit is contained in:
parent
1510b2cfbf
commit
d4c4ee304b
3 changed files with 70 additions and 4 deletions
|
|
@ -1,5 +1,7 @@
|
|||
[partition.py]
|
||||
[test_partition_context]
|
||||
expected: FAIL
|
||||
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1884648
|
||||
disabled:
|
||||
if os == "android": bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1877953
|
||||
|
||||
|
|
|
|||
|
|
@ -134,6 +134,45 @@ async def test_partition_context(
|
|||
assert len(cookies["cookies"]) == 0
|
||||
|
||||
|
||||
async def test_partition_context_with_different_domain(
|
||||
bidi_session, set_cookie, new_tab, test_page, domain_value
|
||||
):
|
||||
await bidi_session.browsing_context.navigate(
|
||||
context=new_tab["context"], url=test_page, wait="complete"
|
||||
)
|
||||
|
||||
# Set cookie on a different domain.
|
||||
cookie_domain = domain_value(domain="alt")
|
||||
cookie_name = "foo"
|
||||
cookie_value = "bar"
|
||||
partition = BrowsingContextPartitionDescriptor(new_tab["context"])
|
||||
await set_cookie(
|
||||
cookie=create_cookie(
|
||||
domain=cookie_domain,
|
||||
name=cookie_name,
|
||||
value=NetworkStringValue(cookie_value),
|
||||
),
|
||||
partition=partition,
|
||||
)
|
||||
|
||||
result = await bidi_session.storage.get_cookies(
|
||||
partition=BrowsingContextPartitionDescriptor(new_tab["context"])
|
||||
)
|
||||
|
||||
assert result["cookies"] == [
|
||||
{
|
||||
"domain": cookie_domain,
|
||||
"httpOnly": False,
|
||||
"name": cookie_name,
|
||||
"path": "/",
|
||||
"sameSite": "none",
|
||||
"secure": True,
|
||||
"size": 6,
|
||||
"value": {"type": "string", "value": cookie_value},
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("domain", ["", "alt"], ids=["same_origin", "cross_origin"])
|
||||
async def test_partition_context_iframe(
|
||||
bidi_session, new_tab, inline, domain_value, domain, set_cookie
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
import pytest
|
||||
from webdriver.bidi.modules.storage import BrowsingContextPartitionDescriptor, StorageKeyPartitionDescriptor
|
||||
from webdriver.bidi.modules.network import NetworkStringValue
|
||||
from webdriver.bidi.modules.script import ContextTarget
|
||||
from webdriver.bidi.modules.storage import (
|
||||
BrowsingContextPartitionDescriptor,
|
||||
StorageKeyPartitionDescriptor,
|
||||
)
|
||||
from .. import assert_cookie_is_set, create_cookie
|
||||
from ... import recursive_compare
|
||||
|
||||
|
|
@ -31,13 +36,33 @@ def assert_set_cookie_result(set_cookie_result, partition):
|
|||
async def test_partition_context(bidi_session, set_cookie, top_context, test_page, domain_value):
|
||||
await bidi_session.browsing_context.navigate(context=top_context["context"], url=test_page, wait="complete")
|
||||
|
||||
cookie_name = "foo"
|
||||
cookie_value = "bar"
|
||||
partition = BrowsingContextPartitionDescriptor(top_context["context"])
|
||||
set_cookie_result = await set_cookie(
|
||||
cookie=create_cookie(domain=domain_value()),
|
||||
partition=partition)
|
||||
cookie=create_cookie(
|
||||
domain=domain_value(),
|
||||
name=cookie_name,
|
||||
value=NetworkStringValue(cookie_value),
|
||||
),
|
||||
partition=partition,
|
||||
)
|
||||
assert_set_cookie_result(set_cookie_result, partition)
|
||||
|
||||
await assert_cookie_is_set(bidi_session, domain=domain_value())
|
||||
await assert_cookie_is_set(
|
||||
bidi_session,
|
||||
domain=domain_value(),
|
||||
name=cookie_name,
|
||||
value=NetworkStringValue(cookie_value)
|
||||
)
|
||||
|
||||
result = await bidi_session.script.evaluate(
|
||||
expression="document.cookie",
|
||||
target=ContextTarget(top_context["context"]),
|
||||
await_promise=True,
|
||||
)
|
||||
|
||||
assert result == {"type": "string", "value": f"{cookie_name}={cookie_value}"}
|
||||
|
||||
|
||||
async def test_partition_context_frame(bidi_session, set_cookie, top_context, test_page, domain_value, inline):
|
||||
|
|
|
|||
Loading…
Reference in a new issue