diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /browser/base/content/test/alerts/browser_notification_open_settings.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'browser/base/content/test/alerts/browser_notification_open_settings.js')
-rw-r--r-- | browser/base/content/test/alerts/browser_notification_open_settings.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/browser/base/content/test/alerts/browser_notification_open_settings.js b/browser/base/content/test/alerts/browser_notification_open_settings.js new file mode 100644 index 000000000..5306fd90a --- /dev/null +++ b/browser/base/content/test/alerts/browser_notification_open_settings.js @@ -0,0 +1,58 @@ +"use strict"; + +var notificationURL = "http://example.org/browser/browser/base/content/test/alerts/file_dom_notifications.html"; + +add_task(function* test_settingsOpen_observer() { + info("Opening a dummy tab so openPreferences=>switchToTabHavingURI doesn't use the blank tab."); + yield BrowserTestUtils.withNewTab({ + gBrowser, + url: "about:robots" + }, function* dummyTabTask(aBrowser) { + let tabPromise = BrowserTestUtils.waitForNewTab(gBrowser, "about:preferences#content"); + info("simulate a notifications-open-settings notification"); + let uri = NetUtil.newURI("https://example.com"); + let principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {}); + Services.obs.notifyObservers(principal, "notifications-open-settings", null); + let tab = yield tabPromise; + ok(tab, "The notification settings tab opened"); + yield BrowserTestUtils.removeTab(tab); + }); +}); + +add_task(function* test_settingsOpen_button() { + let pm = Services.perms; + info("Adding notification permission"); + pm.add(makeURI(notificationURL), "desktop-notification", pm.ALLOW_ACTION); + + try { + yield BrowserTestUtils.withNewTab({ + gBrowser, + url: notificationURL + }, function* tabTask(aBrowser) { + info("Waiting for notification"); + yield openNotification(aBrowser, "showNotification2"); + + let alertWindow = Services.wm.getMostRecentWindow("alert:alert"); + if (!alertWindow) { + ok(true, "Notifications don't use XUL windows on all platforms."); + yield closeNotification(aBrowser); + return; + } + + let closePromise = promiseWindowClosed(alertWindow); + let tabPromise = BrowserTestUtils.waitForNewTab(gBrowser, "about:preferences#content"); + let openSettingsMenuItem = alertWindow.document.getElementById("openSettingsMenuItem"); + openSettingsMenuItem.click(); + + info("Waiting for notification settings tab"); + let tab = yield tabPromise; + ok(tab, "The notification settings tab opened"); + + yield closePromise; + yield BrowserTestUtils.removeTab(tab); + }); + } finally { + info("Removing notification permission"); + pm.remove(makeURI(notificationURL), "desktop-notification"); + } +}); |