Commit 65319920 authored by vsevik@chromium.org's avatar vsevik@chromium.org
Browse files

Web Inspector: Open resource dialog has too many false positive matches.

https://bugs.webkit.org/show_bug.cgi?id=97332

Reviewed by Alexander Pavlov.

Source/WebCore:

Improved open resource dialog filtering to make the amount of false
positive search results less.

* inspector/front-end/FilteredItemSelectionDialog.js:
(WebInspector.FilteredItemSelectionDialog.prototype._innerCreateSearchRegExp):
(WebInspector.FilteredItemSelectionDialog.prototype._highlightItem.get var):
(WebInspector.FilteredItemSelectionDialog.prototype._highlightItem):

LayoutTests:

* inspector/filtered-item-selection-dialog-filtering-expected.txt:
* inspector/filtered-item-selection-dialog-filtering.html:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@129355 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c00cb112
2012-09-24 Vsevolod Vlasov <vsevik@chromium.org>
Web Inspector: Open resource dialog has too many false positive matches.
https://bugs.webkit.org/show_bug.cgi?id=97332
Reviewed by Alexander Pavlov.
* inspector/filtered-item-selection-dialog-filtering-expected.txt:
* inspector/filtered-item-selection-dialog-filtering.html:
2012-09-24 Christophe Dumez <christophe.dumez@intel.com>
 
[EFL] Rebaseline several test cases in Skipped list
Check to see that FilteredItemSelectionDialog uses proper regex to filter results.
{
input : [
"a"
"bc"
]
output : [
"a"
"bc"
]
input : "["a","bc"]"
output : "["a","bc"]"
query : ""
title : "Empty query matches everything"
}
{
input : [
"abc"
"acB"
]
output : [
"acB"
]
input : "["abc","acB"]"
output : "["acB"]"
query : "aB"
title : "Case sensitive matching"
}
{
input : [
"abc"
"bac"
"a_B"
]
output : [
"abc"
"a_B"
]
input : "["abc","bac","a_B"]"
output : "["abc"]"
query : "ab"
title : "Case insensitive matching"
}
{
input : [
"div .visible"
"div.visible "
]
output : [
"div .visible"
]
query : "d v "
title : "Spaces in query"
input : "["div .visible","div . visible "]"
output : "["div .visible"]"
query : "d.v "
title : "Spaces in the input"
}
{
input : [
"abab"
"abaa"
"caab"
"baac"
]
output : [
"abab"
"caab"
]
input : "["abab","abaa","caab","baac","fooaab"]"
output : "[]"
query : "aab"
title : "Duplicate symbols in query"
}
{
input : [
"^[]{}()\.$*+?|"
"0123456789abcdef"
]
output : [
"^[]{}()\.$*+?|"
]
input : "["abab","abaa","caab","baac","fooaab"]"
output : "["caab","fooaab"]"
query : "*aab"
title : "Star in query"
}
{
input : "["abab","abaa","caab","baac","fooaab"]"
output : "["caab"]"
query : "?aab"
title : "Question in query"
}
{
input : "["^[]{}()\\.$*+?|","0123456789abcdef"]"
output : "["^[]{}()\\.$*+?|"]"
query : "^[]{}()\.$*+?|"
title : "Dangerous input escaping"
}
{
input : "["fooBarBaz","FooBarBaz","Foo_Bar_Baz","foo_bar_baz","foobarbaz","foobarBaz","afooBarBaz","aFooBarBaz","a fooBarBaz","fooBorBaz","fooBorCaz"]"
output : "["fooBarBaz"]"
query : "fBaB"
title : "Camel case matching"
}
{
input : "["foOBarBaz","FoOBarBaz","FoO_Bar_Baz","foO_bar_baz","foObarbaz","foObarBaz","afoOBarBaz","aFoOBarBaz","a foOBarBaz","foOBorBaz","foOBorCaz"]"
output : "["foO_bar_baz"]"
query : "fO_ba_b"
title : "Underscore matching"
}
{
input : "["foo_bar","FB","foobar","fBar"]"
output : "["FB","fBar"]"
query : "fb"
title : "Case insensitive matching"
}
{
input : "["foo_bar","FOO_BAR","Foo_Bar","fOo_bAr"]"
output : "["foo_bar","FOO_BAR","Foo_Bar","fOo_bAr"]"
query : "f_b"
title : "Case insensitive underscore matching"
}
......@@ -21,17 +21,23 @@ function test()
InspectorTest.addObject({
title: title,
query: query,
input: input,
output: output
input: JSON.stringify(input),
output: JSON.stringify(output)
});
}
checkQuery("Empty query matches everything", "", ["a", "bc"]);
checkQuery("Case sensitive matching", "aB", ["abc", "acB"]);
checkQuery("Case insensitive matching", "ab", ["abc", "bac", "a_B"]);
checkQuery("Spaces in query", "d v ", ["div .visible", "div.visible "]);
checkQuery("Duplicate symbols in query", "aab", ["abab", "abaa", "caab", "baac"]);
checkQuery("Spaces in the input", "d.v ", ["div .visible", "div . visible "]);
checkQuery("Duplicate symbols in query", "aab", ["abab", "abaa", "caab", "baac", "fooaab"]);
checkQuery("Star in query", "*aab", ["abab", "abaa", "caab", "baac", "fooaab"]);
checkQuery("Question in query", "?aab", ["abab", "abaa", "caab", "baac", "fooaab"]);
checkQuery("Dangerous input escaping", "^[]{}()\\.$*+?|", ["^[]{}()\\.$*+?|", "0123456789abcdef"]);
checkQuery("Camel case matching", "fBaB", ["fooBarBaz", "FooBarBaz", "Foo_Bar_Baz", "foo_bar_baz", "foobarbaz", "foobarBaz", "afooBarBaz", "aFooBarBaz", "a fooBarBaz", "fooBorBaz", "fooBorCaz"]);
checkQuery("Underscore matching", "fO_ba_b", ["foOBarBaz", "FoOBarBaz", "FoO_Bar_Baz", "foO_bar_baz", "foObarbaz", "foObarBaz", "afoOBarBaz", "aFoOBarBaz", "a foOBarBaz", "foOBorBaz", "foOBorCaz"]);
checkQuery("Case insensitive matching", "fb", ["foo_bar", "FB", "foobar", "fBar"]);
checkQuery("Case insensitive underscore matching", "f_b", ["foo_bar", "FOO_BAR", "Foo_Bar", "fOo_bAr"]);
InspectorTest.completeTest();
}
......
2012-09-24 Vsevolod Vlasov <vsevik@chromium.org>
Web Inspector: Open resource dialog has too many false positive matches.
https://bugs.webkit.org/show_bug.cgi?id=97332
Reviewed by Alexander Pavlov.
Improved open resource dialog filtering to make the amount of false
positive search results less.
* inspector/front-end/FilteredItemSelectionDialog.js:
(WebInspector.FilteredItemSelectionDialog.prototype._innerCreateSearchRegExp):
(WebInspector.FilteredItemSelectionDialog.prototype._highlightItem.get var):
(WebInspector.FilteredItemSelectionDialog.prototype._highlightItem):
2012-09-24 Andrey Adaikin <aandrey@chromium.org>
 
Web Inspector: [Canvas] support 2D canvas instrumentation from the inspector C++ code
......@@ -192,23 +192,17 @@ WebInspector.FilteredItemSelectionDialog.prototype = {
*/
_innerCreateSearchRegExp: function(query, isGlobal)
{
query = query ? query.trim() : query;
if (!query)
return new RegExp(".*");
query = query.trim();
var ignoreCase = (query === query.toLowerCase());
const toEscape = "^[]{}()\\.$*+?|";
var regExpString = "";
for (var i = 0; i < query.length; ++i) {
var c = query.charAt(i);
if (toEscape.indexOf(c) !== -1)
c = "\\" + c;
if (i)
regExpString += "[^" + c + "]*";
regExpString += c;
}
var regExpString = query.escapeForRegExp().replace(/\\\*/g, ".*").replace(/\\\?/g, ".")
if (ignoreCase)
regExpString = regExpString.replace(/(?!^)(\\\.|[_:-])/g, "[^._:-]*$1");
else
regExpString = regExpString.replace(/(?!^)(\\\.|[A-Z_:-])/g, "[^.A-Z_:-]*$1");
regExpString = "^" + "[^a-zA-Z0-9]*" + regExpString;
return new RegExp(regExpString, (ignoreCase ? "i" : "") + (isGlobal ? "g" : ""));
},
......@@ -393,7 +387,7 @@ WebInspector.FilteredItemSelectionDialog.prototype = {
var ranges = [];
var match;
while ((match = regex.exec(key)) !== null) {
while ((match = regex.exec(key)) !== null && match[0]) {
ranges.push({ offset: match.index, length: regex.lastIndex - match.index });
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment