Bug 1456799 - [wdspec] Use wdclient to get a named cookie in add cookie tests. r=maja_zf
authorHenrik Skupin <mail@hskupin.info>
Wed, 25 Apr 2018 17:59:09 +0200
changeset 471657 c07b1375c1c4c9337ff81ab53757b5130f558a14
parent 471656 9d55d0203a2b08980505d172982f516726e009bd
child 471658 a63caceffcee5cbf5f6a3043b70f142bbbeab12c
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf
bugs1456799
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1456799 - [wdspec] Use wdclient to get a named cookie in add cookie tests. r=maja_zf MozReview-Commit-ID: 7PP4mPyxk6N
testing/web-platform/tests/webdriver/tests/cookies/add_cookie.py
--- a/testing/web-platform/tests/webdriver/tests/cookies/add_cookie.py
+++ b/testing/web-platform/tests/webdriver/tests/cookies/add_cookie.py
@@ -1,11 +1,12 @@
+from datetime import datetime, timedelta
+
 from tests.support.asserts import assert_success
 from tests.support.fixtures import clear_all_cookies
-from datetime import datetime, timedelta
 
 
 def add_cookie(session, cookie):
     return session.transport.send(
         "POST", "session/{session_id}/cookie".format(**vars(session)),
         {"cookie": cookie})
 
 
@@ -20,30 +21,23 @@ def test_add_domain_cookie(session, url,
     }
 
     session.url = url("/common/blank.html")
     clear_all_cookies(session)
 
     result = add_cookie(session, new_cookie)
     assert_success(result)
 
-    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]
+    cookie = session.cookies("hello")
+    assert "domain" in cookie
+    assert isinstance(cookie["domain"], basestring)
     assert "name" in cookie
     assert isinstance(cookie["name"], basestring)
     assert "value" in cookie
     assert isinstance(cookie["value"], basestring)
-    assert "domain" in cookie
-    assert isinstance(cookie["domain"], basestring)
 
     assert cookie["name"] == "hello"
     assert cookie["value"] == "world"
     assert cookie["domain"] == server_config["browser_host"] or \
         cookie["domain"] == ".%s" % server_config["browser_host"]
 
 
 def test_add_cookie_for_ip(session, url, server_config, configuration):
@@ -57,24 +51,17 @@ def test_add_cookie_for_ip(session, url,
     }
 
     session.url = "http://127.0.0.1:%s/common/blank.html" % (server_config["ports"]["http"][0])
     clear_all_cookies(session)
 
     result = add_cookie(session, new_cookie)
     assert_success(result)
 
-    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]
+    cookie = session.cookies("hello")
     assert "name" in cookie
     assert isinstance(cookie["name"], basestring)
     assert "value" in cookie
     assert isinstance(cookie["value"], basestring)
     assert "domain" in cookie
     assert isinstance(cookie["domain"], basestring)
 
     assert cookie["name"] == "hello"
@@ -93,24 +80,17 @@ def test_add_non_session_cookie(session,
     }
 
     session.url = url("/common/blank.html")
     clear_all_cookies(session)
 
     result = add_cookie(session, new_cookie)
     assert_success(result)
 
-    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]
+    cookie = session.cookies("hello")
     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)
 
     assert cookie["name"] == "hello"
@@ -125,24 +105,17 @@ def test_add_session_cookie(session, url
     }
 
     session.url = url("/common/blank.html")
     clear_all_cookies(session)
 
     result = add_cookie(session, new_cookie)
     assert_success(result)
 
-    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]
+    cookie = session.cookies("hello")
     assert "name" in cookie
     assert isinstance(cookie["name"], basestring)
     assert "value" in cookie
     assert isinstance(cookie["value"], basestring)
     if "expiry" in cookie:
         assert cookie.get("expiry") is None
 
     assert cookie["name"] == "hello"
@@ -157,24 +130,17 @@ def test_add_session_cookie_with_leading
     }
 
     session.url = url("/common/blank.html")
     clear_all_cookies(session)
 
     result = add_cookie(session, new_cookie)
     assert_success(result)
 
-    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]
+    cookie = session.cookies("hello")
     assert "name" in cookie
     assert isinstance(cookie["name"], basestring)
     assert "value" in cookie
     assert isinstance(cookie["value"], basestring)
     assert "domain" in cookie
     assert isinstance(cookie["domain"], basestring)
 
     assert cookie["name"] == "hello"