chromium/third_party/blink/web_tests/http/tests/notifications/close-dispatch-asynchronous.html

<!doctype html>
<html>
  <head>
    <title>Notifications: The close event should be dispatched asynchronously.</title>
    <script src="../resources/testharness.js"></script>
    <script src="../resources/testharnessreport.js"></script>
    <script src="resources/test-helpers.js"></script>
  </head>
  <body>
    <script>
      // Tests that the "close" event on a Notification object will be fired asynchronously
      // when it's being closed programmatically by the developer.
      if (window.testRunner)
          testRunner.setPermission('notifications', 'granted', location.origin, location.origin);

      async_test(function(test) {
          var eventOrderCounter = 0;
          var notification = new Notification('My Notification', {
              body: 'Hello, world!',
              icon: '/my-icon.png'
          });

          notification.addEventListener('show', function() {
              assert_equals(++eventOrderCounter, 2);
              notification.close();

              assert_equals(++eventOrderCounter, 3);
          });

          notification.addEventListener('close', function() {
              assert_equals(++eventOrderCounter, 4);

              test.done();
          });

          assert_equals(++eventOrderCounter, 1);

      }, 'The close event should be dispatched asynchronously.');

    </script>
  </body>
</html>