fune/browser/base/content/test/alerts/browser_notification_replace.js
Kris Maglione 94e3b0bd8d Bug 1596918: Part 3a - Scripted rewrite of most ContentTask.spawn calls to SpecialPowers.spawn calls. r=mccr8,remote-protocol-reviewers,ato
This is generally pretty straightforward, and rewrites nearly all calls. It
skips the ones that it can detect using frame script globals like
`sendAsyncMessage`, though.

Differential Revision: https://phabricator.services.mozilla.com/D53740

--HG--
extra : moz-landing-system : lando
2019-12-13 20:36:16 +00:00

65 lines
1.7 KiB
JavaScript

"use strict";
let notificationURL =
"http://example.org/browser/browser/base/content/test/alerts/file_dom_notifications.html";
add_task(async function test_notificationReplace() {
await addNotificationPermission(notificationURL);
await BrowserTestUtils.withNewTab(
{
gBrowser,
url: notificationURL,
},
async function dummyTabTask(aBrowser) {
await SpecialPowers.spawn(aBrowser, [], async function() {
let win = content.window.wrappedJSObject;
let notification = win.showNotification1();
let promiseCloseEvent = ContentTaskUtils.waitForEvent(
notification,
"close"
);
let showEvent = await ContentTaskUtils.waitForEvent(
notification,
"show"
);
Assert.equal(
showEvent.target.body,
"Test body 1",
"Showed tagged notification"
);
let newNotification = win.showNotification2();
let newShowEvent = await ContentTaskUtils.waitForEvent(
newNotification,
"show"
);
Assert.equal(
newShowEvent.target.body,
"Test body 2",
"Showed new notification with same tag"
);
let closeEvent = await promiseCloseEvent;
Assert.equal(
closeEvent.target.body,
"Test body 1",
"Closed previous tagged notification"
);
let promiseNewCloseEvent = ContentTaskUtils.waitForEvent(
newNotification,
"close"
);
newNotification.close();
let newCloseEvent = await promiseNewCloseEvent;
Assert.equal(
newCloseEvent.target.body,
"Test body 2",
"Closed new notification"
);
});
}
);
});