From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- .../desktop-notification/create_notification.html | 16 +++ .../notification/desktop-notification/moz.build | 6 ++ .../desktop-notification/notification_common.js | 70 +++++++++++++ .../test_basic_notification.html | 50 ++++++++++ .../test_basic_notification_click.html | 53 ++++++++++ .../test_leak_windowClose.html | 34 +++++++ .../test_notification_tag.html | 110 +++++++++++++++++++++ .../desktop-notification/test_system_principal.xul | 85 ++++++++++++++++ 8 files changed, 424 insertions(+) create mode 100644 dom/tests/mochitest/notification/desktop-notification/create_notification.html create mode 100644 dom/tests/mochitest/notification/desktop-notification/moz.build create mode 100644 dom/tests/mochitest/notification/desktop-notification/notification_common.js create mode 100644 dom/tests/mochitest/notification/desktop-notification/test_basic_notification.html create mode 100644 dom/tests/mochitest/notification/desktop-notification/test_basic_notification_click.html create mode 100644 dom/tests/mochitest/notification/desktop-notification/test_leak_windowClose.html create mode 100644 dom/tests/mochitest/notification/desktop-notification/test_notification_tag.html create mode 100644 dom/tests/mochitest/notification/desktop-notification/test_system_principal.xul (limited to 'dom/tests/mochitest/notification/desktop-notification') diff --git a/dom/tests/mochitest/notification/desktop-notification/create_notification.html b/dom/tests/mochitest/notification/desktop-notification/create_notification.html new file mode 100644 index 000000000..b0387e4ff --- /dev/null +++ b/dom/tests/mochitest/notification/desktop-notification/create_notification.html @@ -0,0 +1,16 @@ + + + + Create a notification + + + + + diff --git a/dom/tests/mochitest/notification/desktop-notification/moz.build b/dom/tests/mochitest/notification/desktop-notification/moz.build new file mode 100644 index 000000000..28919c271 --- /dev/null +++ b/dom/tests/mochitest/notification/desktop-notification/moz.build @@ -0,0 +1,6 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# 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/. + diff --git a/dom/tests/mochitest/notification/desktop-notification/notification_common.js b/dom/tests/mochitest/notification/desktop-notification/notification_common.js new file mode 100644 index 000000000..921b1e753 --- /dev/null +++ b/dom/tests/mochitest/notification/desktop-notification/notification_common.js @@ -0,0 +1,70 @@ +const MOCK_ALERTS_CID = SpecialPowers.wrap(SpecialPowers.Components).ID("{48068bc2-40ab-4904-8afd-4cdfb3a385f3}"); +const ALERTS_SERVICE_CONTRACT_ID = "@mozilla.org/alerts-service;1"; + +const MOCK_SYSTEM_ALERTS_CID = SpecialPowers.wrap(SpecialPowers.Components).ID("{e86d888c-e41b-4b78-9104-2f2742a532de}"); +const SYSTEM_ALERTS_SERVICE_CONTRACT_ID = "@mozilla.org/system-alerts-service;1"; + +var registrar = SpecialPowers.wrap(SpecialPowers.Components).manager. + QueryInterface(SpecialPowers.Ci.nsIComponentRegistrar); + +var mockAlertsService = { + showAlert: function(alert, alertListener) { + // probably should do this async.... + SpecialPowers.wrap(alertListener).observe(null, "alertshow", alert.cookie); + + if (SpecialPowers.getBoolPref("notification.prompt.testing.click_on_notification") == true) { + SpecialPowers.wrap(alertListener).observe(null, "alertclickcallback", alert.cookie); + } + + SpecialPowers.wrap(alertListener).observe(null, "alertfinished", alert.cookie); + }, + + showAlertNotification: function(imageUrl, title, text, textClickable, + cookie, alertListener, name, bidi, + lang, data) { + return this.showAlert({ + cookie: cookie + }, alertListener); + }, + + QueryInterface: function(aIID) { + if (SpecialPowers.wrap(aIID).equals(SpecialPowers.Ci.nsISupports) || + SpecialPowers.wrap(aIID).equals(SpecialPowers.Ci.nsIAlertsService)) { + return this; + } + throw SpecialPowers.Components.results.NS_ERROR_NO_INTERFACE; + }, + + createInstance: function(aOuter, aIID) { + if (aOuter != null) { + throw SpecialPowers.Components.results.NS_ERROR_NO_AGGREGATION; + } + return this.QueryInterface(aIID); + } +}; +mockAlertsService = SpecialPowers.wrapCallbackObject(mockAlertsService); + +function setup_notifications(allowPrompt, forceClick, callback) { + SpecialPowers.pushPrefEnv({'set': [["notification.prompt.testing", true], + ["notification.prompt.testing.allow", allowPrompt], + ["notification.prompt.testing.click_on_notification", forceClick]]}, + callback); + + registrar.registerFactory(MOCK_SYSTEM_ALERTS_CID, "system alerts service", + SYSTEM_ALERTS_SERVICE_CONTRACT_ID, + mockAlertsService); + + registrar.registerFactory(MOCK_ALERTS_CID, "alerts service", + ALERTS_SERVICE_CONTRACT_ID, + mockAlertsService); +} + +function reset_notifications() { + registrar.unregisterFactory(MOCK_SYSTEM_ALERTS_CID, mockAlertsService); + registrar.unregisterFactory(MOCK_ALERTS_CID, mockAlertsService); +} + +function is_feature_enabled() { + return navigator.mozNotification && SpecialPowers.getBoolPref("notification.feature.enabled"); +} + diff --git a/dom/tests/mochitest/notification/desktop-notification/test_basic_notification.html b/dom/tests/mochitest/notification/desktop-notification/test_basic_notification.html new file mode 100644 index 000000000..75f3c84b4 --- /dev/null +++ b/dom/tests/mochitest/notification/desktop-notification/test_basic_notification.html @@ -0,0 +1,50 @@ + + + + + Basic functional test + + + + + +Basic property tests +

+ +
+
+ + + diff --git a/dom/tests/mochitest/notification/desktop-notification/test_basic_notification_click.html b/dom/tests/mochitest/notification/desktop-notification/test_basic_notification_click.html new file mode 100644 index 000000000..defa0f412 --- /dev/null +++ b/dom/tests/mochitest/notification/desktop-notification/test_basic_notification_click.html @@ -0,0 +1,53 @@ + + + + + Basic functional test + + + + + +Basic property tests +

+ +
+
+ + + diff --git a/dom/tests/mochitest/notification/desktop-notification/test_leak_windowClose.html b/dom/tests/mochitest/notification/desktop-notification/test_leak_windowClose.html new file mode 100644 index 000000000..c0c9699ae --- /dev/null +++ b/dom/tests/mochitest/notification/desktop-notification/test_leak_windowClose.html @@ -0,0 +1,34 @@ + + + + + Test for leak when window closes + + + + + + + +

I like to write tests

+ + diff --git a/dom/tests/mochitest/notification/desktop-notification/test_notification_tag.html b/dom/tests/mochitest/notification/desktop-notification/test_notification_tag.html new file mode 100644 index 000000000..37bcb16c0 --- /dev/null +++ b/dom/tests/mochitest/notification/desktop-notification/test_notification_tag.html @@ -0,0 +1,110 @@ + + + + + Bug 782211 + + + + +Bug 782211 +

+ + + + +
+
+ + + diff --git a/dom/tests/mochitest/notification/desktop-notification/test_system_principal.xul b/dom/tests/mochitest/notification/desktop-notification/test_system_principal.xul new file mode 100644 index 000000000..1690bc101 --- /dev/null +++ b/dom/tests/mochitest/notification/desktop-notification/test_system_principal.xul @@ -0,0 +1,85 @@ + + + + + + + -- cgit v1.2.3