4 <title>Notifications: Should be able to focus window in onclick event.
</title>
5 <script src=
"../resources/testharness.js"></script>
6 <script src=
"../resources/testharnessreport.js"></script>
7 <script src=
"../resources/permissions-helper.js"></script>
11 // Tests that Document-bound notifications are able to focus a window in
12 // their onclick event. When the test is being run manually, grant
13 // Notification permission and click on the notification.
14 if (window
.testRunner
) {
15 testRunner
.setCanOpenWindows();
16 testRunner
.setCloseRemainingWindowsWhenComplete();
19 async_test(function(test
) {
20 PermissionsHelper
.setPermission('notifications', 'granted').then(test
.step_func(function() {
21 if (Notification
.permission
!= 'granted') {
22 assert_unreached('No permission has been granted for displaying notifications.');
26 window
.addEventListener('focus', test
.step_func(function() {
30 var childWindow
= window
.open('about:blank');
33 var notification
= new Notification('My Notification');
34 notification
.addEventListener('show', test
.step_func(function() {
35 if (window
.testRunner
)
36 testRunner
.simulateWebNotificationClick('My Notification');
39 notification
.addEventListener('click', test
.step_func(function() {
43 notification
.addEventListener('error', test
.step_func(function() {
44 assert_unreached('The error event should not be thrown.');
47 }, 'Clicking on a notification enables it to focus the window it was created from.');
49 <script src=
"resources/click-focus-test.js"></script>