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

Side by Side Diff: chrome/test/data/extensions/api_test/notification_provider/basic_usage/background.js

Issue 468813002: Add NotifyOnPermissionLevelChanged implementation of notification (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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
« no previous file with comments | « chrome/browser/extensions/api/notification_provider/notification_provider_api.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 const notificationProvider = chrome.notificationProvider; 5 const notificationProvider = chrome.notificationProvider;
6 6
7 var myId = chrome.runtime.id; 7 var myId = chrome.runtime.id;
8 var id1 = "id1"; 8 var id1 = "id1";
9 var returnId = myId + "-" + id1; 9 var returnId = myId + "-" + id1;
10 var content = { 10 var content = {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 createNotification(id1, content) 153 createNotification(id1, content)
154 .catch(function() { failTest("notifications.create"); }) 154 .catch(function() { failTest("notifications.create"); })
155 // Try to notify that an non-existent notification was cleared. 155 // Try to notify that an non-existent notification was cleared.
156 .then(function () { return notifyOnCleared(myId, "doesNotExist"); }) 156 .then(function () { return notifyOnCleared(myId, "doesNotExist"); })
157 .then(function() { failTest("NotifyOnCleared"); }) 157 .then(function() { failTest("NotifyOnCleared"); })
158 // Notify that the original notification was cleared. 158 // Notify that the original notification was cleared.
159 .catch(function() { return notifyOnCleared(myId, returnId); }) 159 .catch(function() { return notifyOnCleared(myId, returnId); })
160 .catch(function() { failTest("NotifyOnCleared"); }); 160 .catch(function() { failTest("NotifyOnCleared"); });
161 } 161 }
162 162
163 function testNotifyOnPermissionLevelChanged() {
164 chrome.notifications.onPermissionLevelChanged.addListener(function(level) {
165 chrome.test.succeed();
166 });
167
168 // Create a notification, so there will be one existing notification.
169 createNotification(id1, content)
170 .catch(function() { failTest("notifications.create"); })
171 // Try to notify a web type notifier its permissional level is changed.
172 .then(function() { return notifyOnPermissionLevelChanged("SomeURL",
173 "web",
174 "granted"); })
175 .then(function() { failTest("NotifyOnPermissionLevelChanged"); })
176 // Notify that the permission level of current notifier is changed.
177 .catch(function () { return notifyOnPermissionLevelChanged(myId,
178 "application",
179 "granted"); })
180 .catch(function() { failTest("NotifyOnPermissionLevelChanged"); });
181 }
182
163 function testNotifyOnShowSettings() { 183 function testNotifyOnShowSettings() {
164 chrome.notifications.onShowSettings.addListener(function() { 184 chrome.notifications.onShowSettings.addListener(function() {
165 chrome.test.succeed(); 185 chrome.test.succeed();
166 }); 186 });
167 187
168 // Create a notification, so there will be one existing notification. 188 // Create a notification, so there will be one existing notification.
169 createNotification(id1, content) 189 createNotification(id1, content)
170 .catch(function() { failTest("notifications.create"); }) 190 .catch(function() { failTest("notifications.create"); })
171 // Try to notify a non existent sender that a user checked its settings. 191 // Try to notify a non existent sender that a user checked its settings.
172 .then(function () { return notifyOnShowSettings("DoesNotExist", 192 .then(function () { return notifyOnShowSettings("DoesNotExist",
173 "application"); }) 193 "application"); })
174 // Fail if it returns true. 194 // Fail if it returns true.
175 .then(function() { failTest("NotifyOnShowSettings"); }) 195 .then(function() { failTest("NotifyOnShowSettings"); })
176 // Notify current notifier that a user checked its settings. 196 // Notify current notifier that a user checked its settings.
177 .catch(function () { return notifyOnShowSettings(myId, "application"); }) 197 .catch(function () { return notifyOnShowSettings(myId, "application"); })
178 .catch(function() { failTest("NotifyOnShowSettings"); }) 198 .catch(function() { failTest("NotifyOnShowSettings"); });
179 } 199 }
180 200
181 chrome.test.runTests([ testNotifyOnClicked, 201 chrome.test.runTests([ testNotifyOnClicked,
182 testNotifyOnButtonClicked, 202 testNotifyOnButtonClicked,
183 testNotifyOnClosed, 203 testNotifyOnClosed,
204 testNotifyOnPermissionLevelChanged,
184 testNotifyOnShowSettings ]); 205 testNotifyOnShowSettings ]);
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/notification_provider/notification_provider_api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698