Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows None to be set for the sameSite attribute #9771

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion py/selenium/webdriver/remote/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@ def add_cookie(self, cookie_dict) -> None:

"""
if 'sameSite' in cookie_dict:
assert cookie_dict['sameSite'] in ['Strict', 'Lax']
assert cookie_dict['sameSite'] in ['Strict', 'Lax', 'None']
self.execute(Command.ADD_COOKIE, {'cookie': cookie_dict})
else:
self.execute(Command.ADD_COOKIE, {'cookie': cookie_dict})
Expand Down
21 changes: 21 additions & 0 deletions py/test/selenium/webdriver/common/cookie_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ def same_site_cookie_lax(webserver):
return same_site_cookie_lax


@pytest.fixture
def same_site_cookie_none(webserver):
same_site_cookie_none = {
'name': 'foo',
'value': 'bar',
'path': '/',
'domain': webserver.host,
'sameSite': 'None',
'secure': True}
return same_site_cookie_none


@pytest.fixture(autouse=True)
def pages(request, driver, pages):
pages.load('simpleTest.html')
Expand Down Expand Up @@ -88,6 +100,15 @@ def testAddCookieSameSiteLax(same_site_cookie_lax, driver):
assert 'sameSite' in returned and returned['sameSite'] == 'Lax'


@pytest.mark.xfail_firefox(reason='sameSite cookie attribute not implemented')
@pytest.mark.xfail_remote(reason='sameSite cookie attribute not implemented')
@pytest.mark.xfail_safari
def testAddCookieSameSiteNone(same_site_cookie_none, driver):
driver.add_cookie(same_site_cookie_none)
# Note that insecure sites (http:) can't set cookies with the Secure directive.
# driver.get_cookie would return None


@pytest.mark.xfail_ie
@pytest.mark.xfail_safari
def testAddingACookieThatExpiredInThePast(cookie, driver):
Expand Down