| Index: chrome/browser/resources/google_now/common_test_util.js
|
| diff --git a/chrome/browser/resources/google_now/common_test_util.js b/chrome/browser/resources/google_now/common_test_util.js
|
| index 754e2578fa2f6bf059a5b2b70fbb7ea8c6ed0bed..44d21e6d1f640ea07406a7919738959bcbb09706 100644
|
| --- a/chrome/browser/resources/google_now/common_test_util.js
|
| +++ b/chrome/browser/resources/google_now/common_test_util.js
|
| @@ -82,16 +82,35 @@ function getMockHandlerContainer(eventIdentifier) {
|
| var Promise = function() {
|
| function PromisePrototypeObject(asyncTask) {
|
| var result;
|
| + var resolved = false;
|
| asyncTask(
|
| function(asyncResult) {
|
| result = asyncResult;
|
| + resolved = true;
|
| },
|
| - function() {}); // Errors are unsupported.
|
| + function(asyncFailureResult) {
|
| + result = asyncFailureResult;
|
| + resolved = false;
|
| + });
|
|
|
| function then(callback) {
|
| - callback.call(null, result);
|
| + if (resolved) {
|
| + callback.call(null, result);
|
| + }
|
| + return this;
|
| + }
|
| +
|
| + // Promises use the function name "catch" to call back error handlers.
|
| + // We can't use "catch" since function or variable names cannot use the word
|
| + // "catch".
|
| + function catchFunc(callback) {
|
| + if (!resolved) {
|
| + callback.call(null, result);
|
| + }
|
| + return this;
|
| }
|
| - return {then: then, isPromise: true};
|
| +
|
| + return {then: then, catch: catchFunc, isPromise: true};
|
| }
|
|
|
| function all(arrayOfPromises) {
|
|
|