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

Unified Diff: chrome/browser/resources/edit_search_engine_dialog.js

Issue 8676008: Add automated test for the edit search engine dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Consolidate tests. Created 9 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/ui/webui/edit_search_engine_dialog_webui.cc » ('j') | chrome/chrome_tests.gypi » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/edit_search_engine_dialog.js
diff --git a/chrome/browser/resources/edit_search_engine_dialog.js b/chrome/browser/resources/edit_search_engine_dialog.js
index 0d9cdb375966bb2343c7f488b399d1e0e2922773..1c3fca023d35b872819873e58d52e2edfad1ca55 100644
--- a/chrome/browser/resources/edit_search_engine_dialog.js
+++ b/chrome/browser/resources/edit_search_engine_dialog.js
@@ -6,6 +6,14 @@ cr.define('editSearchEngineDialog', function() {
'use strict';
/**
+ * Flag inidicating if we are in the process of validating input. While
+ * validating, the validity of the inputs is indeterminate.
+ * @type {boolean}
+ * @private
+ */
+ var isValidating_ = false;
+
+ /**
* Disables the controls while the dialog is busy.
*/
function disableControls() {
@@ -50,16 +58,20 @@ cr.define('editSearchEngineDialog', function() {
* by calling setValidation.
*/
function validate() {
+ isValidating_ = true;
chrome.send('requestValidation', [$('description-text').value,
$('keyword-text').value, $('url-text').value]);
}
/**
* Sets dialog state given the results of the validation of input by Chrome.
- * @param {{description: boolean, details: boolean, url: boolean, ok:boolean}}
- * details A dictionary of booleans indicating the validation results of
- * various parts of the UI. |description|, |details| and |url| indicate
- * the validity of the respective text fields, and |ok| indicates whether
+ * @param {{description: boolean,
+ keyword: boolean,
+ url: boolean,
+ ok: boolean}} details
+ * A dictionary of booleans indicating the validation results of various
+ * parts of the UI. |description|, |keyword| and |url| indicate the
+ * validity of the respective text fields, and |ok| indicates whether
* the OK/Save button can be pressed.
*/
function setValidation(details) {
@@ -67,6 +79,7 @@ cr.define('editSearchEngineDialog', function() {
setValidImage($('keyword-icon'), details.keyword);
setValidImage($('url-icon'), details.url);
$('save').disabled = !details.ok;
+ isValidating_ = false;
}
/**
@@ -108,12 +121,25 @@ cr.define('editSearchEngineDialog', function() {
setValidation({description: false, keyword: false, url: false});
if (cr.isViews)
forEach(document.querySelectorAll('.button-strip'), reverseChildren);
- chrome.send('requestDetails')
+ // Mark that we are in the process of validating, since the 'send' call
+ // is asynchronous. Until the next call to 'setValidation' complete, the
+ // validity of the inputs is in an indeterminate state.
+ isValidating_ = true;
+ chrome.send('requestDetails');
+ }
+
+ /**
+ * Indicates if we are in the process of validating input.
+ * @return {boolean} True if validation is in progress.
+ */
+ function isValidating() {
+ return isValidating_;
}
document.addEventListener('DOMContentLoaded', initialize);
return {
+ isValidating: isValidating,
setDetails: setDetails,
setValidation: setValidation,
};
« no previous file with comments | « no previous file | chrome/browser/ui/webui/edit_search_engine_dialog_webui.cc » ('j') | chrome/chrome_tests.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698