1
0
Fork 0
firefox/testing/web-platform/tests/notifications/fetch-url-resolve.https.window.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

32 lines
1.2 KiB
JavaScript

// 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
// (Cannot use `global=window,worker` because testdriver only supports window)
let registration;
promise_setup(async () => {
await trySettingPermission("granted");
registration = await prepareActiveServiceWorker("noop-sw.js");
});
const resolvedUrl = new URL("foo.png", location.href).toString();
promise_test(async t => {
const n = new Notification("new Notification", { icon: "foo.png" });
t.add_cleanup(() => n.close());
assert_equals(n.icon, resolvedUrl, "should give a resolved URL");
}, "new Notification() should give a resolved icon URL");
promise_test(async t => {
t.add_cleanup(closeAllNotifications);
await registration.showNotification("showNotification", { icon: "foo.png" });
let notifications = await registration.getNotifications();
assert_equals(notifications.length, 1, "The list should include one notification");
assert_equals(notifications[0].icon, resolvedUrl, "should give a resolved URL");
}, "getNotifications() should give a resolved icon URL");