<!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.grantWebNotificationPermission(location.origin, true);

      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>
Add a test to verify that Notification.onclose will be fired asynchronously.
Add a test to verify that Notification.onclose will be fired asynchronously.

This is part of a three-sided patch:

  (1) https://codereview.chromium.org/811473002
  (2) https://codereview.chromium.org/811463002
  (3) This patch.

BUG=442339

Review URL: https://codereview.chromium.org/804703003

git-svn-id: bf5cd6ccde378db821296732a091cfbcf5285fbd@187375 bbb929c8-8fbe-4397-9dbb-9b2b20218538
