Merge pull request #413 from ueokande/reopen-current-window
Reopen current window
This commit is contained in:
commit
9b27e4cd4f
3 changed files with 2710 additions and 2689 deletions
|
@ -222,6 +222,8 @@ describe("tab test", () => {
|
|||
}).then((win) => {
|
||||
expect(win.tabs).to.have.lengthOf(1);
|
||||
return keys.press(win.tabs[0].id, 'u');
|
||||
}).then(() => {
|
||||
return new Promise((resolve) => setTimeout(resolve, 100));
|
||||
}).then(() => {
|
||||
return windows.get(targetWindow.id);
|
||||
}).then((win) => {
|
||||
|
|
5385
package-lock.json
generated
5385
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -59,13 +59,17 @@ const closeTabsByKeywordsForce = (keyword) => {
|
|||
};
|
||||
|
||||
const reopenTab = () => {
|
||||
return browser.sessions.getRecentlyClosed({
|
||||
maxResults: 1
|
||||
let window = null;
|
||||
return browser.windows.getCurrent().then().then((w) => {
|
||||
window = w;
|
||||
return browser.sessions.getRecentlyClosed();
|
||||
}).then((sessions) => {
|
||||
if (sessions.length === 0) {
|
||||
let session = sessions.find((s) => {
|
||||
return s.tab && s.tab.windowId === window.id;
|
||||
});
|
||||
if (!session) {
|
||||
return;
|
||||
}
|
||||
let session = sessions[0];
|
||||
if (session.tab) {
|
||||
return browser.sessions.restore(session.tab.sessionId);
|
||||
}
|
||||
|
|
Reference in a new issue