Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4770)

Unified Diff: chrome/test/data/extensions/api_test/notifications/has_permission_prefs/background.js

Issue 10808113: Only allows extensions to create HTML notifications. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Test Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/notifications/has_permission_prefs/background.js
diff --git a/chrome/test/data/extensions/api_test/notifications/has_permission_prefs/background.js b/chrome/test/data/extensions/api_test/notifications/has_permission_prefs/background.js
index 7efb8b172323cebd9c5498053ae9fefc76a6c170..d18ed8521db0c1081e732707f2c0505e0f27da97 100644
--- a/chrome/test/data/extensions/api_test/notifications/has_permission_prefs/background.js
+++ b/chrome/test/data/extensions/api_test/notifications/has_permission_prefs/background.js
@@ -4,24 +4,25 @@
var notification = null;
-// Shows the notification window using the specified URL.
-// Control continues at onNotificationDone().
-function showNotification(url) {
- notification = window.webkitNotifications.createHTMLNotification(url);
+function showHTMLNotification() {
+ // createHTMLNotification is not exposed even when the web page permission
+ // is granted.
+ if (window.webkitNotifications.createHTMLNotification)
+ chrome.test.fail("createHTMLNotification is found.");
+ else
+ chrome.test.succeed();
+}
+
+function showTextNotification() {
+ notification = window.webkitNotifications.createNotification(
+ "", "Foo", "This is text notification.");
notification.onerror = function() {
chrome.test.fail("Failed to show notification.");
};
- notification.show();
-}
-
-// Called by the notification when it is done with its tests.
-function onNotificationDone(notificationWindow) {
- var views = chrome.extension.getViews();
- chrome.test.assertEq(2, views.length);
- notificationWindow.onunload = function() {
+ notification.ondisplay = function() {
chrome.test.succeed();
- }
- notification.cancel();
+ };
+ notification.show();
}
chrome.test.runTests([
@@ -30,10 +31,10 @@ chrome.test.runTests([
webkitNotifications.checkPermission());
chrome.test.succeed();
},
- function absoluteURL() {
- showNotification(chrome.extension.getURL("notification.html"));
+ function htmlNotification() {
+ 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.
},
- function relativeURL() {
- showNotification("notification.html");
+ function textNotification() {
+ showTextNotification();
}
]);

Powered by Google App Engine
This is Rietveld 408576698