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

Unified Diff: chrome/test/data/webui/cr_elements/cr_toolbar_search_field_tests.js

Issue 2447973002: CrSearchFieldBehavior: Fix case where infinite 'search-changed' events are fired. (Closed)
Patch Set: Nit. Created 4 years, 2 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
« no previous file with comments | « no previous file | ui/webui/resources/cr_elements/cr_search_field/cr_search_field_behavior.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/cr_elements/cr_toolbar_search_field_tests.js
diff --git a/chrome/test/data/webui/cr_elements/cr_toolbar_search_field_tests.js b/chrome/test/data/webui/cr_elements/cr_toolbar_search_field_tests.js
index 750560cde7b5003d83fa28c98371400fd4d688fd..85ba39401be603932f8d5348c952885d27a37692 100644
--- a/chrome/test/data/webui/cr_elements/cr_toolbar_search_field_tests.js
+++ b/chrome/test/data/webui/cr_elements/cr_toolbar_search_field_tests.js
@@ -93,6 +93,23 @@ cr.define('cr_toolbar_search_field', function() {
assertEquals(['foo', '', 'bar', 'baz'].join(), searches.join());
});
+ // Tests that calling setValue() from within a 'search-changed' callback
+ // does not result in an infinite loop.
+ test('no infinite loop', function() {
+ var counter = 0;
+ field.addEventListener('search-changed', function(event) {
+ counter++;
+ // Calling setValue() with the already existing value should not
+ // trigger another 'search-changed' event.
+ field.setValue(event.detail);
+ });
+
+ MockInteractions.tap(field);
+ field.setValue('bar');
+ assertEquals(1, counter);
+ assertEquals(['bar'].join(), searches.join());
+ });
+
test('blur does not close field when a search is active', function() {
MockInteractions.tap(field);
simulateSearch('test');
« no previous file with comments | « no previous file | ui/webui/resources/cr_elements/cr_search_field/cr_search_field_behavior.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698