| OLD | NEW |
| 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 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 var chrome = { | 7 var chrome = { |
| 8 metricsPrivate: { | 8 metricsPrivate: { |
| 9 recordPercentage: function() {}, | 9 recordPercentage: function() {}, |
| 10 recordValue: function() {} | 10 recordValue: function() {} |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * @param {string} url URL | 22 * @param {string} url URL |
| 23 * @param {Object} options load options. | 23 * @param {Object} options load options. |
| 24 * @return {Promise<boolean>} True if the local cache is used. | 24 * @return {Promise<boolean>} True if the local cache is used. |
| 25 */ | 25 */ |
| 26 function loadAndCheckCacheUsed(client, url, options) { | 26 function loadAndCheckCacheUsed(client, url, options) { |
| 27 var cacheUsed = true; | 27 var cacheUsed = true; |
| 28 | 28 |
| 29 ImageLoaderClient.sendMessage_ = function(message, callback) { | 29 ImageLoaderClient.sendMessage_ = function(message, callback) { |
| 30 cacheUsed = false; | 30 cacheUsed = false; |
| 31 if (callback) | 31 if (callback) |
| 32 callback({data: 'ImageData', status: 'success'}); | 32 callback({data: 'ImageData', width: 100, height: 100, status: 'success'}); |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 return new Promise(function(fulfill) { | 35 return new Promise(function(fulfill) { |
| 36 client.load(url, function() { | 36 client.load(url, function() { |
| 37 fulfill(cacheUsed); | 37 fulfill(cacheUsed); |
| 38 }, options); | 38 }, options); |
| 39 }); | 39 }); |
| 40 } | 40 } |
| 41 | 41 |
| 42 function testCache(callback) { | 42 function testCache(callback) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 loadAndCheckCacheUsed(client, 'data:URI', {cache: true}). | 77 loadAndCheckCacheUsed(client, 'data:URI', {cache: true}). |
| 78 then(function(cacheUsed) { | 78 then(function(cacheUsed) { |
| 79 assertFalse(cacheUsed); | 79 assertFalse(cacheUsed); |
| 80 return loadAndCheckCacheUsed(client, 'data:URI', {cache: true}); | 80 return loadAndCheckCacheUsed(client, 'data:URI', {cache: true}); |
| 81 }). | 81 }). |
| 82 then(function(cacheUsed) { | 82 then(function(cacheUsed) { |
| 83 assertFalse(cacheUsed); | 83 assertFalse(cacheUsed); |
| 84 }), | 84 }), |
| 85 callback); | 85 callback); |
| 86 } | 86 } |
| OLD | NEW |