Fixed the moving of containers tabs in a separate window
This commit is contained in:
parent
6a9315f295
commit
4ce4e2bf7f
1 changed files with 17 additions and 19 deletions
34
index.js
34
index.js
|
@ -164,15 +164,12 @@ const ContainerService = {
|
||||||
return { title: tab.title, url: tab.url, id: tab.id, active: true };
|
return { title: tab.title, url: tab.url, id: tab.id, active: true };
|
||||||
},
|
},
|
||||||
|
|
||||||
_getTabList(userContextId) {
|
_containerTabIterator(userContextId, cb) {
|
||||||
const list = [];
|
|
||||||
for (let tab of tabs) { // eslint-disable-line prefer-const
|
for (let tab of tabs) { // eslint-disable-line prefer-const
|
||||||
if (userContextId === this._getUserContextIdFromTab(tab)) {
|
if (userContextId === this._getUserContextIdFromTab(tab)) {
|
||||||
list.push(this._createTabObject(tab));
|
cb(tab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Tabs management
|
// Tabs management
|
||||||
|
@ -184,11 +181,7 @@ const ContainerService = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let tab of tabs) { // eslint-disable-line prefer-const
|
this._containerTabIterator(args.userContextId, tab => {
|
||||||
if (args.userContextId !== this._getUserContextIdFromTab(tab)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const object = this._createTabObject(tab);
|
const object = this._createTabObject(tab);
|
||||||
|
|
||||||
// This tab is going to be closed. Let's mark this tabObject as
|
// This tab is going to be closed. Let's mark this tabObject as
|
||||||
|
@ -203,7 +196,7 @@ const ContainerService = {
|
||||||
|
|
||||||
this._identitiesState[args.userContextId].hiddenTabUrls.push(object);
|
this._identitiesState[args.userContextId].hiddenTabUrls.push(object);
|
||||||
tab.close();
|
tab.close();
|
||||||
}
|
});
|
||||||
|
|
||||||
resolve(null);
|
resolve(null);
|
||||||
});
|
});
|
||||||
|
@ -282,7 +275,11 @@ const ContainerService = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const list = this._getTabList(args.userContextId);
|
const list = [];
|
||||||
|
this._containerTabIterator(args.userContextId, tab => {
|
||||||
|
list.push(this._createTabObject(tab));
|
||||||
|
});
|
||||||
|
|
||||||
const promises = [];
|
const promises = [];
|
||||||
|
|
||||||
for (let object of list) { // eslint-disable-line prefer-const
|
for (let object of list) { // eslint-disable-line prefer-const
|
||||||
|
@ -328,7 +325,10 @@ const ContainerService = {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let's create a list of the tabs.
|
// Let's create a list of the tabs.
|
||||||
const list = this._getTabList(args.userContextId);
|
const list = [];
|
||||||
|
this._containerTabIterator(args.userContextId, tab => {
|
||||||
|
list.push(tab);
|
||||||
|
});
|
||||||
|
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
if (list.length === 0) {
|
if (list.length === 0) {
|
||||||
|
@ -344,7 +344,7 @@ const ContainerService = {
|
||||||
// Let's move the tab to the new window.
|
// Let's move the tab to the new window.
|
||||||
for (let tab of list) { // eslint-disable-line prefer-const
|
for (let tab of list) { // eslint-disable-line prefer-const
|
||||||
const newTab = newBrowserWindow.gBrowser.addTab("about:blank");
|
const newTab = newBrowserWindow.gBrowser.addTab("about:blank");
|
||||||
newBrowserWindow.gBrowser.swapBrowsersAndCloseOther(newTab, tab);
|
newBrowserWindow.gBrowser.swapBrowsersAndCloseOther(newTab, viewFor(tab));
|
||||||
// swapBrowsersAndCloseOther is an internal method of gBrowser
|
// swapBrowsersAndCloseOther is an internal method of gBrowser
|
||||||
// an it's not supported by addon SDK. This means that we
|
// an it's not supported by addon SDK. This means that we
|
||||||
// don't receive an 'open' event, but only the 'close' one.
|
// don't receive an 'open' event, but only the 'close' one.
|
||||||
|
@ -454,11 +454,9 @@ const ContainerService = {
|
||||||
return Promise.reject("removeIdentity must be called with userContextId argument.");
|
return Promise.reject("removeIdentity must be called with userContextId argument.");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let tab of tabs) { // eslint-disable-line prefer-const
|
this._containerTabIterator(args.userContextId, tab => {
|
||||||
if (args.userContextId === this._getUserContextIdFromTab(tab)) {
|
|
||||||
tab.close();
|
tab.close();
|
||||||
}
|
});
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.resolve(ContextualIdentityService.remove(args.userContextId));
|
return Promise.resolve(ContextualIdentityService.remove(args.userContextId));
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue