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

Unified Diff: chrome/browser/resources/file_manager/js/test_util.js

Issue 22185002: Add browser test to the sharing dialog feature in Files.app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed jsdoc. Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
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..4fc8537760ccb8779a88b625e711fd66d30be258 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 ? true : false;
yoshiki 2013/08/06 01:17:01 nit: return !!opt_inverse;
mtomasz 2013/08/06 02:02:35 Done.
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 ? false : true;
yoshiki 2013/08/06 01:17:01 nit: !opt_inverse;
mtomasz 2013/08/06 02:02:35 Done.
});
};
@@ -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 = '';

Powered by Google App Engine
This is Rietveld 408576698