From 13f6e623bb836b8dcefcbf28078699b34cb88da2 Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Tue, 21 May 2013 17:14:22 -0500 Subject: [PATCH] Suppress any crash in requestPermission --- js/client.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/js/client.js b/js/client.js index 278303858..5d98c5778 100644 --- a/js/client.js +++ b/js/client.js @@ -1325,16 +1325,18 @@ // notifications requestNotifications: function() { - if (window.webkitNotifications && webkitNotifications.requestPermission) { - // Notification.requestPermission crashes Chrome 23: - // https://code.google.com/p/chromium/issues/detail?id=139594 - // In lieu of a way to detect Chrome 23, we'll just use the old - // requestPermission API, which works to request permissions for - // the new Notification spec anyway. - webkitNotifications.requestPermission(); - } else if (window.Notification && Notification.requestPermission) { - Notification.requestPermission(function(permission) {}); - } + try { + if (window.webkitNotifications && webkitNotifications.requestPermission) { + // Notification.requestPermission crashes Chrome 23: + // https://code.google.com/p/chromium/issues/detail?id=139594 + // In lieu of a way to detect Chrome 23, we'll just use the old + // requestPermission API, which works to request permissions for + // the new Notification spec anyway. + webkitNotifications.requestPermission(); + } else if (window.Notification && Notification.requestPermission) { + Notification.requestPermission(function(permission) {}); + } + } catch (e) {} }, notifications: null, notify: function(title, body, tag, once) {