OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var notification = null; | |
6 | |
7 // Shows the notification window using the specified URL. | |
8 // Control continues at onNotificationDone(). | |
9 function showNotification(url) { | |
10 notification = window.webkitNotifications.createHTMLNotification(url); | |
11 notification.onerror = function() { | |
12 chrome.test.fail("Failed to show notification."); | |
13 }; | |
14 notification.show(); | |
15 } | |
16 | |
17 // Called by the notification when it is done with its tests. | |
18 function onNotificationDone(notificationWindow) { | |
19 var views = chrome.extension.getViews(); | |
20 chrome.test.assertEq(2, views.length); | |
21 notificationWindow.onunload = function() { | |
22 chrome.test.succeed(); | |
23 } | |
24 notification.cancel(); | |
25 } | |
26 | |
27 chrome.test.runTests([ | 5 chrome.test.runTests([ |
28 function hasPermission() { | 6 function hasPermission() { |
29 chrome.test.assertEq(0, // allowed | 7 chrome.test.assertEq(0, // allowed |
30 webkitNotifications.checkPermission()); | 8 webkitNotifications.checkPermission()); |
31 chrome.test.succeed(); | 9 chrome.test.succeed(); |
32 }, | 10 }, |
33 function absoluteURL() { | 11 function showHTMLNotification() { |
34 showNotification(chrome.extension.getURL("notification.html")); | 12 // createHTMLNotification is not exposed even when the web page permission |
| 13 // is granted. |
| 14 if (window.webkitNotifications.createHTMLNotification) |
| 15 chrome.test.fail("createHTMLNotification is found."); |
| 16 else |
| 17 chrome.test.succeed(); |
35 }, | 18 }, |
36 function relativeURL() { | 19 function showTextNotification() { |
37 showNotification("notification.html"); | 20 var notification = window.webkitNotifications.createNotification( |
| 21 "", "Foo", "This is text notification."); |
| 22 notification.onerror = function() { |
| 23 chrome.test.fail("Failed to show notification."); |
| 24 }; |
| 25 notification.ondisplay = function() { |
| 26 chrome.test.succeed(); |
| 27 }; |
| 28 notification.show(); |
38 } | 29 } |
39 ]); | 30 ]); |
OLD | NEW |