OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 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([ |
| 28 function hasPermission() { |
| 29 chrome.test.assertEq(0, // allowed |
| 30 webkitNotifications.checkPermission()); |
| 31 chrome.test.succeed(); |
| 32 }, |
| 33 function absoluteURL() { |
| 34 showNotification(chrome.extension.getURL("notification.html")); |
| 35 }, |
| 36 function relativeURL() { |
| 37 showNotification("notification.html"); |
| 38 } |
| 39 ]); |
OLD | NEW |