Skip to content

Commit 23c0101

Browse files
author
Shane Osbourne
committed
Revert "Harmful API protections (#527)"
This reverts commit 2d9e5e4.
1 parent dbdc047 commit 23c0101

File tree

16 files changed

+77
-1013
lines changed

16 files changed

+77
-1013
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
node_modules/
33
.swiftpm
44
.env
5-
.build/
65
build/
76
docs/
87
test-results/

integration-test/playwright/harmful-apis.spec.js

Lines changed: 0 additions & 144 deletions
This file was deleted.

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,42 @@ export class WindowsPermissionsSpec {
3131
}
3232

3333
async enabled () {
34+
await this.installPolyfills()
3435
const config = JSON.parse(readFileSync(this.config, 'utf8'))
3536
await this.setup({ config })
3637
await this.page.goto(this.htmlPage)
3738
}
3839

40+
/**
41+
* In CI, the global objects such as USB might not be installed on the
42+
* version of chromium running there.
43+
*/
44+
async installPolyfills () {
45+
await this.page.addInitScript(() => {
46+
// @ts-expect-error - testing
47+
if (typeof Bluetooth === 'undefined') {
48+
globalThis.Bluetooth = {}
49+
globalThis.Bluetooth.prototype = { requestDevice: async () => { /* noop */ } }
50+
}
51+
// @ts-expect-error - testing
52+
if (typeof USB === 'undefined') {
53+
globalThis.USB = {}
54+
globalThis.USB.prototype = { requestDevice: async () => { /* noop */ } }
55+
}
56+
57+
// @ts-expect-error - testing
58+
if (typeof Serial === 'undefined') {
59+
globalThis.Serial = {}
60+
globalThis.Serial.prototype = { requestPort: async () => { /* noop */ } }
61+
}
62+
// @ts-expect-error - testing
63+
if (typeof HID === 'undefined') {
64+
globalThis.HID = {}
65+
globalThis.HID.prototype = { requestDevice: async () => { /* noop */ } }
66+
}
67+
})
68+
}
69+
3970
/**
4071
* @param {object} params
4172
* @param {Record<string, any>} params.config

integration-test/test-pages/harmful-apis/config/apis.json

Lines changed: 0 additions & 93 deletions
This file was deleted.

0 commit comments

Comments
 (0)