Skip to content

Commit cac8f10

Browse files
committed
Add toString attempt
1 parent d61720e commit cac8f10

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

injected/integration-test/web-compat.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,16 @@ test.describe('Ensure Notification interface is injected', () => {
130130
return window.Notification.maxActions;
131131
});
132132
expect(maxActionsPropDenied).toEqual(2);
133+
134+
const notificationToString = await page.evaluate(() => {
135+
return window.Notification.toString();
136+
});
137+
expect(notificationToString).toEqual('function Notification() { [native code] }');
138+
139+
const requestPermissionToString = await page.evaluate(() => {
140+
return window.Notification.requestPermission.toString();
141+
});
142+
expect(requestPermissionToString).toEqual('function requestPermission() { [native code] }');
133143
});
134144
});
135145

injected/src/features/web-compat.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,14 @@ export class WebCompat extends ContentFeature {
202202
configurable: true,
203203
enumerable: false,
204204
});
205+
206+
this.defineProperty(/** @type {any} */ (window.Notification), 'toString', {
207+
value: () => 'function Notification() { [native code] }',
208+
writable: false,
209+
configurable: false,
210+
enumerable: false,
211+
});
212+
205213
// window.Notification polyfill is intentionally incompatible with DOM lib types
206214
this.defineProperty(/** @type {any} */ (window.Notification), 'requestPermission', {
207215
value: () => {
@@ -212,6 +220,13 @@ export class WebCompat extends ContentFeature {
212220
enumerable: true,
213221
});
214222

223+
this.defineProperty(/** @type {any} */ (window.Notification).requestPermission, 'toString', {
224+
value: () => 'function requestPermission() { [native code] }',
225+
writable: false,
226+
configurable: false,
227+
enumerable: false,
228+
});
229+
215230
this.defineProperty(/** @type {any} */ (window.Notification), 'permission', {
216231
get: () => 'denied',
217232
configurable: true,

0 commit comments

Comments
 (0)