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

Side by Side 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: Fix per feedback 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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;
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([ 5 chrome.test.runTests([
28 function hasPermission() { 6 function hasPermission() {
29 chrome.test.assertEq(0, // allowed 7 chrome.test.assertEq(0, // allowed
30 webkitNotifications.checkPermission()); 8 webkitNotifications.checkPermission());
31 chrome.test.succeed(); 9 chrome.test.succeed();
32 }, 10 },
33 function absoluteURL() { 11 function showHTMLNotification() {
34 showNotification(chrome.extension.getURL("notification.html")); 12 // createHTMLNotification is not exposed even when the web page permission
13 // is granted.
14 if (window.webkitNotifications.createHTMLNotification)
15 chrome.test.fail("createHTMLNotification is found.");
16 else
17 chrome.test.succeed();
35 }, 18 },
36 function relativeURL() { 19 function showTextNotification() {
37 showNotification("notification.html"); 20 var notification = window.webkitNotifications.createNotification(
21 "", "Foo", "This is text notification.");
22 notification.onerror = function() {
23 chrome.test.fail("Failed to show notification.");
24 };
25 notification.ondisplay = function() {
26 chrome.test.succeed();
27 };
28 notification.show();
38 } 29 }
39 ]); 30 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698