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

Side by Side 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, 10 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
« no previous file with comments | « chrome/renderer/resources/extensions/notifications_custom_bindings.js ('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 notifications = chrome.notifications; 5 const notifications = chrome.notifications;
6 6
7 const red_dot = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA" + 7 const red_dot = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA" +
8 "AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO" + 8 "AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO" +
9 "9TXL0Y4OHwAAAABJRU5ErkJggg=="; 9 "9TXL0Y4OHwAAAABJRU5ErkJggg==";
10 10
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 var fail = failTest(testName); 318 var fail = failTest(testName);
319 var options = { 319 var options = {
320 type: "basic", 320 type: "basic",
321 title: "Basic title", 321 title: "Basic title",
322 message: "Basic message", 322 message: "Basic message",
323 iconUrl: createBigImageUrl(), 323 iconUrl: createBigImageUrl(),
324 }; 324 };
325 create("largeImage", options).then(succeed, fail); 325 create("largeImage", options).then(succeed, fail);
326 } 326 }
327 327
328 function testOptionalParameters() {
329 var testName = "testOptionalParameters";
330 var succeed = succeedTest(testName);
331 var fail = failTest(testName);
332 function createCallback(notificationId) {
333 new Promise(function() {
334 chrome.test.assertNoLastError();
335 chrome.test.assertEq("string", typeof notificationId);
336 // Optional callback - should run without problems
337 chrome.notifications.clear(notificationId);
338 // Note: The point of the previous line is to show that a callback can be
339 // optional. Because .clear is asynchronous, we have to be careful with
340 // calling .clear again. Since .clear is processed in order, calling
341 // clear() synchronously is okay.
342 // If this assumption does not hold and leaks to flaky tests, file a bug
343 // report and/or put the following call in a setTimeout call.
344
345 // The notification should not exist any more, so clear() should fail.
346 clear(notificationId).then(fail, succeed);
347 }).then(null, fail);
348 }
349 // .create should succeed even when notificationId is omitted.
350 chrome.notifications.create(basicNotificationOptions, createCallback);
351 }
352
328 chrome.test.runTests([ 353 chrome.test.runTests([
329 testIdUsage, testBaseFormat, testListItem, testGetAll, testProgress, 354 testIdUsage, testBaseFormat, testListItem, testGetAll, testProgress,
330 testLargeImage 355 testLargeImage, testOptionalParameters
331 ]); 356 ]);
OLDNEW
« 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