| OLD | NEW |
| 1 // To ensure that no GC-able resources from other tests upset | 1 // To ensure that no GC-able resources from other tests upset |
| 2 // expectations, perform an initial GC. | 2 // expectations, perform an initial GC. |
| 3 if (window.GCController) | 3 if (window.GCController) |
| 4 GCController.collect(); | 4 GCController.collect(); |
| 5 | 5 |
| 6 var initialize_SearchTest = function() { | 6 var initialize_SearchTest = function() { |
| 7 InspectorTest.dumpSearchResults = function(searchResults) | 7 InspectorTest.dumpSearchResults = function(searchResults) |
| 8 { | 8 { |
| 9 function comparator(a, b) | 9 function comparator(a, b) |
| 10 { | 10 { |
| 11 a.url.localeCompare(b.url); | 11 a.url.localeCompare(b.url); |
| 12 } | 12 } |
| 13 searchResults.sort(comparator); | 13 searchResults.sort(comparator); |
| 14 | 14 |
| 15 InspectorTest.addResult("Search results: "); | 15 InspectorTest.addResult("Search results: "); |
| 16 for (var i = 0; i < searchResults.length; i++) | 16 for (var i = 0; i < searchResults.length; i++) |
| 17 InspectorTest.addResult("url: " + searchResults[i].url.replace(/VM\d+/,
"VMXX") + ", matchesCount: " + searchResults[i].matchesCount); | 17 InspectorTest.addResult("url: " + searchResults[i].url.replace(/VM\d+/,
"VMXX") + ", matchesCount: " + searchResults[i].matchesCount); |
| 18 InspectorTest.addResult(""); | 18 InspectorTest.addResult(""); |
| 19 }; | 19 }; |
| 20 | 20 |
| 21 InspectorTest.dumpSearchMatches = function(searchMatches) | 21 InspectorTest.dumpSearchMatches = function(searchMatches) |
| 22 { | 22 { |
| 23 InspectorTest.addResult("Search matches: "); | 23 InspectorTest.addResult("Search matches: "); |
| 24 for (var i = 0; i < searchMatches.length; i++) | 24 for (var i = 0; i < searchMatches.length; i++) |
| 25 InspectorTest.addResult("lineNumber: " + searchMatches[i].lineNumber + "
, line: '" + searchMatches[i].lineContent + "'"); | 25 InspectorTest.addResult("lineNumber: " + searchMatches[i].lineNumber + "
, line: '" + searchMatches[i].lineContent + "'"); |
| 26 InspectorTest.addResult(""); | 26 InspectorTest.addResult(""); |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 InspectorTest.runSearchAndDumpResults = function(scope, searchConfig, sortByURI,
callback) | 29 InspectorTest.runSearchAndDumpResults = function(scope, searchConfig, callback) |
| 30 { | 30 { |
| 31 var searchResults = []; | 31 var searchResults = []; |
| 32 var progress = new Common.Progress(); | 32 var progress = new Common.Progress(); |
| 33 scope.performSearch(searchConfig, progress, searchResultCallback, searchFini
shedCallback); | 33 scope.performSearch(searchConfig, progress, searchResultCallback, searchFini
shedCallback); |
| 34 | 34 |
| 35 function searchResultCallback(searchResult) | 35 function searchResultCallback(searchResult) |
| 36 { | 36 { |
| 37 searchResults.push(searchResult); | 37 searchResults.push(searchResult); |
| 38 } | 38 } |
| 39 | 39 |
| 40 function searchFinishedCallback() | 40 function searchFinishedCallback() |
| 41 { | 41 { |
| 42 function comparator(searchResultA, searchResultB) | 42 function comparator(searchResultA, searchResultB) |
| 43 { | 43 { |
| 44 return searchResultA.uiSourceCode.url().compareTo(searchResultB.uiSo
urceCode.url()); | 44 return searchResultA.uiSourceCode.url().compareTo(searchResultB.uiSo
urceCode.url()); |
| 45 } | 45 } |
| 46 if (sortByURI) | 46 searchResults.sort(comparator); |
| 47 searchResults.sort(comparator); | |
| 48 | 47 |
| 49 for (var i = 0; i < searchResults.length; ++i) { | 48 for (var i = 0; i < searchResults.length; ++i) { |
| 50 var searchResult = searchResults[i]; | 49 var searchResult = searchResults[i]; |
| 51 var uiSourceCode = searchResult.uiSourceCode; | 50 var uiSourceCode = searchResult.uiSourceCode; |
| 52 var searchMatches = searchResult.searchMatches; | 51 var searchMatches = searchResult.searchMatches; |
| 53 | 52 |
| 54 if (!searchMatches.length) | 53 if (!searchMatches.length) |
| 55 continue; | 54 continue; |
| 56 InspectorTest.addResult("Search result #" + (i + 1) + ": uiSourceCod
e.url = " + uiSourceCode.url().replace(/VM\d+/, "VMXX")); | 55 InspectorTest.addResult("Search result #" + (i + 1) + ": uiSourceCod
e.url = " + uiSourceCode.url().replace(/VM\d+/, "VMXX")); |
| 57 for (var j = 0; j < searchMatches.length; ++j) { | 56 for (var j = 0; j < searchMatches.length; ++j) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 ++postfixLength; | 113 ++postfixLength; |
| 115 var prefix = oldLine.substring(0, prefixLength); | 114 var prefix = oldLine.substring(0, prefixLength); |
| 116 var removed = oldLine.substring(prefixLength, oldLine.length - postfixLe
ngth); | 115 var removed = oldLine.substring(prefixLength, oldLine.length - postfixLe
ngth); |
| 117 var added = newLine.substring(prefixLength, newLine.length - postfixLeng
th); | 116 var added = newLine.substring(prefixLength, newLine.length - postfixLeng
th); |
| 118 var postfix = oldLine.substring(oldLine.length - postfixLength); | 117 var postfix = oldLine.substring(oldLine.length - postfixLength); |
| 119 InspectorTest.addResult(" - " + prefix + "#" + removed + "#" + added +
"#" + postfix); | 118 InspectorTest.addResult(" - " + prefix + "#" + removed + "#" + added +
"#" + postfix); |
| 120 } | 119 } |
| 121 } | 120 } |
| 122 | 121 |
| 123 }; | 122 }; |
| OLD | NEW |