Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make pop-up visible when signing tx for first time on ff #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 11 additions & 5 deletions packages/extension-base/src/background/handlers/State.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -60,14 +60,13 @@ interface SignRequest extends Resolver<ResponseSigning> {
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';
Expand Down Expand Up @@ -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);
}
}
});
}
Expand Down
12 changes: 12 additions & 0 deletions packages/extension-inject/src/chrome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}