[PM-1796] The autofill keyboard shortcut does not prompt a user to unlock a locked extension within an incognito browsing session (#5337)

* [PM-1796] The autofill keyboard shortcut does not prompt a user to unlock a locked extension within an incongito browsing session

* [PM-1796] Implementing fixes for how we handle focus redirection when logging a user in and attempting to autofill within the Firefox Workspaces addon

* [PM-1796] Removing the `openerTab` value from the createNewTab method within brwoserApi.ts

* [PM-1796] Removing async declaration from createNewTab

* [PM-1796] Removing unnecessary param from the call to openBitwardenExtrensionTab
This commit is contained in:
Cesar Gonzalez 2023-05-15 11:42:01 -05:00 committed by GitHub
parent 1eff0f776f
commit c7150b8981
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 20 deletions

View File

@ -75,6 +75,8 @@ export default class RuntimeBackground {
this.systemService.cancelProcessReload();
if (item) {
await BrowserApi.focusWindow(item.commandToRetry.sender.tab.windowId);
await BrowserApi.focusTab(item.commandToRetry.sender.tab.id);
await BrowserApi.tabSendMessageData(
item.commandToRetry.sender.tab,
"unlockCompleted",
@ -103,7 +105,7 @@ export default class RuntimeBackground {
await this.main.openPopup();
break;
case "promptForLogin":
BrowserApi.openBitwardenExtensionTab("popup/index.html", true, sender.tab);
BrowserApi.openBitwardenExtensionTab("popup/index.html", true);
break;
case "openAddEditCipher": {
const addEditCipherUrl =
@ -111,7 +113,7 @@ export default class RuntimeBackground {
? "popup/index.html#/edit-cipher"
: "popup/index.html#/edit-cipher?cipherId=" + msg.data.cipherId;
BrowserApi.openBitwardenExtensionTab(addEditCipherUrl, true, sender.tab);
BrowserApi.openBitwardenExtensionTab(addEditCipherUrl, true);
break;
}
case "closeTab":

View File

@ -129,24 +129,27 @@ export class BrowserApi {
return Promise.resolve(chrome.extension.getViews({ type: "popup" }).length > 0);
}
static createNewTab(url: string, active = true, openerTab?: chrome.tabs.Tab) {
chrome.tabs.create({ url: url, active: active, openerTabId: openerTab?.id });
static createNewTab(url: string, active = true): Promise<chrome.tabs.Tab> {
return new Promise((resolve) =>
chrome.tabs.create({ url: url, active: active }, (tab) => resolve(tab))
);
}
static openBitwardenExtensionTab(
relativeUrl: string,
active = true,
openerTab?: chrome.tabs.Tab
) {
if (relativeUrl.includes("uilocation=tab")) {
this.createNewTab(relativeUrl, active, openerTab);
return;
static async focusWindow(windowId: number) {
await chrome.windows.update(windowId, { focused: true });
}
static async openBitwardenExtensionTab(relativeUrl: string, active = true) {
let url = relativeUrl;
if (!relativeUrl.includes("uilocation=tab")) {
const fullUrl = chrome.extension.getURL(relativeUrl);
const parsedUrl = new URL(fullUrl);
parsedUrl.searchParams.set("uilocation", "tab");
url = parsedUrl.toString();
}
const fullUrl = chrome.extension.getURL(relativeUrl);
const parsedUrl = new URL(fullUrl);
parsedUrl.searchParams.set("uilocation", "tab");
this.createNewTab(parsedUrl.toString(), active, openerTab);
const createdTab = await this.createNewTab(url, active);
this.focusWindow(createdTab.windowId);
}
static async closeBitwardenExtensionTab() {
@ -163,10 +166,6 @@ export class BrowserApi {
const tabToClose = tabs[tabs.length - 1];
chrome.tabs.remove(tabToClose.id);
if (tabToClose.openerTabId) {
this.focusTab(tabToClose.openerTabId);
}
}
static messageListener(