diff --git a/.travis.yml b/.travis.yml index 2c65144b..4cb5ae9a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,5 +35,6 @@ script: - make styles - make jshint - make javascript + - make test - make binary - make build-i18n diff --git a/debian/changelog b/debian/changelog index 545e143a..08f0e75a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +spreed-webrtc-server (0.24.6) trusty; urgency=medium + + * Make travis run 'make test'. + * Disable notifications on Android Chrome (see https://code.google.com/p/chromium/issues/detail?id=481856). + + -- Simon Eisenmann Mon, 10 Aug 2015 17:33:46 +0200 + spreed-webrtc-server (0.24.5) trusty; urgency=medium * Updated ua-parser to 0.7.9. diff --git a/static/js/services/desktopnotify.js b/static/js/services/desktopnotify.js index 5484e720..706ba8d5 100644 --- a/static/js/services/desktopnotify.js +++ b/static/js/services/desktopnotify.js @@ -20,7 +20,7 @@ */ "use strict"; -define(['jquery', 'underscore', 'desktop-notify'], function($, _, notify) { +define(['jquery', 'underscore', 'desktop-notify', 'webrtc.adapter'], function($, _, notify) { return ["$window", function($window) { @@ -29,8 +29,8 @@ define(['jquery', 'underscore', 'desktop-notify'], function($, _, notify) { var iconElement = $("").addClass("desktopnotify-icon hidden"); iconElement.appendTo("body"); var url = iconElement.css('background-image'); - url = /^url\((['"]?)(.*)\1\)$/.exec(url); - url = url ? url[2] : ""; + url = /^url\((['"]?)(.*)\1\)$/.exec(url); + url = url ? url[2] : ""; iconElement.remove(); return url; }()); @@ -55,18 +55,43 @@ define(['jquery', 'underscore', 'desktop-notify'], function($, _, notify) { DesktopNotify.prototype.enabled = function() { - if (this.level === "default") { + if (this.supported && this.level === "default") { this.asked = true; this.requestPermission(); } - return (this.supported && this.level === "granted") ? true : false; + return this.supported && this.level === "granted"; }; DesktopNotify.prototype.refresh = function() { - this.supported = helper.isSupported; - this.level = helper.permissionLevel(); + var level = this.level = helper.permissionLevel(); + this.supported = (function() { + if (helper.isSupported) { + if ($window.Notification && $window.Notification.requestPermission) { + if (level !== "granted") { + // Aditional check to verify Notification really works. This fails + // on Android, where Notifications raise an exception. + // See https://code.google.com/p/chromium/issues/detail?id=481856 + try { + /*jshint nonew: false */ + new $window.Notification(''); + } catch(e) { + if (e.name == 'TypeError') { + return false; + } + } + } else { + // Disable notifications even if granted and on Android Chrome. + if ($window.webrtcDetectedAndroid) { + return false; + } + } + } + return true; + } + return false; + }()); };