| OLD | NEW |
| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 row.querySelector('.size').textContent, | 150 row.querySelector('.size').textContent, |
| 151 row.querySelector('.type').textContent, | 151 row.querySelector('.type').textContent, |
| 152 row.querySelector('.date').textContent | 152 row.querySelector('.date').textContent |
| 153 ]); | 153 ]); |
| 154 } | 154 } |
| 155 fileList.sort(); | 155 fileList.sort(); |
| 156 return fileList; | 156 return fileList; |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 /** | 159 /** |
| 160 * Waits until the window is set to the specified dimensions. |
| 161 * |
| 162 * @param {Window} contentWindow Window to be tested. |
| 163 * @param {number} width Requested width. |
| 164 * @param {number} height Requested height. |
| 165 * @param {function(Object)} callback Success callback with the dimensions. |
| 166 */ |
| 167 test.util.waitForWindowGeometry = function( |
| 168 contentWindow, width, height, callback) { |
| 169 function helper() { |
| 170 if (contentWindow.innerWidth == width && |
| 171 contentWindow.innerHeight == height) { |
| 172 callback({width: width, height: height}); |
| 173 return; |
| 174 } |
| 175 window.setTimeout(helper, 50); |
| 176 } |
| 177 helper(); |
| 178 }; |
| 179 |
| 180 /** |
| 160 * Waits for an element and returns it as an array of it's attributes. | 181 * Waits for an element and returns it as an array of it's attributes. |
| 161 * | 182 * |
| 162 * @param {Window} contentWindow Window to be tested. | 183 * @param {Window} contentWindow Window to be tested. |
| 163 * @param {string} targetQuery Query to specify the element. | 184 * @param {string} targetQuery Query to specify the element. |
| 164 * @param {?string} iframeQuery Iframe selector or null if no iframe. | 185 * @param {?string} iframeQuery Iframe selector or null if no iframe. |
| 165 * @param {function(Object)} callback Callback with a hash array of attributes | 186 * @param {function(Object)} callback Callback with a hash array of attributes |
| 166 * and contents as text. | 187 * and contents as text. |
| 167 */ | 188 */ |
| 168 test.util.waitForElement = function( | 189 test.util.waitForElement = function( |
| 169 contentWindow, targetQuery, iframeQuery, callback) { | 190 contentWindow, targetQuery, iframeQuery, callback) { |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 case 'resizeWindow': | 543 case 'resizeWindow': |
| 523 sendResponse(test.util.resizeWindow( | 544 sendResponse(test.util.resizeWindow( |
| 524 contentWindow, request.args[0], request.args[1])); | 545 contentWindow, request.args[0], request.args[1])); |
| 525 return false; | 546 return false; |
| 526 case 'getSelectedFiles': | 547 case 'getSelectedFiles': |
| 527 sendResponse(test.util.getSelectedFiles(contentWindow)); | 548 sendResponse(test.util.getSelectedFiles(contentWindow)); |
| 528 return false; | 549 return false; |
| 529 case 'getFileList': | 550 case 'getFileList': |
| 530 sendResponse(test.util.getFileList(contentWindow)); | 551 sendResponse(test.util.getFileList(contentWindow)); |
| 531 return false; | 552 return false; |
| 553 case 'waitForWindowGeometry': |
| 554 test.util.waitForWindowGeometry( |
| 555 contentWindow, request.args[0], request.args[1], sendResponse); |
| 556 return true; |
| 532 case 'waitForElement': | 557 case 'waitForElement': |
| 533 test.util.waitForElement( | 558 test.util.waitForElement( |
| 534 contentWindow, request.args[0], request.args[1], sendResponse); | 559 contentWindow, request.args[0], request.args[1], sendResponse); |
| 535 return true; | 560 return true; |
| 536 case 'performAutocompleteAndWait': | 561 case 'performAutocompleteAndWait': |
| 537 test.util.performAutocompleteAndWait( | 562 test.util.performAutocompleteAndWait( |
| 538 contentWindow, request.args[0], request.args[1], sendResponse); | 563 contentWindow, request.args[0], request.args[1], sendResponse); |
| 539 return true; | 564 return true; |
| 540 case 'waitForFileListChange': | 565 case 'waitForFileListChange': |
| 541 test.util.waitForFileListChange( | 566 test.util.waitForFileListChange( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 default: | 604 default: |
| 580 console.error('Window function ' + request.func + ' not found.'); | 605 console.error('Window function ' + request.func + ' not found.'); |
| 581 } | 606 } |
| 582 } | 607 } |
| 583 return false; | 608 return false; |
| 584 }); | 609 }); |
| 585 }; | 610 }; |
| 586 | 611 |
| 587 // Register the test utils. | 612 // Register the test utils. |
| 588 test.util.registerRemoteTestUtils(); | 613 test.util.registerRemoteTestUtils(); |
| OLD | NEW |