Skip to content

Commit d970deb

Browse files
author
Shane Osbourne
committed
trying in lexical scope
1 parent 989681c commit d970deb

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

integration-test/playwright/windows-permissions.spec.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,6 @@ import { mockWindowsMessaging, wrapWindowsScripts } from '@duckduckgo/messaging/
44

55
test('Windows Permissions Usage', async ({ page }) => {
66
const perms = new WindowsPermissionsSpec(page)
7-
await page.addInitScript(() => {
8-
// @ts-expect-error - testing
9-
if (typeof Bluetooth === 'undefined') {
10-
globalThis.Bluetooth = { requestDevice: async () => { /* noop */ } }
11-
}
12-
// @ts-expect-error - testing
13-
if (typeof USB === 'undefined') {
14-
globalThis.USB = { requestDevice: async () => { /* noop */ } }
15-
}
16-
17-
// @ts-expect-error - testing
18-
if (typeof Serial === 'undefined') {
19-
globalThis.Serial = { requestPort: async () => { /* noop */ } }
20-
}
21-
// @ts-expect-error - testing
22-
if (typeof HID === 'undefined') {
23-
globalThis.HID = { requestDevice: async () => { /* noop */ } }
24-
}
25-
})
267
await perms.enabled()
278
const results = await page.evaluate(() => {
289
// @ts-expect-error - this is added by the test framework

packages/messaging/lib/test-utils.mjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,22 @@ export function wrapWindowsScripts(js, replacements) {
153153
delete window.chrome.webview.postMessage;
154154
delete window.chrome.webview.addEventListener;
155155
delete window.chrome.webview.removeEventListener;
156+
if (typeof Bluetooth === 'undefined') {
157+
globalThis.Bluetooth = { requestDevice: async () => { /* noop */ } }
158+
}
159+
// @ts-expect-error - testing
160+
if (typeof USB === 'undefined') {
161+
globalThis.USB = { requestDevice: async () => { /* noop */ } }
162+
}
163+
164+
// @ts-expect-error - testing
165+
if (typeof Serial === 'undefined') {
166+
globalThis.Serial = { requestPort: async () => { /* noop */ } }
167+
}
168+
// @ts-expect-error - testing
169+
if (typeof HID === 'undefined') {
170+
globalThis.HID = { requestDevice: async () => { /* noop */ } }
171+
}
156172
${js}
157173
} catch (e) {
158174
console.error(e)

0 commit comments

Comments
 (0)