tor-browser

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

test_notification_browser_failure.html (929B)


      1 <!DOCTYPE html>
      2 <script src="/tests/SimpleTest/SimpleTest.js"></script>
      3 <script src="/tests/dom/serviceworkers/test/utils.js"></script>
      4 <script src="MockAlertsService.js"></script>
      5 <script src="NotificationTest.js"></script>
      6 <link rel="stylesheet" href="/tests/SimpleTest/test.css">
      7 <script class="testbody">
      8 add_task(async function test_notification_browser_failure() {
      9  /** @type {ServiceWorkerRegistration} */
     10  const registration = await setupServiceWorker("notification_empty_sw.js", ".")
     11  await MockAlertsService.mockFailure();
     12 
     13  try {
     14    await registration.showNotification("This must not succeed");
     15    ok(false, "showNotification after mockFailure unexpectedly succeeded");
     16  } catch (err) {
     17    is(err.constructor, TypeError, "It should throw TypeError");
     18    ok(
     19      err.message.includes("Failed to show notification"),
     20      `Failing with the proper error message, got: ${err.message}`
     21    );
     22  }
     23 });
     24 </script>