| 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 var chromeExtensionsUrl = "chrome://extensions/"; | 6 var chromeExtensionsUrl = "chrome://extensions/"; |
| 7 | 7 |
| 8 // Shows the notification window using the specified URL. | 8 // Shows the notification window using the specified URL. |
| 9 // Control continues at onNotificationDone(). | 9 // Control continues at onNotificationDone(). |
| 10 function showNotification(url) { | 10 function showNotification(url) { |
| 11 notification = window.webkitNotifications.createHTMLNotification(url); | 11 notification = window.webkitNotifications.createHTMLNotification(url); |
| 12 notification.onerror = function() { | 12 notification.onerror = function() { |
| 13 chrome.test.fail("Failed to show notification."); | 13 chrome.test.fail("Failed to show notification."); |
| 14 }; | 14 }; |
| 15 notification.show(); | 15 notification.show(); |
| 16 } | 16 } |
| 17 | 17 |
| 18 // Called by the notification when it is done with its tests. | 18 // Called by the notification when it is done with its tests. |
| 19 function onNotificationDone() { | 19 function onNotificationDone() { |
| 20 var views = chrome.extension.getViews(); | 20 var views = chrome.extension.getViews(); |
| 21 chrome.test.assertEq(2, views.length); | 21 chrome.test.assertEq(2, views.length); |
| 22 notification.cancel(); | 22 notification.cancel(); |
| 23 | 23 |
| 24 // This last step tests that crbug.com/40967 stays fixed. | 24 // This last step tests that crbug.com/40967 stays fixed. |
| 25 var listener = function(tabId, changeInfo, tab) { | 25 var listener = function(tabId, changeInfo, tab) { |
| 26 if (changeInfo.status != 'complete') | 26 if (changeInfo.status != 'complete') |
| 27 return; | 27 return; |
| 28 // web_page1 loaded, open extension page to inject script | 28 // web_page1 loaded, open extension page to inject script |
| 29 if (tab.url == chromeExtensionsUrl) { | 29 console.log(chromeExtensionsUrl + ' finished loading.'); |
| 30 console.log(chromeExtensionsUrl + ' finished loading.'); | 30 chrome.tabs.onUpdated.removeListener(listener); |
| 31 chrome.tabs.onUpdated.removeListener(listener); | 31 chrome.test.succeed(); |
| 32 chrome.test.succeed(); | |
| 33 } | |
| 34 }; | 32 }; |
| 35 | 33 |
| 36 chrome.tabs.onUpdated.addListener(listener); | 34 chrome.tabs.onUpdated.addListener(listener); |
| 37 chrome.tabs.create({ url: chromeExtensionsUrl }); | 35 chrome.tabs.create({ url: chromeExtensionsUrl }); |
| 38 } | 36 } |
| 39 | 37 |
| 40 chrome.test.runTests([ | 38 chrome.test.runTests([ |
| 41 function hasPermission() { | 39 function hasPermission() { |
| 42 chrome.test.assertEq(0, // allowed | 40 chrome.test.assertEq(0, // allowed |
| 43 webkitNotifications.checkPermission()); | 41 webkitNotifications.checkPermission()); |
| 44 chrome.test.succeed(); | 42 chrome.test.succeed(); |
| 45 }, | 43 }, |
| 46 function absoluteURL() { | 44 function absoluteURL() { |
| 47 showNotification(chrome.extension.getURL("notification.html")); | 45 showNotification(chrome.extension.getURL("notification.html")); |
| 48 }, | 46 }, |
| 49 function relativeURL() { | 47 function relativeURL() { |
| 50 showNotification('notification.html'); | 48 showNotification('notification.html'); |
| 51 } | 49 } |
| 52 ]); | 50 ]); |
| OLD | NEW |