Chromium Code Reviews| 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; | 5 var notification = null; |
| 6 | 6 |
| 7 // Shows the notification window using the specified URL. | 7 function showHTMLNotification() { |
| 8 // Control continues at onNotificationDone(). | 8 // createHTMLNotification is not exposed even when the web page permission |
| 9 function showNotification(url) { | 9 // is granted. |
| 10 notification = window.webkitNotifications.createHTMLNotification(url); | 10 if (window.webkitNotifications.createHTMLNotification) |
| 11 chrome.test.fail("createHTMLNotification is found."); | |
| 12 else | |
| 13 chrome.test.succeed(); | |
| 14 } | |
| 15 | |
| 16 function showTextNotification() { | |
| 17 notification = window.webkitNotifications.createNotification( | |
| 18 "", "Foo", "This is text notification."); | |
| 11 notification.onerror = function() { | 19 notification.onerror = function() { |
| 12 chrome.test.fail("Failed to show notification."); | 20 chrome.test.fail("Failed to show notification."); |
| 13 }; | 21 }; |
| 22 notification.ondisplay = function() { | |
| 23 chrome.test.succeed(); | |
| 24 }; | |
| 14 notification.show(); | 25 notification.show(); |
| 15 } | 26 } |
| 16 | 27 |
| 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([ | 28 chrome.test.runTests([ |
| 28 function hasPermission() { | 29 function hasPermission() { |
| 29 chrome.test.assertEq(0, // allowed | 30 chrome.test.assertEq(0, // allowed |
| 30 webkitNotifications.checkPermission()); | 31 webkitNotifications.checkPermission()); |
| 31 chrome.test.succeed(); | 32 chrome.test.succeed(); |
| 32 }, | 33 }, |
| 33 function absoluteURL() { | 34 function htmlNotification() { |
| 34 showNotification(chrome.extension.getURL("notification.html")); | 35 showHTMLNotification(); |
|
Mihai Parparita -not on Chrome
2012/07/26 23:59:05
You might as well inline the test functions.
jianli
2012/07/27 00:34:10
Done.
| |
| 35 }, | 36 }, |
| 36 function relativeURL() { | 37 function textNotification() { |
| 37 showNotification("notification.html"); | 38 showTextNotification(); |
| 38 } | 39 } |
| 39 ]); | 40 ]); |
| OLD | NEW |