57 lines
1.9 KiB
HTML
57 lines
1.9 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=916893
|
|
-->
|
|
<head>
|
|
<title>Bug 1144660 - Test client.focus() permissions on notification click</title>
|
|
<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>
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1114554">Bug 1114554</a>
|
|
<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.");
|
|
|
|
async function testFrame(src, registration) {
|
|
let { promise, resolve } = Promise.withResolvers();
|
|
let iframe = document.createElement("iframe");
|
|
iframe.src = src;
|
|
window.callback = async function(result) {
|
|
window.callback = null;
|
|
document.body.removeChild(iframe);
|
|
iframe = null;
|
|
ok(result, "All tests passed.");
|
|
await registration.unregister();
|
|
resolve();
|
|
};
|
|
document.body.appendChild(iframe);
|
|
await promise;
|
|
}
|
|
|
|
add_task(async function runTest() {
|
|
await SpecialPowers.pushPrefEnv({"set": [
|
|
// notificationclick_focus depends on this value
|
|
["dom.webnotifications.disable_open_click_delay", 1000],
|
|
]});
|
|
await NotificationTest.allowNotifications();
|
|
await MockAlertsService.register();
|
|
await MockAlertsService.enableAutoClick();
|
|
let registration = await navigator.serviceWorker.register(
|
|
"notificationclick_focus.js",
|
|
{ scope: "notificationclick_focus.html" }
|
|
);
|
|
await waitForState(registration.installing, 'activated');
|
|
await testFrame('notificationclick_focus.html', registration);
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|