diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cookiemanager.js | 14 | ||||
-rw-r--r-- | lib/main.js | 5 |
2 files changed, 15 insertions, 4 deletions
diff --git a/lib/cookiemanager.js b/lib/cookiemanager.js index 5b9df5c..047b988 100644 --- a/lib/cookiemanager.js +++ b/lib/cookiemanager.js @@ -37,6 +37,18 @@ exports.getHostCookies = function getHostCookies(host) { var cm = Cc["@mozilla.org/cookiemanager;1"]. getService(Ci.nsICookieManager2); - return cm.getCookiesFromHost(host); + var e = cm.getCookiesFromHost(host); + var result = []; + while (e.hasMoreElements()) { + var cookie = e.getNext(); + cookie.QueryInterface(Ci.nsICookie2); + if (cookie.rawHost == host) { + result.push({ + name: cookie.name, + value: cookie.value, + }); + } + } + return result; } diff --git a/lib/main.js b/lib/main.js index 694e3d0..8b4181a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -1040,9 +1040,8 @@ function autoCompleteUser(doc, field, multiple) { var bzCookies = require("cookiemanager").getHostCookies("bugzilla.mozilla.org"); var loginID = null, auth = null; - while (bzCookies.hasMoreElements()) { - var cookie = bzCookies.getNext(); - cookie.QueryInterface(Components.interfaces.nsICookie); + for (var i = 0; i < bzCookies.length; ++i) { + var cookie = bzCookies[i]; switch (cookie.name) { case "Bugzilla_login": loginID = cookie.value; |