tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

fetch-url-resolve.https.window.js (1205B)


      1 // META: script=/resources/testdriver.js
      2 // META: script=/resources/testdriver-vendor.js
      3 // META: script=/service-workers/service-worker/resources/test-helpers.sub.js
      4 // META: script=resources/helpers.js
      5 
      6 // (Cannot use `global=window,worker` because testdriver only supports window)
      7 
      8 let registration;
      9 
     10 promise_setup(async () => {
     11  await trySettingPermission("granted");
     12  registration = await prepareActiveServiceWorker("noop-sw.js");
     13 });
     14 
     15 const resolvedUrl = new URL("foo.png", location.href).toString();
     16 
     17 promise_test(async t => {
     18  const n = new Notification("new Notification", { icon: "foo.png" });
     19  t.add_cleanup(() => n.close());
     20 
     21  assert_equals(n.icon, resolvedUrl, "should give a resolved URL");
     22 }, "new Notification() should give a resolved icon URL");
     23 
     24 promise_test(async t => {
     25  t.add_cleanup(closeAllNotifications);
     26 
     27  await registration.showNotification("showNotification", { icon: "foo.png" });
     28 
     29  let notifications = await registration.getNotifications();
     30  assert_equals(notifications.length, 1, "The list should include one notification");
     31  assert_equals(notifications[0].icon, resolvedUrl, "should give a resolved URL");
     32 }, "getNotifications() should give a resolved icon URL");