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 document.body.innerHTML = |
| 106 `<settings-section hidden-by-search> |
| 107 <div><span>Hello there</span></div> |
| 108 </settings-section> |
| 109 <settings-section hidden-by-search> |
| 110 <div><span>Hello over there</span></div> |
| 111 </settings-section> |
| 112 <settings-section hidden-by-search> |
| 113 <div><span>Nothing</span></div> |
| 114 </settings-section>`; |
| 115 |
| 116 var sections = Array.prototype.slice.call( |
| 117 document.querySelectorAll('settings-section')); |
| 118 |
| 119 return Promise.all( |
| 120 sections.map(function(section) { |
| 121 return searchManager.search('there', section); |
| 122 }), |
| 123 ).then(function(requests) { |
| 124 assertTrue(requests[0].didFindMatches()); |
| 125 assertFalse(sections[0].hiddenBySearch); |
| 126 assertTrue(requests[1].didFindMatches()); |
| 127 assertFalse(sections[1].hiddenBySearch); |
| 128 assertFalse(requests[2].didFindMatches()); |
| 129 assertTrue(sections[2].hiddenBySearch); |
| 130 }); |
| 131 }); |
101 }); | 132 }); |
102 }); | 133 }); |
OLD | NEW |