| Index: chrome/browser/resources/file_manager/js/test_util.js
|
| diff --git a/chrome/browser/resources/file_manager/js/test_util.js b/chrome/browser/resources/file_manager/js/test_util.js
|
| index 07005a3d7d85d155382ded3981e8209e0e68a3d7..450ff90da871534cf1ca84344ca6378140c48009 100644
|
| --- a/chrome/browser/resources/file_manager/js/test_util.js
|
| +++ b/chrome/browser/resources/file_manager/js/test_util.js
|
| @@ -221,18 +221,20 @@ test.util.async.waitForWindowGeometry = function(
|
| * @param {Window} contentWindow Window to be tested.
|
| * @param {string} targetQuery Query to specify the element.
|
| * @param {?string} iframeQuery Iframe selector or null if no iframe.
|
| + * @param {boolean=} opt_inverse True if the function should return if the
|
| + * element disappears, instead of appearing.
|
| * @param {function(Object)} callback Callback with a hash array of attributes
|
| * and contents as text.
|
| */
|
| test.util.async.waitForElement = function(
|
| - contentWindow, targetQuery, iframeQuery, callback) {
|
| + contentWindow, targetQuery, iframeQuery, opt_inverse, callback) {
|
| test.util.repeatUntilTrue_(function() {
|
| var doc = test.util.sync.getDocument_(contentWindow, iframeQuery);
|
| if (!doc)
|
| return false;
|
| var element = doc.querySelector(targetQuery);
|
| if (!element)
|
| - return false;
|
| + return !!opt_inverse;
|
| var attributes = {};
|
| for (var i = 0; i < element.attributes.length; i++) {
|
| attributes[element.attributes[i].nodeName] =
|
| @@ -240,7 +242,7 @@ test.util.async.waitForElement = function(
|
| }
|
| var text = element.textContent;
|
| callback({attributes: attributes, text: text});
|
| - return true;
|
| + return !opt_inverse;
|
| });
|
| };
|
|
|
| @@ -441,6 +443,21 @@ test.util.async.waitForFiles = function(
|
| };
|
|
|
| /**
|
| + * Executes Javascript code on a webview and returns the result.
|
| + *
|
| + * @param {Window} contentWindow Window to be tested.
|
| + * @param {string} webViewQuery Selector for the web view.
|
| + * @param {string} code Javascript code to be executed within the web view.
|
| + * @param {function(*)} callback Callback function with results returned by the
|
| + * script.
|
| + */
|
| +test.util.async.executeScriptInWebView = function(
|
| + contentWindow, webViewQuery, code, callback) {
|
| + var webView = contentWindow.document.querySelector(webViewQuery);
|
| + webView.executeScript({code: code}, callback);
|
| +};
|
| +
|
| +/**
|
| * Sends an event to the element specified by |targetQuery|.
|
| *
|
| * @param {Window} contentWindow Window to be tested.
|
| @@ -663,6 +680,9 @@ test.util.registerRemoteTestUtils = function() {
|
| console.error('The testing extension must be white-listed.');
|
| return false;
|
| }
|
| + // Set a global flag that we are in tests, so other components are aware
|
| + // of it.
|
| + window.IN_TEST = true;
|
| // Check the function name.
|
| if (!request.func || request.func[request.func.length - 1] == '_') {
|
| request.func = '';
|
|
|