forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Observe window events only for non-persistent notifications
Differential Revision: https://phabricator.services.mozilla.com/D201627 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1879934 gecko-commit: 3dd0aa903d7f26c03fb8d966e0c1d4a3bd7f684e gecko-reviewers: asuth
- Loading branch information
1 parent
0a24e44
commit 57dcf26
Showing
4 changed files
with
64 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<script> | ||
async function showNotification() { | ||
const registration = await navigator.serviceWorker.ready; | ||
await registration.showNotification('foo'); | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/testdriver.js"></script> | ||
<script src="/resources/testdriver-vendor.js"></script> | ||
<script src="resources/helpers.js"></script> | ||
<iframe id="iframe" src="resources/shownotification-window-iframe.html"></iframe> | ||
<script> | ||
/** @type {ServiceWorkerRegistration} */ | ||
let registration; | ||
|
||
promise_setup(async (t) => { | ||
await trySettingPermission("granted"); | ||
registration = await getActiveServiceWorker("noop-sw.js"); | ||
await closeAllNotifications(); | ||
}); | ||
|
||
promise_test(async (t) => { | ||
t.add_cleanup(closeAllNotifications); | ||
|
||
if (iframe.contentDocument.readyState !== "complete") { | ||
await new Promise(resolve => iframe.onload = resolve); | ||
} | ||
|
||
await iframe.contentWindow.showNotification(); | ||
let notifications = await registration.getNotifications(); | ||
assert_equals(notifications.length, 1, "Should persist the notification"); | ||
|
||
iframe.contentWindow.location.reload(); | ||
// Wait for some time for potential notification close requests to be sent | ||
await new Promise(resolve => iframe.onload = resolve); | ||
notifications = await registration.getNotifications(); | ||
assert_equals(notifications.length, 1, "Should keep the notification"); | ||
}, 'Refreshing window does not clear persistent notifications'); | ||
</script> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters