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

Side by Side Diff: chrome/browser/resources/file_manager/js/test_util.js

Issue 14367009: Fix Javascript errors occuring when a file is deleted during calculating it's size. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments. Created 7 years, 8 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
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 /** 5 /**
6 * Namespace for test related things. 6 * Namespace for test related things.
7 */ 7 */
8 var test = test || {}; 8 var test = test || {};
9 9
10 /** 10 /**
(...skipping 25 matching lines...) Expand all
36 callback(appId); 36 callback(appId);
37 return; 37 return;
38 } 38 }
39 } 39 }
40 window.setTimeout(helper, 50); 40 window.setTimeout(helper, 50);
41 } 41 }
42 helper(); 42 helper();
43 }; 43 };
44 44
45 /** 45 /**
46 * Gets total Javascript error count from each app window.
47 * @return {number} Error count.
48 */
49 test.util.getErrorCount = function() {
50 var totalCount = 0;
51 for (var appId in appWindows) {
52 var contentWindow = appWindows[appId].contentWindow;
53 if (contentWindow.JSErrorCount)
54 totalCount += contentWindow.JSErrorCount;
55 }
56 return totalCount;
57 };
58
59 /**
46 * Returns an array with the files currently selected in the file manager. 60 * Returns an array with the files currently selected in the file manager.
47 * 61 *
48 * @param {Window} contentWindow Window to be tested. 62 * @param {Window} contentWindow Window to be tested.
49 * @return {Array.<string>} Array of selected files. 63 * @return {Array.<string>} Array of selected files.
50 */ 64 */
51 test.util.getSelectedFiles = function(contentWindow) { 65 test.util.getSelectedFiles = function(contentWindow) {
52 var table = contentWindow.document.querySelector('#detail-table'); 66 var table = contentWindow.document.querySelector('#detail-table');
53 var rows = table.querySelectorAll('li'); 67 var rows = table.querySelectorAll('li');
54 var selected = []; 68 var selected = [];
55 for (var i = 0; i < rows.length; ++i) { 69 for (var i = 0; i < rows.length; ++i) {
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 return false; 314 return false;
301 } 315 }
302 contentWindow = appWindows[request.appId].contentWindow; 316 contentWindow = appWindows[request.appId].contentWindow;
303 } 317 }
304 if (!contentWindow) { 318 if (!contentWindow) {
305 // Global functions, not requiring a window. 319 // Global functions, not requiring a window.
306 switch (request.func) { 320 switch (request.func) {
307 case 'openMainWindow': 321 case 'openMainWindow':
308 test.util.openMainWindow(request.args[0], sendResponse); 322 test.util.openMainWindow(request.args[0], sendResponse);
309 return true; 323 return true;
324 case 'getErrorCount':
325 sendResponse(test.util.getErrorCount());
326 return true;
310 default: 327 default:
311 console.error('Global function ' + request.func + ' not found.'); 328 console.error('Global function ' + request.func + ' not found.');
312 } 329 }
313 } else { 330 } else {
314 // Functions working on a window. 331 // Functions working on a window.
315 switch (request.func) { 332 switch (request.func) {
316 case 'getSelectedFiles': 333 case 'getSelectedFiles':
317 sendResponse(test.util.getSelectedFiles(contentWindow)); 334 sendResponse(test.util.getSelectedFiles(contentWindow));
318 return false; 335 return false;
319 case 'getFileList': 336 case 'getFileList':
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 default: 369 default:
353 console.error('Window function ' + request.func + ' not found.'); 370 console.error('Window function ' + request.func + ' not found.');
354 } 371 }
355 } 372 }
356 return false; 373 return false;
357 }); 374 });
358 }; 375 };
359 376
360 // Register the test utils. 377 // Register the test utils.
361 test.util.registerRemoteTestUtils(); 378 test.util.registerRemoteTestUtils();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698