OLD | NEW |
1 <script> | 1 <script> |
2 var notification = null; | 2 var notification = null; |
3 | 3 |
4 // Shows the notification window using the specified URL. | 4 // Shows the notification window using the specified URL. |
5 // Control continues at onNotificationDone(). | 5 // Control continues at onNotificationDone(). |
6 function showNotification(url) { | 6 function showNotification(url) { |
7 notification = window.webkitNotifications.createHTMLNotification(url); | 7 notification = window.webkitNotifications.createHTMLNotification(url); |
8 notification.onerror = function() { | 8 notification.onerror = function() { |
9 chrome.test.fail("Failed to show notification."); | 9 chrome.test.fail("Failed to show notification."); |
10 }; | 10 }; |
11 notification.show(); | 11 notification.show(); |
12 } | 12 } |
13 | 13 |
14 // Called by the notification when it is done with its tests. | 14 // Called by the notification when it is done with its tests. |
15 function onNotificationDone() { | 15 function onNotificationDone(notificationWindow) { |
16 var views = chrome.extension.getViews(); | 16 var views = chrome.extension.getViews(); |
17 chrome.test.assertEq(2, views.length); | 17 chrome.test.assertEq(2, views.length); |
| 18 notificationWindow.onunload = function() { |
| 19 chrome.test.succeed(); |
| 20 } |
18 notification.cancel(); | 21 notification.cancel(); |
19 chrome.test.succeed(); | |
20 } | 22 } |
21 | 23 |
22 chrome.test.runTests([ | 24 chrome.test.runTests([ |
23 function hasPermission() { | 25 function hasPermission() { |
24 chrome.test.assertEq(0, // allowed | 26 chrome.test.assertEq(0, // allowed |
25 webkitNotifications.checkPermission()); | 27 webkitNotifications.checkPermission()); |
26 chrome.test.succeed(); | 28 chrome.test.succeed(); |
27 }, | 29 }, |
28 function absoluteURL() { | 30 function absoluteURL() { |
29 showNotification(chrome.extension.getURL("notification.html")); | 31 showNotification(chrome.extension.getURL("notification.html")); |
30 }, | 32 }, |
31 function relativeURL() { | 33 function relativeURL() { |
32 showNotification("notification.html"); | 34 showNotification("notification.html"); |
33 } | 35 } |
34 ]); | 36 ]); |
35 </script> | 37 </script> |
OLD | NEW |