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