Chromium Code Reviews| Index: chrome/test/data/extensions/api_test/media_galleries/tourl/test.js |
| diff --git a/chrome/test/data/extensions/api_test/media_galleries/tourl/test.js b/chrome/test/data/extensions/api_test/media_galleries/tourl/test.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a5257ee7dc7d1a59c3e9d044cd41e095b9084a40 |
| --- /dev/null |
| +++ b/chrome/test/data/extensions/api_test/media_galleries/tourl/test.js |
| @@ -0,0 +1,49 @@ |
| +// 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. |
| + |
| +function check_result_factory(expected) { |
|
Lei Zhang
2014/03/20 21:37:53
This might be useful in other tests. Maybe move to
|
| + return function() { |
| + if (expected) { |
| + chrome.test.succeed(); |
| + } else { |
| + chrome.test.fail(); |
| + } |
| + }; |
| +} |
| + |
| +function TestImageLoadFactory(url, should_load) { |
| + return function() { |
| + test_image = document.createElement('img'); |
| + document.body.appendChild(test_image); |
| + test_image.addEventListener('load', check_result_factory(should_load)); |
| + test_image.addEventListener('error', check_result_factory(!should_load)); |
| + |
| + test_image.src = url; |
| + }; |
| +} |
| + |
| +CreateDummyWindowToPreventSleep(); |
| + |
| +chrome.test.getConfig(function(config) { |
| + var customArg = JSON.parse(config.customArg); |
| + var gallery_id = customArg[0]; |
| + var extension_url = chrome.runtime.getURL('/'); |
| + var extension_id = extension_url.split('/')[2]; |
| + |
| + var bad_mount_point = 'filesystem:' + extension_url + |
| + 'external/invalid-Default-' + extension_id + '-' + gallery_id + '/test.jpg'; |
| + |
| + var bad_mount_name = 'filesystem:' + extension_url + |
| + 'external/media_galleries-Default-' + gallery_id + '/test.jpg'; |
| + |
| + var good_url = 'filesystem:' + extension_url + |
| + 'external/media_galleries-Default-' + extension_id + '-' + gallery_id + |
| + '/test.jpg'; |
| + |
| + chrome.test.runTests([ |
| + TestImageLoadFactory(bad_mount_point, false), |
| + TestImageLoadFactory(bad_mount_name, false), |
| + TestImageLoadFactory(good_url, true), |
| + ]); |
| +}) |