You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32-3Lines changed: 32 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -67,11 +67,40 @@ In the built output you will see these dramatic differences in the bundled code
67
67
68
68
### Features scope injection utilities
69
69
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.
71
71
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)
74
74
- 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) {
0 commit comments