Skip to content

Commit 3de9ce3

Browse files
committed
Use webextension-polyfill explicitly
1 parent a4b4135 commit 3de9ce3

File tree

13 files changed

+16
-25
lines changed

13 files changed

+16
-25
lines changed

source/global.d.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
1-
import type { Browser } from "webextension-polyfill";
2-
3-
declare global {
4-
const browser: Browser;
5-
// eslint-disable-next-line no-var -- `let/const` behave differently https://stackoverflow.com/a/69208755/288906
6-
var __webextMessenger: string;
7-
}
1+
// eslint-disable-next-line no-var -- `let/const` behave differently https://stackoverflow.com/a/69208755/288906
2+
declare var __webextMessenger: string;

source/receiver.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import browser from "webextension-polyfill";
12
import { serializeError } from "serialize-error";
23
import { getContextName } from "webext-detect";
34

source/sender.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import browser from "webextension-polyfill";
12
import pRetry from "p-retry";
23
import { isBackground } from "webext-detect";
34
import { deserializeError } from "serialize-error";

source/test/background.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import "./webextensionPolyfill.js";
21
import "./background/registration.js";
32
import "./contentscript/api.test.js";
43

source/test/background/testingApi.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import browser from "webextension-polyfill";
12
import { executeFunction } from "webext-content-scripts";
23
import { once } from "webext-messenger/shared.js";
34

45
export async function ensureScripts(tabId: number): Promise<void> {
56
await browser.scripting.executeScript({
67
target: { tabId },
7-
files: ["webextensionPolyfill.js", "contentscript/registration.js"],
8+
files: ["contentscript/registration.js"],
89
});
910
}
1011

source/test/contentscript/api.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import browser from "webextension-polyfill";
12
import test from "tape";
23
import { isBackground, isContentScript, isWebPage } from "webext-detect";
34
import { type PageTarget, type Target } from "webext-messenger";

source/test/contentscript/fixtures/unrelatedMessageListener.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import browser from "webextension-polyfill";
2+
13
browser.runtime.onMessage.addListener(
24
(message: unknown): Promise<string> | undefined => {
35
// eslint-disable-next-line @typescript-eslint/no-explicit-any

source/test/iframe.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@
77
margin: 20px 0;
88
}
99
</style>
10-
<script type="module" src="webextensionPolyfill.ts"></script>
1110
<script type="module" src="contentscript/registration.ts"></script>
1211
<h1>Extension frame</h1>

source/test/manifest.json

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,43 +19,40 @@
1919
"matches": [
2020
"https://fregante.github.io/pixiebrix-testing-ground/Will-call-background-methods"
2121
],
22-
"js": ["webextensionPolyfill.ts", "background/api.test.ts"]
22+
"js": ["background/api.test.ts"]
2323
},
2424
{
2525
"matches": [
2626
"https://fregante.github.io/pixiebrix-testing-ground/Will-call-offscreen-methods"
2727
],
28-
"js": ["webextensionPolyfill.ts", "offscreen/api.test.ts"]
28+
"js": ["offscreen/api.test.ts"]
2929
},
3030
{
3131
"all_frames": true,
3232
"matches": [
3333
"https://fregante.github.io/pixiebrix-testing-ground/Will-receive-CS-calls/*"
3434
],
35-
"js": ["webextensionPolyfill.ts", "contentscript/registration.ts"]
35+
"js": ["contentscript/registration.ts"]
3636
},
3737
{
3838
"matches": [
3939
"https://fregante.github.io/pixiebrix-testing-ground/Will-call-other-CS-via-background"
4040
],
41-
"js": ["webextensionPolyfill.ts", "contentscript/api.test.ts"]
41+
"js": ["contentscript/api.test.ts"]
4242
},
4343
{
4444
"all_frames": true,
4545
"matches": [
4646
"https://fregante.github.io/pixiebrix-testing-ground/Unrelated-CS-on-this-page"
4747
],
48-
"js": [
49-
"webextensionPolyfill.ts",
50-
"contentscript/fixtures/unrelatedMessageListener.ts"
51-
]
48+
"js": ["contentscript/fixtures/unrelatedMessageListener.ts"]
5249
},
5350
{
5451
"all_frames": true,
5552
"matches": [
5653
"https://fregante.github.io/pixiebrix-testing-ground/webext-messenger-was-imported-but-not-executed"
5754
],
58-
"js": ["webextensionPolyfill.ts", "contentscript/missedRegistration.ts"]
55+
"js": ["contentscript/missedRegistration.ts"]
5956
}
6057
],
6158
"web_accessible_resources": [

source/test/offscreen.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<!doctype html>
22
<meta charset="UTF-8" />
33
<title>Offscreen page</title>
4-
<script type="module" src="webextensionPolyfill.ts"></script>
54
<script type="module" src="offscreen/registration.ts"></script>

0 commit comments

Comments
 (0)