Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / notifications / close-dispatch-asynchronous.html
blobf19a7fd6f1c74cffb3d5a62869761f00325b3b62
1 <!doctype html>
2 <html>
3 <head>
4 <title>Notifications: The close event should be dispatched asynchronously.</title>
5 <script src="../resources/testharness.js"></script>
6 <script src="../resources/testharnessreport.js"></script>
7 <script src="resources/test-helpers.js"></script>
8 </head>
9 <body>
10 <script>
11 // Tests that the "close" event on a Notification object will be fired asynchronously
12 // when it's being closed programmatically by the developer.
13 if (window.testRunner)
14 testRunner.setPermission('notifications', 'granted', location.origin, location.origin);
16 async_test(function(test) {
17 var eventOrderCounter = 0;
18 var notification = new Notification('My Notification', {
19 body: 'Hello, world!',
20 icon: '/my-icon.png'
21 });
23 notification.addEventListener('show', function() {
24 assert_equals(++eventOrderCounter, 2);
25 notification.close();
27 assert_equals(++eventOrderCounter, 3);
28 });
30 notification.addEventListener('close', function() {
31 assert_equals(++eventOrderCounter, 4);
33 test.done();
34 });
36 assert_equals(++eventOrderCounter, 1);
38 }, 'The close event should be dispatched asynchronously.');
40 </script>
41 </body>
42 </html>