Skip to content

Commit 4e56a8a

Browse files
Release build 4.19.0 [ci release]
1 parent 0d5bfab commit 4e56a8a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+15178
-1938
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"indent": ["error", 4],
2121
"require-await": ["error"],
2222
"promise/prefer-await-to-then": ["error"],
23-
"@typescript-eslint/await-thenable": "error"
23+
"@typescript-eslint/await-thenable": "error",
24+
"@typescript-eslint/no-unused-vars": "error"
2425
},
2526
"env": {
2627
"webextensions": true,

README.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,40 @@ In the built output you will see these dramatic differences in the bundled code
6767

6868
### Features scope injection utilities
6969

70-
To handle the difference in scope injection we expose multiple utilities which behave differently per browser in src/utils.js. for Firefox the code exposed handles [xrays correctly](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Sharing_objects_with_page_scripts) without needing the features to be authored differently.
70+
To handle the difference in scope injection we expose multiple utilities which behave differently per browser in src/utils.js and src/wrapper-utils.js. for Firefox the code exposed handles [xrays correctly](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Sharing_objects_with_page_scripts) without needing the features to be authored differently.
7171

72-
- defineProperty
73-
- defineProperty(object, propertyName, descriptor) behaves the same as Object.defineProperty(object, propertyName, descriptor)
72+
- defineProperty()
73+
- defineProperty(object, propertyName, descriptor) behaves the same as Object.defineProperty(object, propertyName, descriptor)
7474
- The difference is for Firefox we export the relevant functions so it can go across the xray
75+
- wrapProperty(object, propertyName, descriptor)
76+
- a simple wrapper around defineProperty() that ignores non-existing properties and retains unspecified descriptor keys.
77+
- Example usage: `wrapProperty('Navigator.prototype.userAgent', { get: () => 'fakeUA' })`
78+
- wrapMethod(object, propertyName, wrapperFn)
79+
- overrides a native method. wrapperFn() will be called in place of the original method. The original method will be passed as the first argument.
80+
- Example usage:
81+
```
82+
wrapMethod(Permissions.prototype, 'query', async function (originalFn, queryObject) {
83+
if (queryObject.name === 'blocked-permission') {
84+
return {
85+
name: queryObject.name,
86+
state: 'denied',
87+
status: 'denied'
88+
}
89+
}
90+
return await nativeImpl.call(this, queryObject)
91+
})
92+
```
93+
94+
- wrapConstructor(object, propertyName, wrapperFn)
95+
- overrides a constructor. It works similar to `wrapMethod()`, but handles extra constructor-specific details
96+
- Example usage:
97+
```
98+
wrapConstructor(window, 'Date', function (originalConstructor, ...args) {
99+
// always return the same date
100+
return new originalConstructor(1995, 11, 17)
101+
})
102+
```
103+
75104
- DDGProxy
76105
- Behaves a lot like new window.Proxy with a few differences:
77106
- has an overload function to actually apply the function to the native property.

0 commit comments

Comments
 (0)