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

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

Issue 2458113003: Prevent bogus 'search-changed' event firing from cr_search_field_behavior.js. (Closed)
Patch Set: ? -> undefined 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 85ba39401be603932f8d5348c952885d27a37692..48107ee2a51565afec2e32c5afdcafdfae1d31c2 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
@@ -34,6 +34,23 @@ cr.define('cr_toolbar_search_field', function() {
searches = null;
});
+ // Test that no initial 'search-changed' event is fired during
+ // construction and initialization of the cr-toolbar-search-field element.
+ test('no initial search-changed event', function() {
+ var didFire = false;
+ var onSearchChanged = function () { didFire = true; };
+
+ // Need to attach listener event before the element is created, to catch
+ // the unnecessary initial event.
+ document.body.addEventListener('search-changed', onSearchChanged);
+ document.body.innerHTML =
+ '<cr-toolbar-search-field></cr-toolbar-search-field>';
+ // Remove event listener on |body| so that other tests are not affected.
+ document.body.removeEventListener('search-changed', onSearchChanged);
+
+ assertFalse(didFire, 'Should not have fired search-changed event');
+ });
+
test('opens and closes correctly', function() {
assertFalse(field.showingSearch);
MockInteractions.tap(field);
« 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