Skip to content

Commit a3c693c

Browse files
window.safari.pushNotification Safari checking fix (#172)
1 parent 223a08b commit a3c693c

File tree

10 files changed

+488
-48
lines changed

10 files changed

+488
-48
lines changed

Sources/ContentScopeScripts/dist/contentScope.js

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4210,7 +4210,44 @@
42104210
return
42114211
}
42124212
defineProperty(window, 'safari', {
4213-
value: {},
4213+
value: {
4214+
},
4215+
configurable: true,
4216+
enumerable: true
4217+
});
4218+
defineProperty(window.safari, 'pushNotification', {
4219+
value: {
4220+
},
4221+
configurable: true,
4222+
enumerable: true
4223+
});
4224+
defineProperty(window.safari.pushNotification, 'toString', {
4225+
value: () => { return '[object SafariRemoteNotification]' },
4226+
configurable: true,
4227+
enumerable: true
4228+
});
4229+
class SafariRemoteNotificationPermission {
4230+
constructor () {
4231+
this.deviceToken = null;
4232+
this.permission = 'denied';
4233+
}
4234+
}
4235+
defineProperty(window.safari.pushNotification, 'permission', {
4236+
value: (name) => {
4237+
return new SafariRemoteNotificationPermission()
4238+
},
4239+
configurable: true,
4240+
enumerable: true
4241+
});
4242+
defineProperty(window.safari.pushNotification, 'requestPermission', {
4243+
value: (name, domain, options, callback) => {
4244+
if (typeof callback === 'function') {
4245+
callback(new SafariRemoteNotificationPermission());
4246+
return
4247+
}
4248+
const reason = "Invalid 'callback' value passed to safari.pushNotification.requestPermission(). Expected a function.";
4249+
throw new Error(reason)
4250+
},
42144251
configurable: true,
42154252
enumerable: true
42164253
});
@@ -4219,10 +4256,17 @@
42194256
}
42204257
}
42214258

4222-
function init$1 () {
4223-
windowSizingFix();
4224-
navigatorCredentialsFix();
4225-
safariObjectFix();
4259+
function init$1 (args) {
4260+
const featureName = 'web-compat';
4261+
if (getFeatureSettingEnabled(featureName, args, 'windowSizing')) {
4262+
windowSizingFix();
4263+
}
4264+
if (getFeatureSettingEnabled(featureName, args, 'navigatorCredentials')) {
4265+
navigatorCredentialsFix();
4266+
}
4267+
if (getFeatureSettingEnabled(featureName, args, 'safariObject')) {
4268+
safariObjectFix();
4269+
}
42264270
}
42274271

42284272
var webCompat = /*#__PURE__*/Object.freeze({

build/android/contentScope.js

Lines changed: 49 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/chrome-mv3/inject.js

Lines changed: 49 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/chrome/inject.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/firefox/inject.js

Lines changed: 49 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/integration/contentScope.js

Lines changed: 82 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)