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

Unified Diff: trunk/src/chrome/test/data/extensions/api_test/notifications/api/partial_update/background.js

Issue 296113009: Revert 272211 "Allow high-res bitmaps to be passed in from notif..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 7 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: trunk/src/chrome/test/data/extensions/api_test/notifications/api/partial_update/background.js
===================================================================
--- trunk/src/chrome/test/data/extensions/api_test/notifications/api/partial_update/background.js (revision 272269)
+++ trunk/src/chrome/test/data/extensions/api_test/notifications/api/partial_update/background.js (working copy)
@@ -1,141 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-const notifications = chrome.notifications;
-
-function arrayEquals(a, b) {
- if (a === b) return true;
- if (a == null || b == null) return false;
- if (a.length !== b.length) return false;
-
- for (var i = 0; i < a.length; i++) {
- if (a[i] !== b[i]) return false;
- }
- return true;
-};
-
-function create(id, options) {
- return new Promise(function (resolve, reject) {
- notifications.create(id, options, function (id) {
- if (chrome.runtime.lastError) {
- reject(new Error("Unable to create notification"));
- return;
- }
- console.log("Created with id: " + id);
- resolve(id);
- return;
- });
- });
-};
-
-function update(id, options) {
- return new Promise(function (resolve, reject) {
- notifications.update(id, options, function (ok) {
- if (chrome.runtime.lastError || !ok) {
- reject(new Error("Unable to update notification"));
- return;
- }
- console.log("Updated id: ", id);
- resolve(ok);
- return;
- });
- });
-}
-
-function clear(id) {
- return new Promise(function (resolve, reject) {
- notifications.clear(id, function (ok) {
- if (chrome.runtime.lastError || !ok) {
- reject(new Error("Unable to clear notification"));
- return;
- }
- resolve(ok);
- return;
- });
- });
-}
-
-function getAll() {
- return new Promise(function (resolve, reject) {
- notifications.getAll(function (ids) {
- if (chrome.runtime.lastError) {
- reject(new Error(chrome.runtime.lastError.message));
- return;
- }
-
- if (ids === undefined) {
- resolve([]);
- return
- }
-
- var id_list = Object.keys(ids);
- resolve(id_list);
- });
- });
-}
-
-function clearAll() {
- return getAll().then(function (ids) {
- var idPromises = ids.map(function (id) { return clear(id); });
- return Promise.all(idPromises);
- });
-}
-
-function succeedTest(testName) {
- return function () {
- return clearAll().then(
- function () { chrome.test.succeed(testName); },
- function (error) {
- console.log("Unknown error in clearAll: " +
- JSON.stringify(arguments));
- });
- };
-}
-
-function failTest(testName) {
- return function () {
- return clearAll().then(
- function () { chrome.test.fail(testName); },
- function (error) {
- console.log("Unknown error in clearAll: " +
- JSON.stringify(error.message));
- });
- };
-}
-
-function testPartialUpdate() {
- var testName = "testPartialUpdate";
- console.log("Starting " + testName);
- var succeed = succeedTest(testName);
- var fail = failTest(testName);
-
- const red_dot = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA" +
- "AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO" +
- "9TXL0Y4OHwAAAABJRU5ErkJggg==";
-
- var basicNotificationOptions = {
- type: "basic",
- title: "Basic title",
- message: "Basic message",
- iconUrl: red_dot,
- buttons: [{title: "Button"}]
- };
-
- // Create a notification.
- create("testId", basicNotificationOptions)
- // Then update a few items
- .then(function () {
- return update("testId", {
- title: "Changed!",
- message: "Too late! The show ended yesterday"
- });
- })
- // Then update a few more items
- .then(function () { return update("testId", {priority:2, buttons: []}); })
- // The test will continue in C++, checking that all the updates "took"
- .then(chrome.test.succeed, chrome.test.fail);
-};
-
-
-chrome.test.runTests([testPartialUpdate]);

Powered by Google App Engine
This is Rietveld 408576698