commit be218488315daa9307a6c3f83b8b41968dc8f638
parent 50c4de911c377283c861efd035067bd5e313e6bc
Author: Henrik Skupin <mail@hskupin.info>
Date: Tue, 16 Dec 2025 12:03:48 +0000
Bug 1851788 - [wdspec] Add tests for cookie methods not supporting chrome browsing contexts. r=jdescottes
Differential Revision: https://phabricator.services.mozilla.com/D275813
Diffstat:
3 files changed, 70 insertions(+), 0 deletions(-)
diff --git a/testing/web-platform/mozilla/tests/webdriver/bidi/storage/delete_cookies/chrome.py b/testing/web-platform/mozilla/tests/webdriver/bidi/storage/delete_cookies/chrome.py
@@ -0,0 +1,19 @@
+import pytest
+from webdriver.bidi import error
+from webdriver.bidi.modules.storage import BrowsingContextPartitionDescriptor
+
+pytestmark = pytest.mark.asyncio
+
+
+@pytest.mark.allow_system_access
+async def test_chrome_browsing_context_not_supported(bidi_session):
+ # Retrieve the chrome browsing context for the open browser window
+ parent_contexts = await bidi_session.browsing_context.get_tree(
+ max_depth=0, _extension_params={"moz:scope": "chrome"}
+ )
+
+ assert parent_contexts[0]["moz:scope"] == "chrome"
+
+ partition = BrowsingContextPartitionDescriptor(parent_contexts[0]["context"])
+ with pytest.raises(error.UnsupportedOperationException):
+ await bidi_session.storage.delete_cookies(partition=partition)
diff --git a/testing/web-platform/mozilla/tests/webdriver/bidi/storage/get_cookies/chrome.py b/testing/web-platform/mozilla/tests/webdriver/bidi/storage/get_cookies/chrome.py
@@ -0,0 +1,19 @@
+import pytest
+from webdriver.bidi import error
+from webdriver.bidi.modules.storage import BrowsingContextPartitionDescriptor
+
+pytestmark = pytest.mark.asyncio
+
+
+@pytest.mark.allow_system_access
+async def test_chrome_browsing_context_not_supported(bidi_session):
+ # Retrieve the chrome browsing context for the open browser window
+ parent_contexts = await bidi_session.browsing_context.get_tree(
+ max_depth=0, _extension_params={"moz:scope": "chrome"}
+ )
+
+ assert parent_contexts[0]["moz:scope"] == "chrome"
+
+ partition = BrowsingContextPartitionDescriptor(parent_contexts[0]["context"])
+ with pytest.raises(error.UnsupportedOperationException):
+ await bidi_session.storage.get_cookies(partition=partition)
diff --git a/testing/web-platform/mozilla/tests/webdriver/bidi/storage/set_cookie/chrome.py b/testing/web-platform/mozilla/tests/webdriver/bidi/storage/set_cookie/chrome.py
@@ -0,0 +1,32 @@
+import pytest
+from webdriver.bidi import error
+from webdriver.bidi.modules.network import NetworkStringValue
+from webdriver.bidi.modules.storage import (
+ BrowsingContextPartitionDescriptor,
+ PartialCookie,
+)
+
+pytestmark = pytest.mark.asyncio
+
+
+@pytest.mark.allow_system_access
+async def test_chrome_browsing_context_not_supported(bidi_session):
+ # Retrieve the chrome browsing context for the open browser window
+ parent_contexts = await bidi_session.browsing_context.get_tree(
+ max_depth=0, _extension_params={"moz:scope": "chrome"}
+ )
+
+ assert parent_contexts[0]["moz:scope"] == "chrome"
+
+ partition = BrowsingContextPartitionDescriptor(parent_contexts[0]["context"])
+ with pytest.raises(error.UnsupportedOperationException):
+ await bidi_session.storage.set_cookie(
+ cookie=PartialCookie(
+ domain="example.org",
+ name="foo",
+ value=NetworkStringValue("bar"),
+ same_site="none",
+ secure=True,
+ ),
+ partition=partition,
+ )