Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: lib/subscriptionInit.js

Issue 29761562: Issue 6496 - Account for notifications.create() failing asynchronously (Closed)
Patch Set: Created April 25, 2018, 1:33 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld