OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Notifications: Simulating a click should call the onclick event.</tit
le> | 4 <title>Notifications: Simulating a click should call the onclick event.</tit
le> |
5 <script src="../resources/testharness.js"></script> | 5 <script src="../resources/testharness.js"></script> |
6 <script src="../resources/testharnessreport.js"></script> | 6 <script src="../resources/testharnessreport.js"></script> |
7 </head> | 7 </head> |
8 <body> | 8 <body> |
9 <script> | 9 <script> |
10 // Tests that Document-bound notifications are able to focus a window in | 10 // Tests that Document-bound notifications are able to focus a window in |
11 // their onclick event. When the test is being ran manually, grant | 11 // their onclick event. When the test is being ran manually, grant |
12 // Notification permission and click on the notification. | 12 // Notification permission and click on the notification. |
13 if (window.testRunner) { | 13 if (window.testRunner) { |
14 testRunner.setCanOpenWindows(); | 14 testRunner.setCanOpenWindows(); |
15 testRunner.setCloseRemainingWindowsWhenComplete(); | 15 testRunner.setCloseRemainingWindowsWhenComplete(); |
| 16 testRunner.setPermission('notifications', 'granted', location.origin,
location.origin); |
16 testRunner.grantWebNotificationPermission(location.origin, true); | 17 testRunner.grantWebNotificationPermission(location.origin, true); |
17 } | 18 } |
18 | 19 |
19 async_test(function(test) { | 20 async_test(function(test) { |
20 if (Notification.permission != 'granted') { | 21 if (Notification.permission != 'granted') { |
21 assert_unreached('No permission has been granted for displaying no
tifications.'); | 22 assert_unreached('No permission has been granted for displaying no
tifications.'); |
22 return; | 23 return; |
23 } | 24 } |
24 | 25 |
25 window.addEventListener('focus', function() { | 26 window.addEventListener('focus', function() { |
26 test.done(); | 27 test.done(); |
27 }); | 28 }); |
28 | 29 |
29 var childWindow = window.open('about:blank'); | 30 var childWindow = window.open('about:blank'); |
30 childWindow.focus(); | 31 childWindow.focus(); |
31 | 32 |
32 var notification = new Notification('My Notification'); | 33 var notification = new Notification('My Notification'); |
33 notification.addEventListener('show', function() { | 34 notification.addEventListener('show', function() { |
34 if (window.testRunner) | 35 if (window.testRunner) |
35 testRunner.simulateWebNotificationClick('My Notification'); | 36 testRunner.simulateWebNotificationClick('My Notification'); |
36 }); | 37 }); |
37 | 38 |
38 notification.addEventListener('click', function() { | 39 notification.addEventListener('click', function() { |
39 window.focus(); | 40 window.focus(); |
40 }); | 41 }); |
41 | 42 |
42 notification.addEventListener('error', function() { | 43 notification.addEventListener('error', function() { |
43 assert_unreached('The error event should not be thrown.'); | 44 assert_unreached('The error event should not be thrown.'); |
44 }); | 45 }); |
45 | 46 |
46 }, 'Clicking on a notification enables it to focus the window it was creat
ed from.'); | 47 }, 'Clicking on a notification enables it to focus the window it was creat
ed from.'); |
47 </script> | 48 </script> |
48 <script src="resources/click-focus-test.js"></script> | 49 <script src="resources/click-focus-test.js"></script> |
49 </body> | 50 </body> |
50 </html> | 51 </html> |
OLD | NEW |