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

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

Issue 855813002: Mark create/update/clear callbacks of notification API as optional (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments #25 Created 5 years, 11 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
« no previous file with comments | « chrome/renderer/resources/extensions/notifications_custom_bindings.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/api_test/notifications/api/basic_usage/background.js
diff --git a/chrome/test/data/extensions/api_test/notifications/api/basic_usage/background.js b/chrome/test/data/extensions/api_test/notifications/api/basic_usage/background.js
index e1d010605b9658fe419babbf6e19267c40df9d09..001f6db088ffb49eb32062a725f77a13da44e074 100644
--- a/chrome/test/data/extensions/api_test/notifications/api/basic_usage/background.js
+++ b/chrome/test/data/extensions/api_test/notifications/api/basic_usage/background.js
@@ -325,7 +325,32 @@ function testLargeImage() {
create("largeImage", options).then(succeed, fail);
}
+function testOptionalParameters() {
+ var testName = "testOptionalParameters";
+ var succeed = succeedTest(testName);
+ var fail = failTest(testName);
+ function createCallback(notificationId) {
+ new Promise(function() {
+ chrome.test.assertNoLastError();
+ chrome.test.assertEq("string", typeof notificationId);
+ // Optional callback - should run without problems
+ chrome.notifications.clear(notificationId);
+ // Note: The point of the previous line is to show that a callback can be
+ // optional. Because .clear is asynchronous, we have to be careful with
+ // calling .clear again. Since .clear is processed in order, calling
+ // clear() synchronously is okay.
+ // If this assumption does not hold and leaks to flaky tests, file a bug
+ // report and/or put the following call in a setTimeout call.
+
+ // The notification should not exist any more, so clear() should fail.
+ clear(notificationId).then(fail, succeed);
+ }).then(null, fail);
+ }
+ // .create should succeed even when notificationId is omitted.
+ chrome.notifications.create(basicNotificationOptions, createCallback);
+}
+
chrome.test.runTests([
testIdUsage, testBaseFormat, testListItem, testGetAll, testProgress,
- testLargeImage
+ testLargeImage, testOptionalParameters
]);
« no previous file with comments | « chrome/renderer/resources/extensions/notifications_custom_bindings.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698