Bug 1315872: Refactor browser_ext_tabs_cookieStoreId. r=aswan

MozReview-Commit-ID: J4diktOFIQR

--HG--
extra : rebase_source : 56de8d0b34022ec82f6550b9cfcb34bb870e38ab
extra : histedit_source : c0ae98a25ed447226e44bc3c18700850fe70865c
This commit is contained in:
Kris Maglione 2016-11-07 22:08:24 -08:00
Родитель aa7573eedb
Коммит 2be53ae148
1 изменённых файлов: 33 добавлений и 29 удалений

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

@ -45,15 +45,17 @@ add_task(function* () {
async function runTest(data) {
try {
// Tab Creation
let tab = await browser.tabs.create({
windowId: data.privateTab ? this.privateWindowId : this.defaultWindowId,
cookieStoreId: data.cookieStoreId,
}).then((tab) => {
// Tests for tab creation
testTab(data, tab);
return tab;
}, (error) => {
let tab;
try {
tab = await browser.tabs.create({
windowId: data.privateTab ? this.privateWindowId : this.defaultWindowId,
cookieStoreId: data.cookieStoreId,
});
browser.test.assertTrue(!data.failure, "we want a success");
} catch (error) {
browser.test.assertTrue(!!data.failure, "we want a failure");
if (data.failure == "illegal") {
browser.test.assertTrue(/Illegal cookieStoreId/.test(error.message),
"runtime.lastError should report the expected error message");
@ -72,29 +74,31 @@ add_task(function* () {
browser.test.fail("The test is broken");
}
return null;
});
if (tab) {
{
// Tests for tab querying
let [tab] = await browser.tabs.query({
windowId: data.privateTab ? this.privateWindowId : this.defaultWindowId,
cookieStoreId: data.cookieStoreId,
});
browser.test.assertTrue(tab != undefined, "Tab found!");
testTab(data, tab);
}
let stores = await browser.cookies.getAllCookieStores();
let store = stores.find(store => store.id === tab.cookieStoreId);
browser.test.assertTrue(!!store, "We have a store for this tab.");
await browser.tabs.remove(tab.id);
browser.test.sendMessage("test-done");
return;
}
// Tests for tab creation
testTab(data, tab);
{
// Tests for tab querying
let [tab] = await browser.tabs.query({
windowId: data.privateTab ? this.privateWindowId : this.defaultWindowId,
cookieStoreId: data.cookieStoreId,
});
browser.test.assertTrue(tab != undefined, "Tab found!");
testTab(data, tab);
}
let stores = await browser.cookies.getAllCookieStores();
let store = stores.find(store => store.id === tab.cookieStoreId);
browser.test.assertTrue(!!store, "We have a store for this tab.");
await browser.tabs.remove(tab.id);
browser.test.sendMessage("test-done");
} catch (e) {
browser.test.fail("An exception has been thrown");