Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Fix #2842, if the /creating tab is closed open a new tab instead of u…
Browse files Browse the repository at this point in the history
…pdating the nonexistent tab (#2850)
  • Loading branch information
ianb authored and jaredhirsch committed May 17, 2017
1 parent 37f7561 commit ccb2397
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion addon/webextension/background/takeshot.js
Expand Up @@ -47,7 +47,18 @@ this.takeshot = (function() {
openedTab = tab;
return uploadShot(shot);
}).then(() => {
return browser.tabs.update(openedTab.id, {url: shot.viewUrl});
return browser.tabs.update(openedTab.id, {url: shot.viewUrl}).then(
null,
(error) => {
// FIXME: If https://bugzilla.mozilla.org/show_bug.cgi?id=1365718 is resolved,
// use the errorCode added as an additional check:
if ((/invalid tab id/i).test(error)) {
// This happens if the tab was closed before the upload completed
return browser.tabs.create({url: shot.viewUrl});
}
throw error;
}
);
}).then(() => {
return shot.viewUrl;
}).catch((error) => {
Expand Down

0 comments on commit ccb2397

Please sign in to comment.