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

Side by Side Diff: chrome/test/data/webui/settings/search_settings_test.js

Issue 2454023002: MD Settings: Fix <select> search highlighting. (Closed)
Patch Set: Fix browserPreload path. Created 4 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 unified diff | Download patch
« no previous file with comments | « chrome/test/data/webui/settings/cr_settings_browsertest.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 cr.define('settings_test', function() {
6 var searchManager = settings.getSearchManager();
7
8 suite('SearchSettingsTest', function() {
9 setup(function() {
10 PolymerTest.clearBody();
11 });
12
13 /*
Dan Beam 2016/10/27 21:24:53 /**
dpapad 2016/10/27 21:35:37 Done. Technically this is only needed if you have
14 * Test that the DOM of a node is modified as expected when a search hit
15 * occurs within that node.
16 */
17 test('normal highlighting', function() {
18 var textBefore = 'FooSettingsFoo';
19 var htmlBefore = document.body.innerHTML =
Dan Beam 2016/10/27 21:24:53 why are you changing document.body's innerHTML rat
dpapad 2016/10/27 21:35:37 Removed. It was an accidental leftover of a previo
20 `<settings-section hidden-by-search>
Dan Beam 2016/10/27 21:24:53 why are you adding hidden-by-search and checking i
dpapad 2016/10/27 21:35:37 Well, for two reasons. a) If I don't add it, then
21 <div id="mydiv">${textBefore}</div>
22 </settings-section>`;
23
24 document.body.innerHTML = htmlBefore;
Dan Beam 2016/10/27 21:24:53 what is all this assignment devilry?
dpapad 2016/10/27 21:35:37 Fixed.
25
26 var section = document.querySelector('settings-section');
27 var div = section.queryEffectiveChildren('#mydiv');
28
29 assertTrue(section.hiddenBySearch);
30 return searchManager.search('settings', section).then(function() {
31 assertFalse(section.hiddenBySearch);
32
33 var highlighWrapper = div.querySelector('.search-highlight-wrapper');
34 assertTrue(!!highlighWrapper);
35
36 var originalContent = highlighWrapper.querySelector(
37 '.search-highlight-original-content');
38 assertTrue(!!originalContent);
39 assertEquals(textBefore, originalContent.textContent);
40
41 var searchHits = highlighWrapper.querySelectorAll(
42 '.search-highlight-hit');
43 assertEquals(1, searchHits.length);
44 assertEquals('Settings', searchHits[0].textContent);
45
46 // Check that original DOM structure is restored when search
47 // highlights are cleared.
48 return searchManager.search('', section);
49 }).then(function() {
50 assertEquals(0, div.children.length);
51 assertEquals(textBefore, div.textContent);
52 });
53 });
54
55
56 /*
Dan Beam 2016/10/27 21:24:53 same
dpapad 2016/10/27 21:35:37 Done.
57 * Tests that a search hit within a <select> node causes the parent
58 * settings-section to be shown, but the DOM of the <select> is not
59 * modified.
60 */
61 test('<select> highlighting', function() {
62 PolymerTest.clearBody();
Dan Beam 2016/10/27 21:24:53 why do this if it's already done in setup?
dpapad 2016/10/27 21:35:37 Removed.
63 document.body.innerHTML =
64 `<settings-section hidden-by-search>
65 <select>
66 <option>Foo</option>
67 <option>Settings</option>
68 <option>Baz</option>
69 </select>
70 </settings-section>`;
71
72 var section = document.querySelector('settings-section');
73 var select = section.querySelector('select');
74
75 assertTrue(section.hiddenBySearch);
76 return searchManager.search('settings', section).then(function() {
77 assertFalse(section.hiddenBySearch);
78
79 var highlighWrapper = select.querySelector(
Dan Beam 2016/10/27 21:24:53 highlightWrapper
80 '.search-highlight-wrapper');
81 assertFalse(!!highlighWrapper);
82
83 // Check that original DOM structure is present even after search
84 // highlights are cleared.
85 return searchManager.search('', section);
86 }).then(function() {
87 var options = select.querySelectorAll('option');
88 assertEquals(3, options.length);
89 assertEquals('Foo', options[0].textContent);
90 assertEquals('Settings', options[1].textContent);
91 assertEquals('Baz', options[2].textContent);
92 });
93 });
94 });
95 });
OLDNEW
« no previous file with comments | « chrome/test/data/webui/settings/cr_settings_browsertest.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698