gecko-dev/dom/html/test/file_cookiemanager.js
Kris Maglione 3a5c05e76f Bug 1484496: Part 5e - Convert remaining nsISimpleEnumerator users to use JS iteration. r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D3733

--HG--
extra : rebase_source : c0fac176d7b3d840c4dbb14f8d95ccfc7f83a5a8
extra : histedit_source : a92c40117d0808a3ad68c972f622a7a42c9ae8ba
2018-08-18 18:13:14 -07:00

18 lines
526 B
JavaScript

addMessageListener("getCookieFromManager", ({ host, path }) => {
let cm = Cc["@mozilla.org/cookiemanager;1"]
.getService(Ci.nsICookieManager);
let values = [];
path = path.substring(0, path.lastIndexOf("/") + 1);
for (let cookie of cm.enumerator) {
if (!cookie) {
break;
}
if (host != cookie.host || path != cookie.path) {
continue;
}
values.push(cookie.name + "=" + cookie.value);
}
sendAsyncMessage("getCookieFromManager:return", { cookie: values.join("; ") });
});