RESOLVED FIXED 182293
Web Automation: cookies returned by automation should have expiry time in seconds
https://bugs.webkit.org/show_bug.cgi?id=182293
Summary Web Automation: cookies returned by automation should have expiry time in sec...
Carlos Garcia Campos
Reported 2018-01-30 08:18:08 PST
When creating a WebCore::Cookie from a WebDriver object we convert the given expiry time to milliseconds, but when creating a WebDriver object from a WebCore::Cookie we are keeping the milliseconds. We should convert to seconds for consistency, so that the WebDriver always handles seconds. This fixes imported/w3c/webdriver/tests/cookies/get_named_cookie.py::test_get_named_cookie ___________________________________________________________________________________ test_get_named_cookie ____________________________________________________________________________________ session = <webdriver.client.Session object at 0x7fa1cc7a5550>, url = <function url at 0x7fa1cc80ea28> def test_get_named_cookie(session, url): session.url = url("/common/blank.html") clear_all_cookies(session) # same formatting as Date.toUTCString() in javascript utc_string_format = "%a, %d %b %Y %H:%M:%S" a_year_from_now = (datetime.utcnow() + timedelta(days=365)).strftime(utc_string_format) session.execute_script("document.cookie = 'foo=bar;expires=%s'" % a_year_from_now) result = session.transport.send("GET", "session/%s/cookie" % session.session_id) assert result.status == 200 assert "value" in result.body assert isinstance(result.body["value"], list) assert len(result.body["value"]) == 1 assert isinstance(result.body["value"][0], dict) cookie = result.body["value"][0] assert "name" in cookie assert isinstance(cookie["name"], basestring) assert "value" in cookie assert isinstance(cookie["value"], basestring) assert "expiry" in cookie assert isinstance(cookie["expiry"], (int, long)) assert cookie["name"] == "foo" assert cookie["value"] == "bar" # convert from seconds since epoch > assert datetime.utcfromtimestamp(cookie["expiry"]).strftime(utc_string_format) == a_year_from_now E AssertionError: assert 'Thu, 13 Jun 1918 11:59:04' == 'Wed, 30 Jan 2019 13:52:05' E - Thu, 13 Jun 1918 11:59:04 E + Wed, 30 Jan 2019 13:52:05 a_year_from_now = 'Wed, 30 Jan 2019 13:52:05' cookie = {'domain': 'localhost', 'expiry': -1626868856, 'httpOnly': False, 'name': 'foo', ...} result = <Responsetatus=200 body={"value": [{"domain": "localhost", "name": "foo", "val...expiry": -1626868856, "path": "/common", "httpOnly": false, "secure": false}]}> session = <webdriver.client.Session object at 0x7fa1cc7a5550> url = <function url at 0x7fa1cc80ea28> utc_string_format = '%a, %d %b %Y %H:%M:%S' WebDriverTests/imported/w3c/webdriver/tests/cookies/get_named_cookie.py:62: AssertionError
Attachments
Patch (1.82 KB, patch)
2018-01-30 08:20 PST, Carlos Garcia Campos
bburg: review+
Carlos Garcia Campos
Comment 1 2018-01-30 08:20:14 PST
Blaze Burg
Comment 2 2018-01-30 09:27:41 PST
Comment on attachment 332655 [details] Patch r=me Oops, we did document this as the unit of measure, but messed up: { "name": "expires", "type": "number", "description": "Cookie expiration in seconds since the UNIX epoch." },
Carlos Garcia Campos
Comment 3 2018-01-31 01:09:53 PST
Radar WebKit Bug Importer
Comment 4 2018-01-31 01:10:49 PST
Note You need to log in before you can comment on or make changes to this bug.