diff --git a/testing/marionette/client/marionette/tests/unit/test_cookies.py b/testing/marionette/client/marionette/tests/unit/test_cookies.py index 647865d849ca..13bc5090b4e2 100644 --- a/testing/marionette/client/marionette/tests/unit/test_cookies.py +++ b/testing/marionette/client/marionette/tests/unit/test_cookies.py @@ -88,3 +88,11 @@ class CookieTest(MarionetteTestCase): self.assertFalse(cookie1["name"] == cookies[0]["name"], msg=str(cookies)) self.assertEquals(cookie2["name"] , cookies[0]["name"], msg=str(cookies)) + + def test_we_get_required_elements_when_available(self): + self.marionette.add_cookie(self.COOKIE_A) + cookies = self.marionette.get_cookies() + + self.assertIn("name", cookies[0], 'name not available') + self.assertIn("value", cookies[0], 'value not available') + self.assertIn("httpOnly", cookies[0], 'httpOnly not available') diff --git a/testing/marionette/driver.js b/testing/marionette/driver.js index e82d882f5acd..f29bdd301fac 100644 --- a/testing/marionette/driver.js +++ b/testing/marionette/driver.js @@ -20,7 +20,7 @@ let {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); this.DevToolsUtils = devtools.require("devtools/toolkit/DevToolsUtils.js"); XPCOMUtils.defineLazyServiceGetter( - this, "cookieManager", "@mozilla.org/cookiemanager;1", "nsICookieManager"); + this, "cookieManager", "@mozilla.org/cookiemanager;1", "nsICookieManager2"); Cu.import("chrome://marionette/content/actions.js"); Cu.import("chrome://marionette/content/elements.js"); @@ -2862,9 +2862,9 @@ GeckoDriver.prototype.receiveMessage = function(message) { let isForCurrentPath = path => currentPath.indexOf(path) != -1; let results = []; - let en = cookieManager.enumerator; + let en = cookieManager.getCookiesFromHost(host); while (en.hasMoreElements()) { - let cookie = en.getNext().QueryInterface(Ci.nsICookie); + let cookie = en.getNext().QueryInterface(Ci.nsICookie2); // take the hostname and progressively shorten let hostname = host; do { @@ -2876,7 +2876,8 @@ GeckoDriver.prototype.receiveMessage = function(message) { "path": cookie.path, "host": cookie.host, "secure": cookie.isSecure, - "expiry": cookie.expires + "expiry": cookie.expires, + "httpOnly": cookie.isHttpOnly }); break; } @@ -2893,7 +2894,7 @@ GeckoDriver.prototype.receiveMessage = function(message) { cookieToAdd.name, cookieToAdd.value, cookieToAdd.secure, - false, + cookieToAdd.httpOnly, false, cookieToAdd.expiry); return true; diff --git a/testing/marionette/listener.js b/testing/marionette/listener.js index fac5f8a70faa..992211ae4acb 100644 --- a/testing/marionette/listener.js +++ b/testing/marionette/listener.js @@ -1807,6 +1807,7 @@ function getCookies(msg) { 'path': cookie.path, 'domain': cookie.host, 'secure': cookie.isSecure, + 'httpOnly': cookie.httpOnly, 'expiry': expires }); }