feat(extension): add Firefox WebExtension support
Testing / remote-protocol-compat (0.9.5) (push) Successful in 48s
Testing / remote-protocol-compat (0.9.3) (push) Successful in 47s
Build & Publish Package / publish (push) Successful in 46s
Package Extension / package-extension (push) Successful in 59s
Testing / test (push) Failing after 50s
Testing / remote-protocol-compat (0.9.5) (push) Successful in 48s
Testing / remote-protocol-compat (0.9.3) (push) Successful in 47s
Build & Publish Package / publish (push) Successful in 46s
Package Extension / package-extension (push) Successful in 59s
Testing / test (push) Failing after 50s
- Add a neutral WebExtension API adapter that uses Firefox browser.* or Chromium chrome.* without mutating globals. - Switch extension runtime code to the adapter and add Firefox-specific typings for tabs, windows, tab groups, storage, scripting, and native messaging ports. - Fix Firefox temporary add-on instructions to load the packaged manifest with background.scripts instead of the Chromium service worker manifest. - Detect Firefox in clients.list via runtime.getBrowserInfo and keep Chromium user-agent fallback support. - Make navigate.open wait briefly for Firefox to replace initial about:blank with the requested URL. - Add JS coverage for API selection, clients.list browser detection, and Firefox navigate.open URL polling. - Bump package and extension version to 0.15.2.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
// @ts-nocheck
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { webExtApi } from '../src/browser-api';
|
||||
|
||||
test('browser-api uses Firefox browser.* before Chromium chrome.*', () => {
|
||||
const originalChrome = globalThis.chrome;
|
||||
const originalBrowser = globalThis.browser;
|
||||
const firefoxApi = { runtime: { id: 'firefox-api' } };
|
||||
const chromiumApi = { runtime: { id: 'chromium-api' } };
|
||||
|
||||
try {
|
||||
globalThis.chrome = chromiumApi;
|
||||
globalThis.browser = firefoxApi;
|
||||
|
||||
assert.equal(webExtApi.runtime, firefoxApi.runtime);
|
||||
} finally {
|
||||
if (originalChrome === undefined) delete globalThis.chrome;
|
||||
else globalThis.chrome = originalChrome;
|
||||
|
||||
if (originalBrowser === undefined) delete globalThis.browser;
|
||||
else globalThis.browser = originalBrowser;
|
||||
}
|
||||
});
|
||||
|
||||
test('browser-api falls back to chrome.* in Chromium', () => {
|
||||
const originalChrome = globalThis.chrome;
|
||||
const originalBrowser = globalThis.browser;
|
||||
const chromiumApi = { runtime: { id: 'chromium-api' } };
|
||||
|
||||
try {
|
||||
globalThis.chrome = chromiumApi;
|
||||
delete globalThis.browser;
|
||||
|
||||
assert.equal(webExtApi.runtime, chromiumApi.runtime);
|
||||
} finally {
|
||||
if (originalChrome === undefined) delete globalThis.chrome;
|
||||
else globalThis.chrome = originalChrome;
|
||||
|
||||
if (originalBrowser === undefined) delete globalThis.browser;
|
||||
else globalThis.browser = originalBrowser;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user