OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 cr.define('settings_test', function() { | 5 cr.define('settings_test', function() { |
6 | 6 |
7 suite('SearchSettingsTest', function() { | 7 suite('SearchSettingsTest', function() { |
8 var searchManager; | 8 var searchManager; |
9 | 9 |
10 // Don't import script if already imported (happens in Vulcanized mode). | 10 // Don't import script if already imported (happens in Vulcanized mode). |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 // highlights are cleared. | 91 // highlights are cleared. |
92 return searchManager.search('', section); | 92 return searchManager.search('', section); |
93 }).then(function() { | 93 }).then(function() { |
94 var options = select.querySelectorAll('option'); | 94 var options = select.querySelectorAll('option'); |
95 assertEquals(3, options.length); | 95 assertEquals(3, options.length); |
96 assertEquals('Foo', options[0].textContent); | 96 assertEquals('Foo', options[0].textContent); |
97 assertEquals('Settings', options[1].textContent); | 97 assertEquals('Settings', options[1].textContent); |
98 assertEquals('Baz', options[2].textContent); | 98 assertEquals('Baz', options[2].textContent); |
99 }); | 99 }); |
100 }); | 100 }); |
101 | |
102 // Test that multiple requests for the same text correctly highlight their | |
103 // corresponding part of the tree without affecting other parts of the tree. | |
104 test('multiple simultaneous requests for the same text', function() { | |
105 console.log('ssssstart test'); | |
Dan Beam
2017/03/14 00:44:28
rrrrremove
dpapad
2017/03/14 03:28:11
Done.
| |
106 document.body.innerHTML = | |
107 `<settings-section hidden-by-search> | |
108 <div><span>Hello there</span></div> | |
109 </settings-section> | |
110 <settings-section hidden-by-search> | |
111 <div><span>Hello over there</span></div> | |
112 </settings-section> | |
113 <settings-section hidden-by-search> | |
114 <div><span>Nothing</span></div> | |
115 </settings-section>`; | |
116 | |
117 var sections = Array.prototype.slice.call( | |
118 document.querySelectorAll('settings-section')); | |
119 | |
120 return Promise.all( | |
121 sections.map(function(section) { | |
122 return searchManager.search('there', section); | |
123 }), | |
124 ).then(function(requests) { | |
125 assertTrue(requests[0].didFindMatches()); | |
126 assertFalse(sections[0].hiddenBySearch); | |
127 assertTrue(requests[1].didFindMatches()); | |
128 assertFalse(sections[1].hiddenBySearch); | |
129 assertFalse(requests[2].didFindMatches()); | |
130 assertTrue(sections[2].hiddenBySearch); | |
131 }); | |
132 }); | |
101 }); | 133 }); |
102 }); | 134 }); |
OLD | NEW |