Files
tubestation/testing/web-platform/tests/notifications/fetch-url-resolve.https.window.js
Kagami Sascha Rosylight 0800b9244a Bug 1892705 - Persist fully resolved icon URL r=asuth,hsingh
The resolved URL is passed to alert service as expected already, and this patch makes sure Notification object itself stores the resolved URL as the spec says.

Safari and Chrome already conform to the spec.

Removing test_notification_get as it's now covered by WPT and modifying notification_worker as WPT doesn't cover dedicated workers yet (as testdriver limitation makes it hard).

Differential Revision: https://phabricator.services.mozilla.com/D208132
2024-06-10 16:56:18 +00:00

33 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 getActiveServiceWorker("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");