diff --git a/packages/extension-base/src/background/handlers/Extension.ts b/packages/extension-base/src/background/handlers/Extension.ts index 312ba65eb5..01a34ce4f0 100644 --- a/packages/extension-base/src/background/handlers/Extension.ts +++ b/packages/extension-base/src/background/handlers/Extension.ts @@ -488,7 +488,7 @@ export default class Extension { } private windowOpen (path: AllowedPath): boolean { - const url = `${chrome.extension.getURL('index.html')}#${path}`; + const url = `${chrome.runtime.getURL('index.html')}#${path}`; if (!ALLOWED_PATH.includes(path)) { console.error('Not allowed to open the url:', url); diff --git a/packages/extension-base/src/background/handlers/State.ts b/packages/extension-base/src/background/handlers/State.ts index f813399db2..14caa3536e 100644 --- a/packages/extension-base/src/background/handlers/State.ts +++ b/packages/extension-base/src/background/handlers/State.ts @@ -8,7 +8,7 @@ import type { AccountJson, AuthorizeRequest, MetadataRequest, RequestAuthorizeTa import { BehaviorSubject } from 'rxjs'; import { addMetadata, knownMetadata } from '@polkadot/extension-chains'; -import chrome from '@polkadot/extension-inject/chrome'; +import chrome, {getBrowser} from '@polkadot/extension-inject/chrome'; import { assert } from '@polkadot/util'; import { MetadataStore } from '../../stores'; @@ -60,14 +60,13 @@ interface SignRequest extends Resolver { let idCounter = 0; const WINDOW_OPTS = { - // This is not allowed on FF, only on Chrome - disable completely - // focused: true, + focused: true, height: 621, left: 150, top: 150, type: 'popup', - url: chrome.extension.getURL('notification.html'), - width: 560 + url: chrome.runtime.getURL('notification.html'), + width: 560, }; const AUTH_URLS_KEY = 'authUrls'; @@ -164,6 +163,13 @@ export default class State { chrome.windows.create({ ...WINDOW_OPTS }, (window?: chrome.windows.Window): void => { if (window) { this.#windows.push(window.id); + const browser = getBrowser(); + // Additional step for ff browser - + //(In Firefox, the top value currently is ignored for popups (bug 1271047) but can be set using browser.windows.update().) + if (browser === 'Firefox') { + const cloneWindowOptMinusURL = (({ url, type, ...o }) => o)(WINDOW_OPTS) + chrome.windows.update(window.id, cloneWindowOptMinusURL); + } } }); } diff --git a/packages/extension-inject/src/chrome.ts b/packages/extension-inject/src/chrome.ts index bae320fee4..0d300e4484 100644 --- a/packages/extension-inject/src/chrome.ts +++ b/packages/extension-inject/src/chrome.ts @@ -8,3 +8,15 @@ const extension = typeof chrome !== 'undefined' : null; export default extension as typeof chrome; + +export function getBrowser() { + if (typeof chrome !== "undefined") { + if (typeof browser !== "undefined") { + return "Firefox"; + } else { + return "Chrome"; + } + } else { + return "Edge"; + } +}