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

Side by Side Diff: chrome/test/data/extensions/api_test/media_galleries/tourl/test.js

Issue 185393012: Change media galleries to external file system type to add toURL support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add test for URL access Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 function check_result_factory(expected) {
Lei Zhang 2014/03/20 21:37:53 This might be useful in other tests. Maybe move to
6 return function() {
7 if (expected) {
8 chrome.test.succeed();
9 } else {
10 chrome.test.fail();
11 }
12 };
13 }
14
15 function TestImageLoadFactory(url, should_load) {
16 return function() {
17 test_image = document.createElement('img');
18 document.body.appendChild(test_image);
19 test_image.addEventListener('load', check_result_factory(should_load));
20 test_image.addEventListener('error', check_result_factory(!should_load));
21
22 test_image.src = url;
23 };
24 }
25
26 CreateDummyWindowToPreventSleep();
27
28 chrome.test.getConfig(function(config) {
29 var customArg = JSON.parse(config.customArg);
30 var gallery_id = customArg[0];
31 var extension_url = chrome.runtime.getURL('/');
32 var extension_id = extension_url.split('/')[2];
33
34 var bad_mount_point = 'filesystem:' + extension_url +
35 'external/invalid-Default-' + extension_id + '-' + gallery_id + '/test.jpg';
36
37 var bad_mount_name = 'filesystem:' + extension_url +
38 'external/media_galleries-Default-' + gallery_id + '/test.jpg';
39
40 var good_url = 'filesystem:' + extension_url +
41 'external/media_galleries-Default-' + extension_id + '-' + gallery_id +
42 '/test.jpg';
43
44 chrome.test.runTests([
45 TestImageLoadFactory(bad_mount_point, false),
46 TestImageLoadFactory(bad_mount_name, false),
47 TestImageLoadFactory(good_url, true),
48 ]);
49 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698