Merge pull request #155 from bakulf/delete

Comment applied - issue #151
This commit is contained in:
Andrea Marchesini 2017-02-06 17:52:35 +01:00 committed by GitHub
commit 4b3892f38e

View file

@ -236,13 +236,7 @@ const ContainerService = {
return Promise.resolve(null); return Promise.resolve(null);
} }
const browserWin = windowUtils.getMostRecentBrowserWindow(); return this._recentBrowserWindow().then(browserWin => {
// This should not really happen.
if (!browserWin || !browserWin.gBrowser) {
return Promise.resolve(null);
}
browserWin.gBrowser.addTab(); browserWin.gBrowser.addTab();
for (let tab of tabsToClose) { // eslint-disable-line prefer-const for (let tab of tabsToClose) { // eslint-disable-line prefer-const
@ -250,6 +244,18 @@ const ContainerService = {
} }
return Promise.resolve(null); return Promise.resolve(null);
}).catch(() => null);
},
_recentBrowserWindow() {
const browserWin = windowUtils.getMostRecentBrowserWindow();
// This should not really happen.
if (!browserWin || !browserWin.gBrowser) {
return Promise.resolve(null);
}
return Promise.resolve(browserWin);
}, },
// Tabs management // Tabs management
@ -456,14 +462,7 @@ const ContainerService = {
}, },
openTab(args) { openTab(args) {
return new Promise(resolve => { return this._recentBrowserWindow().then(browserWin => {
const browserWin = windowUtils.getMostRecentBrowserWindow();
// This should not really happen.
if (!browserWin || !browserWin.gBrowser) {
return Promise.resolve(false);
}
let userContextId = 0; let userContextId = 0;
if ("userContextId" in args) { if ("userContextId" in args) {
userContextId = args.userContextId; userContextId = args.userContextId;
@ -471,8 +470,8 @@ const ContainerService = {
const tab = browserWin.gBrowser.addTab(args.url || null, { userContextId }); const tab = browserWin.gBrowser.addTab(args.url || null, { userContextId });
browserWin.gBrowser.selectedTab = tab; browserWin.gBrowser.selectedTab = tab;
resolve(true); return true;
}); }).catch(() => false);
}, },
// Identities management // Identities management