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) { async function runTest(data) {
try { try {
// Tab Creation // Tab Creation
let tab = await browser.tabs.create({ let tab;
windowId: data.privateTab ? this.privateWindowId : this.defaultWindowId, try {
cookieStoreId: data.cookieStoreId, tab = await browser.tabs.create({
}).then((tab) => { windowId: data.privateTab ? this.privateWindowId : this.defaultWindowId,
// Tests for tab creation cookieStoreId: data.cookieStoreId,
testTab(data, tab); });
return tab;
}, (error) => { browser.test.assertTrue(!data.failure, "we want a success");
} catch (error) {
browser.test.assertTrue(!!data.failure, "we want a failure"); browser.test.assertTrue(!!data.failure, "we want a failure");
if (data.failure == "illegal") { if (data.failure == "illegal") {
browser.test.assertTrue(/Illegal cookieStoreId/.test(error.message), browser.test.assertTrue(/Illegal cookieStoreId/.test(error.message),
"runtime.lastError should report the expected error message"); "runtime.lastError should report the expected error message");
@ -72,29 +74,31 @@ add_task(function* () {
browser.test.fail("The test is broken"); browser.test.fail("The test is broken");
} }
return null; browser.test.sendMessage("test-done");
}); return;
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);
} }
// 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"); browser.test.sendMessage("test-done");
} catch (e) { } catch (e) {
browser.test.fail("An exception has been thrown"); browser.test.fail("An exception has been thrown");