| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 function supportsNotificationsWithButtons() | 138 function supportsNotificationsWithButtons() |
| 139 { | 139 { |
| 140 // Microsoft Edge (as of EdgeHTML 16) doesn't have the notifications API. | 140 // Microsoft Edge (as of EdgeHTML 16) doesn't have the notifications API. |
| 141 // Opera gives an asynchronous error when buttons are provided (we cannot | 141 // Opera gives an asynchronous error when buttons are provided (we cannot |
| 142 // detect that behavior without attempting to show a notification). | 142 // detect that behavior without attempting to show a notification). |
| 143 if (!("notifications" in browser) || info.application == "opera") | 143 if (!("notifications" in browser) || info.application == "opera") |
| 144 return false; | 144 return false; |
| 145 | 145 |
| 146 // Firefox throws synchronously if the "buttons" option is provided. | 146 // Firefox throws synchronously if the "buttons" option is provided. |
| 147 // If buttons are supported (i.e. on Chrome), this fails with | 147 // If buttons are supported (i.e. on Chrome), this fails with |
| 148 // a different error message due to missing required options. | 148 // an asynchronous error due to missing required options. |
| 149 // https://bugzilla.mozilla.org/show_bug.cgi?id=1190681 | 149 // https://bugzilla.mozilla.org/show_bug.cgi?id=1190681 |
| 150 try | 150 try |
| 151 { | 151 { |
| 152 browser.notifications.create({buttons: []}); | 152 browser.notifications.create({buttons: []}).catch(() => {}); |
| 153 } | 153 } |
| 154 catch (e) | 154 catch (e) |
| 155 { | 155 { |
| 156 if (e.toString().includes('"buttons" is unsupported')) | 156 if (e.toString().includes('"buttons" is unsupported')) |
| 157 return false; | 157 return false; |
| 158 } | 158 } |
| 159 | 159 |
| 160 return true; | 160 return true; |
| 161 } | 161 } |
| 162 | 162 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 * Sets a callback that is called with an array of subscriptions to be added | 284 * Sets a callback that is called with an array of subscriptions to be added |
| 285 * during initialization. The callback must return an array of subscriptions | 285 * during initialization. The callback must return an array of subscriptions |
| 286 * that will effectively be added. | 286 * that will effectively be added. |
| 287 * | 287 * |
| 288 * @param {function} callback | 288 * @param {function} callback |
| 289 */ | 289 */ |
| 290 exports.setSubscriptionsCallback = callback => | 290 exports.setSubscriptionsCallback = callback => |
| 291 { | 291 { |
| 292 subscriptionsCallback = callback; | 292 subscriptionsCallback = callback; |
| 293 }; | 293 }; |
| OLD | NEW |