Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: xorigin
- Manifest: dom/notification/test/mochitest/mochitest.toml
<!DOCTYPE HTML>
<html>
<!--
-->
<head>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/dom/notification/test/mochitest/MockAlertsService.js"></script>
<script src="/tests/dom/notification/test/mochitest/NotificationTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
<script src="/tests/dom/serviceworkers/test/utils.js"></script>
<script>
SimpleTest.requestFlakyTimeout("Mock alert service dispatches show and click events.");
add_task(() => setupServiceWorker("notificationclick.js", "notificationclick.html"));
add_task(async function click() {
await MockAlertsService.enableAutoClick();
const args = { data: { complex: ["jsval", 5] } };
const event = await testFrame("notificationclick.html", args);
isDeeply(event.notification.data, args.data, "Got notificationclick event with the correct data.")
is(event.action, "", "Got notificationclick event with an empty action.");
is(event.notification.actions.length, 0, "Got notificationclick event with an empty action list.");
});
add_task(async function clickWithAction() {
await MockAlertsService.enableAutoClick("foo");
const args = { actions: [{ action: "foo", title: "bar" }] };
const event = await testFrame("notificationclick.html", args);
is(event.action, "foo", "Got notificationclick event with the correct action.");
isDeeply(event.notification.actions, args.actions, "Got notificationclick event with a correct action list");
});
</script>
</body>
</html>