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 --- .../test/alerts/browser_notification_replace.js | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 browser/base/content/test/alerts/browser_notification_replace.js (limited to 'browser/base/content/test/alerts/browser_notification_replace.js') diff --git a/browser/base/content/test/alerts/browser_notification_replace.js b/browser/base/content/test/alerts/browser_notification_replace.js new file mode 100644 index 000000000..e678dc438 --- /dev/null +++ b/browser/base/content/test/alerts/browser_notification_replace.js @@ -0,0 +1,38 @@ +"use strict"; + +let notificationURL = "http://example.org/browser/browser/base/content/test/alerts/file_dom_notifications.html"; + +add_task(function* test_notificationReplace() { + let pm = Services.perms; + pm.add(makeURI(notificationURL), "desktop-notification", pm.ALLOW_ACTION); + + yield BrowserTestUtils.withNewTab({ + gBrowser, + url: notificationURL + }, function* dummyTabTask(aBrowser) { + yield ContentTask.spawn(aBrowser, {}, function* () { + let win = content.window.wrappedJSObject; + let notification = win.showNotification1(); + let promiseCloseEvent = ContentTaskUtils.waitForEvent(notification, "close"); + + let showEvent = yield ContentTaskUtils.waitForEvent(notification, "show"); + Assert.equal(showEvent.target.body, "Test body 1", "Showed tagged notification"); + + let newNotification = win.showNotification2(); + let newShowEvent = yield ContentTaskUtils.waitForEvent(newNotification, "show"); + Assert.equal(newShowEvent.target.body, "Test body 2", "Showed new notification with same tag"); + + let closeEvent = yield promiseCloseEvent; + Assert.equal(closeEvent.target.body, "Test body 1", "Closed previous tagged notification"); + + let promiseNewCloseEvent = ContentTaskUtils.waitForEvent(newNotification, "close"); + newNotification.close(); + let newCloseEvent = yield promiseNewCloseEvent; + Assert.equal(newCloseEvent.target.body, "Test body 2", "Closed new notification"); + }); + }); +}); + +add_task(function* cleanup() { + Services.perms.remove(makeURI(notificationURL), "desktop-notification"); +}); -- cgit v1.2.3