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..43baf0f8fd3798b2d37d74035af8f8c8ee16a0ae |
--- /dev/null |
+++ b/chrome/test/data/extensions/api_test/media_galleries/tourl/test.js |
@@ -0,0 +1,51 @@ |
+// 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) { |
+ 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 profile_path = customArg[1]; |
+ var extension_url = chrome.runtime.getURL('/'); |
+ var extension_id = extension_url.split('/')[2]; |
+ |
+ var bad_mount_point = 'filesystem:' + extension_url + |
+ 'external/invalid-' + profile_path + '-' + extension_id + '-' + gallery_id + |
+ '/test.jpg'; |
+ |
+ var bad_mount_name = 'filesystem:' + extension_url + |
+ 'external/media_galleries-' + profile_path + '-' + gallery_id + '/test.jpg'; |
+ |
+ var good_url = 'filesystem:' + extension_url + |
+ 'external/media_galleries-' + profile_path + '-' + extension_id + '-' + |
+ gallery_id + '/test.jpg'; |
+ |
+ chrome.test.runTests([ |
+ TestImageLoadFactory(bad_mount_point, false), |
+ TestImageLoadFactory(bad_mount_name, false), |
+ TestImageLoadFactory(good_url, true), |
+ ]); |
+}) |