chromium/third_party/blink/web_tests/http/tests/notifications/serviceworkerregistration-service-worker-image-abort.html

<!doctype html>
<html>
  <head>
    <title>Notifications: Showing a notification with an image and then abort the load immediately.</title>
    <script src="../resources/testharness.js"></script>
    <script src="../resources/testharnessreport.js"></script>
    <script src="../serviceworker/resources/test-helpers.js"></script>
    <script src="resources/test-helpers.js"></script>
  </head>
  <body>
    <script>
      // Tests that showing a notification with an image that takes 200ms to load, which
      // is unlikely to succeed because the Service Worker registration will be unregistered
      // immediately after, does not cause a crash.

      async_test(function(test) {
          var scope = 'resources/scope/' + location.pathname,
              script = 'instrumentation-service-worker.js';

          testRunner.setPermission('notifications', 'granted', location.origin, location.origin);
          getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(info) {
              // (1) Display a Web Notification through the Service Worker with which
              // will take 200ms to load, and unregister the Service Worker immediately
              // after that to abort the in-progress load.
              info.port.postMessage({
                  command: 'show',

                  title: 'My Notification',
                  options: { body: 'Hello, world!',
                             icon: '/resources/slow-image.php?redirect_name=square100.png&mimeType=image/png&sleep=200' }
              });

              return info.registration.unregister().then(function () {
                  test.done();
              });
          }).catch(unreached_rejection(test));

      }, 'Showing a notification with an image and then abort the load immediately.');
    </script>
  </body>
</html>