Skip to content

Commit

Permalink
Allows None to be set for the sameSite attribute (#9771)
Browse files Browse the repository at this point in the history
* Allows None to be set for the sameSite attribute

* Fixes formatting

Co-authored-by: David Burns <[email protected]>
  • Loading branch information
gpt14 and AutomatedTester authored Sep 8, 2021
1 parent 0101ad4 commit ee61e94
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
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

0 comments on commit ee61e94

Please sign in to comment.