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

Unified Diff: chrome/browser/resources/settings/settings_main/settings_main.js

Issue 2185493003: MD Settings: Adding some unit tests for <settings-main>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@search_no_results
Patch Set: Address comments. Created 4 years, 5 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/settings/settings_main/settings_main.js
diff --git a/chrome/browser/resources/settings/settings_main/settings_main.js b/chrome/browser/resources/settings/settings_main/settings_main.js
index d9c65784fda9f8a9bd4079fcc57ebc866a2c3572..6f1ff0f69021d9d507243e845ee8c9fc6da16d3f 100644
--- a/chrome/browser/resources/settings/settings_main/settings_main.js
+++ b/chrome/browser/resources/settings/settings_main/settings_main.js
@@ -176,6 +176,7 @@ Polymer({
/**
* @param {string} query
+ * @return {!Promise} A promise indicating that searching finished.
*/
searchContents: function(query) {
this.ensureInDefaultSearchPage_();
@@ -184,26 +185,31 @@ Polymer({
// Trigger rendering of the basic and advanced pages and search once ready.
this.showPages_ = {about: false, basic: true, advanced: true};
- setTimeout(function() {
- settings.getSearchManager().search(
- query, assert(this.$$('settings-basic-page')));
- }.bind(this), 0);
- setTimeout(function() {
- settings.getSearchManager().search(
- query, assert(this.$$('settings-advanced-page'))).then(
- function(request) {
- if (!request.finished) {
- // Nothing to do here. A previous search request was canceled
- // because a new search request was issued before the first one
- // completed.
- return;
- }
-
- this.toolbarSpinnerActive = false;
- this.showNoResultsFound_ =
- !request.isSame('') && !request.didFindMatches();
- }.bind(this));
- }.bind(this), 0);
+ return new Promise(function(resolve, reject) {
+ setTimeout(function() {
+ var whenSearchDone = settings.getSearchManager().search(
+ query, assert(this.$$('settings-basic-page')));
+ assert(
+ whenSearchDone ===
+ settings.getSearchManager().search(
michaelpg 2016/08/02 20:45:20 is this indent ok?
dpapad 2016/08/02 22:33:15 Fixed.
+ query, assert(this.$$('settings-advanced-page'))));
+
+ whenSearchDone.then(
michaelpg 2016/08/02 20:45:20 perhaps join with the next line to save precious w
dpapad 2016/08/02 22:33:15 Done. I don't mind either way.
+ function(request) {
+ resolve();
+ if (!request.finished) {
+ // Nothing to do here. A previous search request was canceled
+ // because a new search request was issued before the first one
+ // completed.
+ return;
+ }
+
+ this.toolbarSpinnerActive = false;
+ this.showNoResultsFound_ =
+ !request.isSame('') && !request.didFindMatches();
+ }.bind(this));
+ }.bind(this), 0);
+ }.bind(this));
},
/**

Powered by Google App Engine
This is Rietveld 408576698