Bug 1302697 - Containers and WebExtensions - part 3 - getAllCookieStores, r=kmag

This commit is contained in:
Andrea Marchesini 2016-10-28 10:16:32 +02:00
Родитель 003066e91d
Коммит 0467141ad5
2 изменённых файлов: 25 добавлений и 12 удалений

Просмотреть файл

@ -82,11 +82,28 @@ add_task(function* () {
.then((tabs) => {
browser.test.assertTrue(tabs.length >= 1, "Tab found!");
testTab(data, tabs[0]);
return browser.tabs.remove(tab.id);
return tab;
});
}
})
.then((tab) => {
if (tab) {
return browser.cookies.getAllCookieStores()
.then(stores => {
let store = stores.find(store => store.id === tab.cookieStoreId);
browser.test.assertTrue(!!store, "We have a store for this tab.");
return tab;
});
}
})
.then((tab) => {
if (tab) {
return browser.tabs.remove(tab.id);
}
})
.then(() => {
browser.test.sendMessage("test-done");
}, () => {

Просмотреть файл

@ -416,24 +416,20 @@ extensions.registerSchemaAPI("cookies", "addon_parent", context => {
},
getAllCookieStores: function() {
let defaultTabs = [];
let privateTabs = [];
let data = {};
for (let window of WindowListManager.browserWindows()) {
let tabs = TabManager.for(extension).getTabs(window);
for (let tab of tabs) {
if (tab.incognito) {
privateTabs.push(tab.id);
} else {
defaultTabs.push(tab.id);
if (!(tab.cookieStoreId in data)) {
data[tab.cookieStoreId] = [];
}
data[tab.cookieStoreId].push(tab);
}
}
let result = [];
if (defaultTabs.length > 0) {
result.push({id: DEFAULT_STORE, tabIds: defaultTabs});
}
if (privateTabs.length > 0) {
result.push({id: PRIVATE_STORE, tabIds: privateTabs});
for (let key in data) {
result.push({id: key, tabIds: data[key], incognito: key == PRIVATE_STORE});
}
return Promise.resolve(result);
},