Index: chrome/test/data/webui/history_browsertest.js |
diff --git a/chrome/test/data/webui/history_browsertest.js b/chrome/test/data/webui/history_browsertest.js |
index 3cb30d2dcca6226d8b4919b81738e37fa562003e..9debe39d2ce85d86ff2cb58633fb52fdfbb4a832 100644 |
--- a/chrome/test/data/webui/history_browsertest.js |
+++ b/chrome/test/data/webui/history_browsertest.js |
@@ -193,6 +193,16 @@ function queryHistoryImpl(args, beginTime, history) { |
if (maxCount) |
results = results.slice(0, maxCount); |
+ // Search only by title in this stub. |
+ if (searchText) { |
Patrick Dubroy
2013/04/03 09:52:10
I feel like this should probably be moved to above
Sergiu
2013/04/03 13:43:39
Makes sense, fixed.
|
+ var newResults = new Array(); |
Patrick Dubroy
2013/04/03 09:52:10
Use "[]" instead of the Array constructor.
Sergiu
2013/04/03 13:43:39
Done.
|
+ for (var k = 0; k < results.length; k++) { |
+ if (results[k].title.indexOf(searchText) != -1) |
+ newResults.push(results[k]); |
+ } |
+ results = newResults; |
+ } |
+ |
var queryStartTime = ''; |
var queryEndTime = ''; |
if (results.length) { |
@@ -207,7 +217,7 @@ function queryHistoryImpl(args, beginTime, history) { |
'historyResult', |
{ |
term: searchText, |
- finished: (history.length <= i + results.length), |
+ finished: (searchText || history.length <= i + results.length), |
queryStartTime: queryStartTime, |
queryEndTime: queryEndTime |
}, |
@@ -501,6 +511,30 @@ TEST_F('HistoryWebUITest', 'multipleSelect', function() { |
testDone(); |
}); |
+TEST_F('HistoryWebUITest', 'searchHistory', function() { |
+ var getResultCount = function() { |
+ return document.querySelectorAll('.entry').length; |
+ }; |
+ // See that all the elements are there. |
+ expectEquals(RESULTS_PER_PAGE, getResultCount()); |
+ |
+ // See that the search works. |
+ $('search-field').value = 'Thu Oct 02 2008'; |
+ $('search-button').click(); |
+ |
+ waitForCallback('historyResult', function() { |
+ expectEquals(31, getResultCount()); |
+ |
+ // Clear the search. |
+ $('search-field').value = ''; |
+ $('search-button').click(); |
+ waitForCallback('historyResult', function() { |
+ expectEquals(RESULTS_PER_PAGE, getResultCount()); |
+ testDone(); |
+ }); |
+ }); |
+}); |
+ |
function setPageState(searchText, page, groupByDomain, range, offset) { |
window.location = '#' + PageState.getHashString( |
searchText, page, groupByDomain, range, offset); |