Index: lib/subscriptionInit.js |
=================================================================== |
--- a/lib/subscriptionInit.js |
+++ b/lib/subscriptionInit.js |
@@ -133,6 +133,31 @@ |
return selectedItem; |
} |
+function supportsNotificationsWithButtons() |
+{ |
+ // Microsoft Edge (as of EdgeHTML 16) doesn't have the notifications API. |
+ // Opera gives an asynchronous error when buttons are provided (we cannot |
+ // detect that behavior without attempting to show a notification). |
+ if (!("notifications" in browser) || info.application == "opera") |
+ return false; |
+ |
+ // Firefox throws synchronously if the "buttons" option is provided. |
+ // If buttons are supported (i.e. on Chrome), this fails with |
+ // a different error message due to missing required options. |
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1190681 |
+ try |
+ { |
+ browser.notifications.create({buttons: []}); |
+ } |
+ catch (e) |
+ { |
+ if (e.toString().includes('"buttons" is unsupported')) |
+ return false; |
+ } |
+ |
+ return true; |
+} |
+ |
/** |
* Gets the filter subscriptions to be added when the extnesion is loaded. |
* |
@@ -155,11 +180,16 @@ |
acceptableAdsSubscription.title = "Allow non-intrusive advertising"; |
subscriptions.push(acceptableAdsSubscription); |
- let antiAdblockSubscription = Subscription.fromURL( |
- Prefs.subscriptions_antiadblockurl |
- ); |
- antiAdblockSubscription.disabled = true; |
- subscriptions.push(antiAdblockSubscription); |
+ // Only add the anti-adblock messages subscription if |
+ // the related notification can be shown on this browser. |
+ if (supportsNotificationsWithButtons()) |
+ { |
+ let antiAdblockSubscription = Subscription.fromURL( |
+ Prefs.subscriptions_antiadblockurl |
+ ); |
+ antiAdblockSubscription.disabled = true; |
+ subscriptions.push(antiAdblockSubscription); |
+ } |
} |
// Add default ad blocking subscription (e.g. EasyList) |