Bug 1178468 - Update marionette cookie support to use nsICookie2. r=jgriffin

This allows us to return httpOnly key when doing getCookie and serialising the result

Details in http://w3c.github.io/webdriver/webdriver-spec.html#dfn-serialized-cookie

--HG--
extra : commitid : Fkr0udCIjfm
extra : rebase_source : 7e837a36947e83520eae26c3f41b45dd5c211829
extra : histedit_source : 806d7c8249128b08bc1ad448389bb639e0369c07
This commit is contained in:
David Burns 2015-07-15 23:51:51 +01:00
parent 893918b610
commit df864f9993
3 changed files with 15 additions and 5 deletions

View File

@ -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')

View File

@ -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;

View File

@ -1807,6 +1807,7 @@ function getCookies(msg) {
'path': cookie.path,
'domain': cookie.host,
'secure': cookie.isSecure,
'httpOnly': cookie.httpOnly,
'expiry': expires
});
}