Loading addon-sdk/source/CONTRIBUTING.md +0 −2 Original line number Diff line number Diff line Loading @@ -37,7 +37,6 @@ All changes need a review by someone on the Jetpack review crew: - [@mossop] - [@gozala] - [@ZER0] - [@erikvold] - [@jsantell] - [@zombie] Loading @@ -61,6 +60,5 @@ For API and developer ergonomics review, ask [@gozala]. [@mossop]:https://github.com/mossop/ [@gozala]:https://github.com/Gozala/ [@ZER0]:https://github.com/ZER0/ [@erikvold]:https://github.com/erikvold/ [@jsantell]:https://github.com/jsantell [@zombie]:https://github.com/zombie addon-sdk/source/bin/node-scripts/words.txt +0 −1 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ github stackoverflow bugzilla irc erikvold jsantell mossop gozala Loading browser/base/content/test/alerts/browser.ini +1 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ support-files = file_dom_notifications.html [browser_notification_do_not_disturb.js] [browser_notification_open_settings.js] [browser_notification_remove_permission.js] skip-if = e10s Loading browser/base/content/test/alerts/browser_notification_do_not_disturb.js 0 → 100644 +91 −0 Original line number Diff line number Diff line "use strict"; var tab; var notification; var notification2; var notificationURL = "http://example.org/browser/browser/base/content/test/alerts/file_dom_notifications.html"; const ALERT_SERVICE = Cc["@mozilla.org/alerts-service;1"] .getService(Ci.nsIAlertsService) .QueryInterface(Ci.nsIAlertsDoNotDisturb); function test () { waitForExplicitFinish(); try { // Only run the test if the do-not-disturb // interface has been implemented. ALERT_SERVICE.manualDoNotDisturb; ok(true, "Alert service implements do-not-disturb interface"); } catch (e) { ok(true, "Alert service doesn't implement do-not-disturb interface, exiting test"); finish(); return; } let pm = Services.perms; registerCleanupFunction(function() { ALERT_SERVICE.manualDoNotDisturb = false; pm.remove(makeURI(notificationURL), "desktop-notification"); gBrowser.removeTab(tab); window.restore(); }); pm.add(makeURI(notificationURL), "desktop-notification", pm.ALLOW_ACTION); // Make sure that do-not-disturb is not enabled. ok(!ALERT_SERVICE.manualDoNotDisturb, "Alert service should not be disabled when test starts"); ALERT_SERVICE.manualDoNotDisturb = false; tab = gBrowser.addTab(notificationURL); gBrowser.selectedTab = tab; tab.linkedBrowser.addEventListener("load", onLoad, true); } function onLoad() { tab.linkedBrowser.removeEventListener("load", onLoad, true); let win = tab.linkedBrowser.contentWindow.wrappedJSObject; notification = win.showNotification2(); notification.addEventListener("show", onAlertShowing); } function onAlertShowing() { info("Notification alert showing"); notification.removeEventListener("show", onAlertShowing); let alertWindow = Services.wm.getMostRecentWindow("alert:alert"); if (!alertWindow) { ok(true, "Notifications don't use XUL windows on all platforms."); notification.close(); finish(); return; } let doNotDisturbMenuItem = alertWindow.document.getElementById("doNotDisturbMenuItem"); is(doNotDisturbMenuItem.localName, "menuitem", "menuitem found"); alertWindow.addEventListener("beforeunload", onAlertClosing); doNotDisturbMenuItem.click(); info("Clicked on do-not-disturb menuitem") } function onAlertClosing(event) { event.target.removeEventListener("beforeunload", onAlertClosing); ok(ALERT_SERVICE.manualDoNotDisturb, "Alert service should be disabled after clicking menuitem"); let win = tab.linkedBrowser.contentWindow.wrappedJSObject; notification2 = win.showNotification2(); notification2.addEventListener("show", onAlert2Showing); // The notification should not appear, but there is // no way from the client-side to know that it was // blocked, except for waiting some time and realizing // that the "onshow" event never fired. setTimeout(function() { notification2.removeEventListener("show", onAlert2Showing); finish(); }, 2000); } function onAlert2Showing() { ok(false, "the second alert should not have been shown"); notification2.close(); } browser/components/preferences/in-content/content.js +33 −1 Original line number Diff line number Diff line Loading @@ -2,6 +2,19 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ XPCOMUtils.defineLazyGetter(this, "AlertsServiceDND", function () { try { let alertsService = Cc["@mozilla.org/alerts-service;1"] .getService(Ci.nsIAlertsService) .QueryInterface(Ci.nsIAlertsDoNotDisturb); // This will throw if manualDoNotDisturb isn't implemented. alertsService.manualDoNotDisturb; return alertsService; } catch (ex) { return undefined; } }); var gContentPane = { init: function () { Loading Loading @@ -30,6 +43,18 @@ var gContentPane = { } } let doNotDisturbAlertsEnabled = false; if (AlertsServiceDND) { let notificationsDoNotDisturbRow = document.getElementById("notificationsDoNotDisturbRow"); notificationsDoNotDisturbRow.removeAttribute("hidden"); if (AlertsServiceDND.manualDoNotDisturb) { let notificationsDoNotDisturb = document.getElementById("notificationsDoNotDisturb"); notificationsDoNotDisturb.setAttribute("checked", true); } } setEventListener("font.language.group", "change", gContentPane._rebuildFonts); setEventListener("notificationsPolicyButton", "command", Loading @@ -46,6 +71,8 @@ var gContentPane = { gContentPane.openTranslationProviderAttribution); setEventListener("translateButton", "command", gContentPane.showTranslationExceptions); setEventListener("notificationsDoNotDisturb", "command", gContentPane.toggleDoNotDisturbNotifications); let drmInfoURL = Services.urlFormatter.formatURLPref("app.support.baseURL") + "drm-content"; Loading Loading @@ -253,5 +280,10 @@ var gContentPane = { { Components.utils.import("resource:///modules/translation/Translation.jsm"); Translation.openProviderAttribution(); } }, toggleDoNotDisturbNotifications: function (event) { AlertsServiceDND.manualDoNotDisturb = event.target.checked; }, }; Loading
addon-sdk/source/CONTRIBUTING.md +0 −2 Original line number Diff line number Diff line Loading @@ -37,7 +37,6 @@ All changes need a review by someone on the Jetpack review crew: - [@mossop] - [@gozala] - [@ZER0] - [@erikvold] - [@jsantell] - [@zombie] Loading @@ -61,6 +60,5 @@ For API and developer ergonomics review, ask [@gozala]. [@mossop]:https://github.com/mossop/ [@gozala]:https://github.com/Gozala/ [@ZER0]:https://github.com/ZER0/ [@erikvold]:https://github.com/erikvold/ [@jsantell]:https://github.com/jsantell [@zombie]:https://github.com/zombie
addon-sdk/source/bin/node-scripts/words.txt +0 −1 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ github stackoverflow bugzilla irc erikvold jsantell mossop gozala Loading
browser/base/content/test/alerts/browser.ini +1 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ support-files = file_dom_notifications.html [browser_notification_do_not_disturb.js] [browser_notification_open_settings.js] [browser_notification_remove_permission.js] skip-if = e10s Loading
browser/base/content/test/alerts/browser_notification_do_not_disturb.js 0 → 100644 +91 −0 Original line number Diff line number Diff line "use strict"; var tab; var notification; var notification2; var notificationURL = "http://example.org/browser/browser/base/content/test/alerts/file_dom_notifications.html"; const ALERT_SERVICE = Cc["@mozilla.org/alerts-service;1"] .getService(Ci.nsIAlertsService) .QueryInterface(Ci.nsIAlertsDoNotDisturb); function test () { waitForExplicitFinish(); try { // Only run the test if the do-not-disturb // interface has been implemented. ALERT_SERVICE.manualDoNotDisturb; ok(true, "Alert service implements do-not-disturb interface"); } catch (e) { ok(true, "Alert service doesn't implement do-not-disturb interface, exiting test"); finish(); return; } let pm = Services.perms; registerCleanupFunction(function() { ALERT_SERVICE.manualDoNotDisturb = false; pm.remove(makeURI(notificationURL), "desktop-notification"); gBrowser.removeTab(tab); window.restore(); }); pm.add(makeURI(notificationURL), "desktop-notification", pm.ALLOW_ACTION); // Make sure that do-not-disturb is not enabled. ok(!ALERT_SERVICE.manualDoNotDisturb, "Alert service should not be disabled when test starts"); ALERT_SERVICE.manualDoNotDisturb = false; tab = gBrowser.addTab(notificationURL); gBrowser.selectedTab = tab; tab.linkedBrowser.addEventListener("load", onLoad, true); } function onLoad() { tab.linkedBrowser.removeEventListener("load", onLoad, true); let win = tab.linkedBrowser.contentWindow.wrappedJSObject; notification = win.showNotification2(); notification.addEventListener("show", onAlertShowing); } function onAlertShowing() { info("Notification alert showing"); notification.removeEventListener("show", onAlertShowing); let alertWindow = Services.wm.getMostRecentWindow("alert:alert"); if (!alertWindow) { ok(true, "Notifications don't use XUL windows on all platforms."); notification.close(); finish(); return; } let doNotDisturbMenuItem = alertWindow.document.getElementById("doNotDisturbMenuItem"); is(doNotDisturbMenuItem.localName, "menuitem", "menuitem found"); alertWindow.addEventListener("beforeunload", onAlertClosing); doNotDisturbMenuItem.click(); info("Clicked on do-not-disturb menuitem") } function onAlertClosing(event) { event.target.removeEventListener("beforeunload", onAlertClosing); ok(ALERT_SERVICE.manualDoNotDisturb, "Alert service should be disabled after clicking menuitem"); let win = tab.linkedBrowser.contentWindow.wrappedJSObject; notification2 = win.showNotification2(); notification2.addEventListener("show", onAlert2Showing); // The notification should not appear, but there is // no way from the client-side to know that it was // blocked, except for waiting some time and realizing // that the "onshow" event never fired. setTimeout(function() { notification2.removeEventListener("show", onAlert2Showing); finish(); }, 2000); } function onAlert2Showing() { ok(false, "the second alert should not have been shown"); notification2.close(); }
browser/components/preferences/in-content/content.js +33 −1 Original line number Diff line number Diff line Loading @@ -2,6 +2,19 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ XPCOMUtils.defineLazyGetter(this, "AlertsServiceDND", function () { try { let alertsService = Cc["@mozilla.org/alerts-service;1"] .getService(Ci.nsIAlertsService) .QueryInterface(Ci.nsIAlertsDoNotDisturb); // This will throw if manualDoNotDisturb isn't implemented. alertsService.manualDoNotDisturb; return alertsService; } catch (ex) { return undefined; } }); var gContentPane = { init: function () { Loading Loading @@ -30,6 +43,18 @@ var gContentPane = { } } let doNotDisturbAlertsEnabled = false; if (AlertsServiceDND) { let notificationsDoNotDisturbRow = document.getElementById("notificationsDoNotDisturbRow"); notificationsDoNotDisturbRow.removeAttribute("hidden"); if (AlertsServiceDND.manualDoNotDisturb) { let notificationsDoNotDisturb = document.getElementById("notificationsDoNotDisturb"); notificationsDoNotDisturb.setAttribute("checked", true); } } setEventListener("font.language.group", "change", gContentPane._rebuildFonts); setEventListener("notificationsPolicyButton", "command", Loading @@ -46,6 +71,8 @@ var gContentPane = { gContentPane.openTranslationProviderAttribution); setEventListener("translateButton", "command", gContentPane.showTranslationExceptions); setEventListener("notificationsDoNotDisturb", "command", gContentPane.toggleDoNotDisturbNotifications); let drmInfoURL = Services.urlFormatter.formatURLPref("app.support.baseURL") + "drm-content"; Loading Loading @@ -253,5 +280,10 @@ var gContentPane = { { Components.utils.import("resource:///modules/translation/Translation.jsm"); Translation.openProviderAttribution(); } }, toggleDoNotDisturbNotifications: function (event) { AlertsServiceDND.manualDoNotDisturb = event.target.checked; }, };