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

Test browser.* namespace with Chrome & Edge #2

Closed
Jimadine opened this issue Oct 17, 2024 · 4 comments
Closed

Test browser.* namespace with Chrome & Edge #2

Jimadine opened this issue Oct 17, 2024 · 4 comments

Comments

@Jimadine
Copy link
Owner

Jimadine commented Oct 17, 2024

Currently the extension uses the chrome.* namespace. The extension works in Firefox because:

Firefox also supports the chrome.* namespace for APIs that are compatible with Chrome, primarily to assist with porting

Source

However, ideally the browser.* namespace should be used but it's unclear whether Chrome supports this:

Note: The browser namespace is supported by Firefox and Safari. Chrome does not offer the browser namespace, until Chrome bug 798169 is resolved.

Source

This github issue suggests support for browser.* namespace was merged earlier in the year, so there's a fair chance the general release of Chrome now supports it.

Microsoft Edge appears to already support the browser.* namespace:

Microsoft Edge uses the browser namespace, but doesn't yet support promise-based asynchronous APIs. In Edge, for the time being, asynchronous APIs must use callbacks.

Source

@Jimadine
Copy link
Owner Author

Seemingly Chromium 131.0.6778.86 doesn't have the needed change:

Uncaught ReferenceError: browser is not defined

@Jimadine
Copy link
Owner Author

Next best thing is:

const xbrowser = chrome ?? browser;

...as suggested here.

@Jimadine
Copy link
Owner Author

The above choose chrome as the default namespace, whuch we don't want. If I change the order (const xbrowser = browser ??chrome;) it doesn't work in Chromium:

Uncaught ReferenceError: browser is not defined

This works:

if (typeof browser === "undefined") {
  var xbrowser = chrome;
} else {
  var xbrowser = browser;
}

@Jimadine
Copy link
Owner Author

Fixed in 3b38d4a.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant