-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Part 2: Expand instance test for service worker
Differential Revision: https://phabricator.services.mozilla.com/D209008 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1894039 gecko-commit: c59a28c89897d5cdf18d23a24f8720f06e71b9cd gecko-reviewers: asuth
- Loading branch information
1 parent
74aad7d
commit d4bff26
Showing
7 changed files
with
108 additions
and
71 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,40 @@ | ||
const notification_args = [ | ||
"Radio check", | ||
{ | ||
dir: "ltr", | ||
lang: "aa", | ||
body: "This is a radio check.", | ||
tag: "radio_check999", | ||
icon: `${location.origin}/icon.png`, | ||
data: fakeCustomData, | ||
} | ||
]; | ||
|
||
// promise_tests because we need to wait for promise_setup | ||
function notification_instance_test(createFn, testTitle) { | ||
let n; | ||
promise_test(async t => { | ||
n = await createFn(t); | ||
}, `${testTitle}: Setup`); | ||
promise_test(async () => { | ||
assert_equals("Radio check", n.title) | ||
}, `${testTitle}: Attribute exists with expected value: title`) | ||
promise_test(async () => { | ||
assert_equals("ltr", n.dir) | ||
}, `${testTitle}: Attribute exists with expected value: dir`) | ||
promise_test(async () => { | ||
assert_equals("aa", n.lang) | ||
}, `${testTitle}: Attribute exists with expected value: lang`) | ||
promise_test(async () => { | ||
assert_equals("This is a radio check.", n.body) | ||
}, `${testTitle}: Attribute exists with expected value: body`) | ||
promise_test(async () => { | ||
assert_equals("radio_check999", n.tag) | ||
}, `${testTitle}: Attribute exists with expected value: tag`) | ||
promise_test(async () => { | ||
assert_equals(`${location.origin}/icon.png`, n.icon) | ||
}, `${testTitle}: Attribute exists with expected value: icon`) | ||
promise_test(async () => { | ||
assert_custom_data(n.data); | ||
}, `${testTitle}: Attribute exists with expected value: data`) | ||
} |
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,34 @@ | ||
importScripts("/resources/testharness.js"); | ||
importScripts("resources/helpers.js"); | ||
importScripts("resources/custom-data.js"); | ||
importScripts("instance-checks.js"); | ||
|
||
promise_setup(async () => { | ||
await untilActivate(); | ||
}); | ||
|
||
notification_instance_test(async t => { | ||
t.add_cleanup(closeAllNotifications); | ||
|
||
await registration.showNotification(...notification_args); | ||
|
||
let notifications = await registration.getNotifications(); | ||
assert_equals(notifications.length, 1, "The list should include one notification"); | ||
|
||
return notifications[0]; | ||
}, "getNotifications()"); | ||
|
||
// Doing this separately because this times out on Blink and GeckoView | ||
notification_instance_test(async t => { | ||
t.add_cleanup(closeAllNotifications); | ||
|
||
await registration.showNotification(...notification_args); | ||
|
||
let notifications = await registration.getNotifications(); | ||
assert_equals(notifications.length, 1, "The list should include one notification"); | ||
|
||
notifications[0].close(); | ||
const ev = await new Promise(resolve => addEventListener("notificationclose", resolve, { once: true })); | ||
|
||
return ev.notification; | ||
}, "notificationclose"); |
This file was deleted.
Oops, something went wrong.
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,18 @@ | ||
// META: script=/resources/testdriver.js | ||
// META: script=/resources/testdriver-vendor.js | ||
// META: script=/service-workers/service-worker/resources/test-helpers.sub.js | ||
// META: script=resources/helpers.js | ||
// META: script=resources/custom-data.js | ||
// META: script=instance-checks.js | ||
|
||
promise_setup(async () => { | ||
await trySettingPermission("granted"); | ||
}); | ||
|
||
notification_instance_test(() => { | ||
const n = new Notification(...notification_args); | ||
n.close(); | ||
return n; | ||
}, "new Notification()"); | ||
|
||
service_worker_test("instance-sw.js", "Service worker test setup"); |
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