Diff
Modified: trunk/LayoutTests/ChangeLog (242017 => 242018)
--- trunk/LayoutTests/ChangeLog 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/LayoutTests/ChangeLog 2019-02-25 04:27:46 UTC (rev 242018)
@@ -1,5 +1,24 @@
2019-02-24 Devin Rousso <[email protected]>
+ Web Inspector: provide a way to make searches case sensitive or use a regular _expression_
+ https://bugs.webkit.org/show_bug.cgi?id=192527
+ <rdar://problem/46800955>
+
+ Reviewed by Joseph Pecoraro.
+
+ * inspector/debugger/search-scripts.html:
+ * inspector/debugger/search-scripts-expected.txt:
+
+ * inspector/page/searchInResources.html:
+ * inspector/page/searchInResources-expected.txt:
+
+ * inspector/page/resources/search-script.js:
+ * inspector/page/resources/search-stylesheet.css:
+ * inspector/page/resources/search-worker.js:
+ * inspector/page/resources/search-xhr.txt:
+
+2019-02-24 Devin Rousso <[email protected]>
+
Web Inspector: make debounce Proxy into its own class
https://bugs.webkit.org/show_bug.cgi?id=194721
Modified: trunk/LayoutTests/inspector/debugger/search-scripts-expected.txt (242017 => 242018)
--- trunk/LayoutTests/inspector/debugger/search-scripts-expected.txt 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/LayoutTests/inspector/debugger/search-scripts-expected.txt 2019-02-25 04:27:46 UTC (rev 242018)
@@ -1,28 +1,191 @@
Test DebuggerAgent.searchInContent to search script content.
+Script added: inspector/debugger/search-scripts.html
+Script added: inspector/debugger/search-scripts.html
+Script added: eval1.js
+Script added: eval2.js
-SCRIPT: LayoutTests/http/tests/inspector/resources/inspector-test.js
+QUERY: searchtest {}
+SCRIPT: inspector/debugger/search-scripts.html
+RESULTS: 1
+ LINE: 1
+ CONTENT: runTest(); // SEARCHTEST: onload attribute string // OTHERTEST: onload attribute string
+
+QUERY: searchtest {"caseSensitive":true}
+SCRIPT: inspector/debugger/search-scripts.html
RESULTS: 0
-SCRIPT: LayoutTests/inspector/debugger/search-scripts.html
-RESULTS: 2
+QUERY: searchtest {"isRegex":true}
+SCRIPT: inspector/debugger/search-scripts.html
+RESULTS: 1
LINE: 1
- CONTENT: // SEARCHTEST: Comment in inline <script>.
- LINE: 28
- CONTENT: DebuggerAgent.searchInContent(script.id, "SEARCHTEST", false, false, function(error, results) {
+ CONTENT: runTest(); // SEARCHTEST: onload attribute string // OTHERTEST: onload attribute string
-SCRIPT: LayoutTests/inspector/debugger/search-scripts.html
+QUERY: searchtest {"caseSensitive":true,"isRegex":true}
+SCRIPT: inspector/debugger/search-scripts.html
+RESULTS: 0
+
+QUERY: SEARCHtest {}
+SCRIPT: inspector/debugger/search-scripts.html
RESULTS: 1
LINE: 1
- CONTENT: runTest(); // SEARCHTEST: onload attribute string
+ CONTENT: runTest(); // SEARCHTEST: onload attribute string // OTHERTEST: onload attribute string
+QUERY: SEARCHtest {"caseSensitive":true}
+SCRIPT: inspector/debugger/search-scripts.html
+RESULTS: 0
+
+QUERY: SEARCHtest {"isRegex":true}
+SCRIPT: inspector/debugger/search-scripts.html
+RESULTS: 1
+ LINE: 1
+ CONTENT: runTest(); // SEARCHTEST: onload attribute string // OTHERTEST: onload attribute string
+
+QUERY: SEARCHtest {"caseSensitive":true,"isRegex":true}
+SCRIPT: inspector/debugger/search-scripts.html
+RESULTS: 0
+
+QUERY: (search|OTHER)TEST {}
+SCRIPT: inspector/debugger/search-scripts.html
+RESULTS: 0
+
+QUERY: (search|OTHER)TEST {"caseSensitive":true}
+SCRIPT: inspector/debugger/search-scripts.html
+RESULTS: 0
+
+QUERY: (search|OTHER)TEST {"isRegex":true}
+SCRIPT: inspector/debugger/search-scripts.html
+RESULTS: 1
+ LINE: 1
+ CONTENT: runTest(); // SEARCHTEST: onload attribute string // OTHERTEST: onload attribute string
+
+QUERY: (search|OTHER)TEST {"caseSensitive":true,"isRegex":true}
+SCRIPT: inspector/debugger/search-scripts.html
+RESULTS: 1
+ LINE: 1
+ CONTENT: runTest(); // SEARCHTEST: onload attribute string // OTHERTEST: onload attribute string
+
+QUERY: searchtest {}
SCRIPT: eval1.js
RESULTS: 1
LINE: 0
CONTENT: // SEARCHTEST: Eval 1
+QUERY: searchtest {"caseSensitive":true}
+SCRIPT: eval1.js
+RESULTS: 0
+
+QUERY: searchtest {"isRegex":true}
+SCRIPT: eval1.js
+RESULTS: 1
+ LINE: 0
+ CONTENT: // SEARCHTEST: Eval 1
+
+QUERY: searchtest {"caseSensitive":true,"isRegex":true}
+SCRIPT: eval1.js
+RESULTS: 0
+
+QUERY: SEARCHtest {}
+SCRIPT: eval1.js
+RESULTS: 1
+ LINE: 0
+ CONTENT: // SEARCHTEST: Eval 1
+
+QUERY: SEARCHtest {"caseSensitive":true}
+SCRIPT: eval1.js
+RESULTS: 0
+
+QUERY: SEARCHtest {"isRegex":true}
+SCRIPT: eval1.js
+RESULTS: 1
+ LINE: 0
+ CONTENT: // SEARCHTEST: Eval 1
+
+QUERY: SEARCHtest {"caseSensitive":true,"isRegex":true}
+SCRIPT: eval1.js
+RESULTS: 0
+
+QUERY: (search|OTHER)TEST {}
+SCRIPT: eval1.js
+RESULTS: 0
+
+QUERY: (search|OTHER)TEST {"caseSensitive":true}
+SCRIPT: eval1.js
+RESULTS: 0
+
+QUERY: (search|OTHER)TEST {"isRegex":true}
+SCRIPT: eval1.js
+RESULTS: 2
+ LINE: 0
+ CONTENT: // SEARCHTEST: Eval 1
+ LINE: 1
+ CONTENT: // OTHERTEST: Eval 1
+
+QUERY: (search|OTHER)TEST {"caseSensitive":true,"isRegex":true}
+SCRIPT: eval1.js
+RESULTS: 1
+ LINE: 1
+ CONTENT: // OTHERTEST: Eval 1
+
+QUERY: searchtest {}
SCRIPT: eval2.js
RESULTS: 1
LINE: 0
CONTENT: var SEARCHTEST = "SEARCHTEST";
+QUERY: searchtest {"caseSensitive":true}
+SCRIPT: eval2.js
+RESULTS: 0
+
+QUERY: searchtest {"isRegex":true}
+SCRIPT: eval2.js
+RESULTS: 1
+ LINE: 0
+ CONTENT: var SEARCHTEST = "SEARCHTEST";
+
+QUERY: searchtest {"caseSensitive":true,"isRegex":true}
+SCRIPT: eval2.js
+RESULTS: 0
+
+QUERY: SEARCHtest {}
+SCRIPT: eval2.js
+RESULTS: 1
+ LINE: 0
+ CONTENT: var SEARCHTEST = "SEARCHTEST";
+
+QUERY: SEARCHtest {"caseSensitive":true}
+SCRIPT: eval2.js
+RESULTS: 0
+
+QUERY: SEARCHtest {"isRegex":true}
+SCRIPT: eval2.js
+RESULTS: 1
+ LINE: 0
+ CONTENT: var SEARCHTEST = "SEARCHTEST";
+
+QUERY: SEARCHtest {"caseSensitive":true,"isRegex":true}
+SCRIPT: eval2.js
+RESULTS: 0
+
+QUERY: (search|OTHER)TEST {}
+SCRIPT: eval2.js
+RESULTS: 0
+
+QUERY: (search|OTHER)TEST {"caseSensitive":true}
+SCRIPT: eval2.js
+RESULTS: 0
+
+QUERY: (search|OTHER)TEST {"isRegex":true}
+SCRIPT: eval2.js
+RESULTS: 2
+ LINE: 0
+ CONTENT: var SEARCHTEST = "SEARCHTEST";
+ LINE: 1
+ CONTENT: var OTHERTEST = "OTHERTEST";
+
+QUERY: (search|OTHER)TEST {"caseSensitive":true,"isRegex":true}
+SCRIPT: eval2.js
+RESULTS: 1
+ LINE: 1
+ CONTENT: var OTHERTEST = "OTHERTEST";
+
Modified: trunk/LayoutTests/inspector/debugger/search-scripts.html (242017 => 242018)
--- trunk/LayoutTests/inspector/debugger/search-scripts.html 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/LayoutTests/inspector/debugger/search-scripts.html 2019-02-25 04:27:46 UTC (rev 242018)
@@ -7,41 +7,61 @@
function performEvals()
{
// Find the line with the search term.
- eval("// SEARCH" + "TEST: Eval 1\n//# sourceURL=eval1.js");
+ eval("// SEARCH" + "TEST: Eval 1\n// OTHER" + "TEST: Eval 1\n//# sourceURL=eval1.js");
// If the search term shows up multiple times on a single line, the line is returned once.
- eval("var SEARCH" + "TEST = \"SEARCH" + "TEST\";\n//# sourceURL=eval2.js");
+ eval("var SEARCH" + "TEST = \"SEARCH" + "TEST\";\nvar OTHER" + "TEST = \"OTHER" + "TEST\";\n//# sourceURL=eval2.js");
};
function test()
{
- function sanitizeScriptURL(url) {
- return url.substring(url.indexOf("LayoutTests"));
- }
-
function chomp(line) {
return line.replace(/\n$/, "");
}
- var scriptsCount = 0;
- const expectedScriptsCount = 5;
+ function searchInContent(script, query, options = {}) {
+ return DebuggerAgent.searchInContent(script.id, query, options.caseSensitive, options.isRegex)
+ .then(({result}) => {
+ InspectorTest.log("");
+ InspectorTest.log("QUERY: " + query + " " + JSON.stringify(options));
+ InspectorTest.log("SCRIPT: " + sanitizeURL(script.sourceURL || script.url));
+ InspectorTest.log("RESULTS: " + result.length);
+ for (let item of result) {
+ InspectorTest.log(" LINE: " + item.lineNumber);
+ InspectorTest.log(" CONTENT: " + chomp(item.lineContent));
+ }
+ });
+ }
+ let scripts = new Map;
+
WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.ScriptAdded, function(event) {
- var script = event.data.script;
- if (!/LayoutTests/.test(script.url) && !/eval\d\.js/.test(script.sourceURL))
+ let {script} = event.data;
+ let url = "" || script.url;
+ if (!/LayoutTests/.test(url) && !/eval\d\.js/.test(url))
return;
- DebuggerAgent.searchInContent(script.id, "SEARCHTEST", false, false, function(error, results) {
- InspectorTest.log("");
- InspectorTest.log("SCRIPT: " + sanitizeScriptURL(script.sourceURL || script.url));
- InspectorTest.log("RESULTS: " + results.length);
- for (var result of results) {
- InspectorTest.log(" LINE: " + result.lineNumber);
- InspectorTest.log(" CONTENT: " + chomp(result.lineContent));
+ if (url.endsWith("inspector-test.js"))
+ return;
+
+ InspectorTest.log("Script added: " + sanitizeURL(url));
+
+ scripts.set(url, script);
+
+ if (url ="" "eval2.js") {
+ let promiseCallbacks = [];
+ for (let item of scripts.values()) {
+ for (let query of ["search" + "test", "SEARCH" + "test", "(search|OTHER)" + "TEST"]) {
+ promiseCallbacks.push(() => searchInContent(item, query));
+ promiseCallbacks.push(() => searchInContent(item, query, {caseSensitive: true}));
+ promiseCallbacks.push(() => searchInContent(item, query, {isRegex: true}));
+ promiseCallbacks.push(() => searchInContent(item, query, {caseSensitive: true, isRegex: true}));
+ }
}
- if (++scriptsCount === expectedScriptsCount)
+ Promise.chain(promiseCallbacks).then(() => {
InspectorTest.completeTest();
- });
+ });
+ }
});
InspectorTest.addEventListener(FrontendTestHarness.Event.TestPageDidLoad, () => {
@@ -52,7 +72,7 @@
}
</script>
</head>
-<body _onload_="runTest(); // SEARCHTEST: onload attribute string">
+<body _onload_="runTest(); // SEARCHTEST: onload attribute string // OTHERTEST: onload attribute string">
<p>Test <code>DebuggerAgent.searchInContent</code> to search script content.</p>
</body>
</html>
Modified: trunk/LayoutTests/inspector/page/resources/search-script.js (242017 => 242018)
--- trunk/LayoutTests/inspector/page/resources/search-script.js 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/LayoutTests/inspector/page/resources/search-script.js 2019-02-25 04:27:46 UTC (rev 242018)
@@ -1 +1,3 @@
// Script resource with the SEARCH-STRING.
+
+// Script resource with the OTHER-STRING.
Modified: trunk/LayoutTests/inspector/page/resources/search-stylesheet.css (242017 => 242018)
--- trunk/LayoutTests/inspector/page/resources/search-stylesheet.css 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/LayoutTests/inspector/page/resources/search-stylesheet.css 2019-02-25 04:27:46 UTC (rev 242018)
@@ -1,4 +1,7 @@
/* Stylesheet resource with the SEARCH-STRING */
+
+/* Stylesheet resource with the OTHER-STRING */
+
body {
color: black;
}
Modified: trunk/LayoutTests/inspector/page/resources/search-worker.js (242017 => 242018)
--- trunk/LayoutTests/inspector/page/resources/search-worker.js 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/LayoutTests/inspector/page/resources/search-worker.js 2019-02-25 04:27:46 UTC (rev 242018)
@@ -1,5 +1,7 @@
// Worker resource with the SEARCH-STRING.
+// Worker resource with the OTHER-STRING.
+
self.addEventListener("message", (event) => {
self.postMessage("echo: " + event.data);
});
Modified: trunk/LayoutTests/inspector/page/resources/search-xhr.txt (242017 => 242018)
--- trunk/LayoutTests/inspector/page/resources/search-xhr.txt 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/LayoutTests/inspector/page/resources/search-xhr.txt 2019-02-25 04:27:46 UTC (rev 242018)
@@ -1,2 +1,5 @@
XHR Resource with the SEARCH-STRING.
XHR Resource with the SEARCH-STRING again!
+
+XHR Resource with the OTHER-STRING.
+XHR Resource with the OTHER-STRING again!
Modified: trunk/LayoutTests/inspector/page/searchInResources-expected.txt (242017 => 242018)
--- trunk/LayoutTests/inspector/page/searchInResources-expected.txt 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/LayoutTests/inspector/page/searchInResources-expected.txt 2019-02-25 04:27:46 UTC (rev 242018)
@@ -10,12 +10,64 @@
FOUND: inspector/page/resources/search-xhr.txt (2)
FOUND: inspector/page/searchInResources.html (1)
+-- Running test case: SearchAllResources.CaseSensitive
+PASS: Should find results in multiple resources.
+FOUND: inspector/page/resources/search-script.js (1)
+FOUND: inspector/page/resources/search-stylesheet.css (1)
+FOUND: inspector/page/resources/search-worker.js (1)
+FOUND: inspector/page/resources/search-xhr.txt (2)
+
+-- Running test case: SearchAllResources.IsRegex
+PASS: Should find results in multiple resources.
+FOUND: inspector/page/resources/search-script.js (2)
+FOUND: inspector/page/resources/search-stylesheet.css (2)
+FOUND: inspector/page/resources/search-worker.js (2)
+FOUND: inspector/page/resources/search-xhr.txt (4)
+FOUND: inspector/page/searchInResources.html (1)
+
+-- Running test case: SearchAllResources.CaseSensitiveIsRegex
+PASS: Should find results in multiple resources.
+FOUND: inspector/page/resources/search-script.js (1)
+FOUND: inspector/page/resources/search-stylesheet.css (1)
+FOUND: inspector/page/resources/search-worker.js (1)
+FOUND: inspector/page/resources/search-xhr.txt (2)
+
-- Running test case: SearchInScriptResource
-PASS: Should find previously mentioned number of matches.
+PASS: Should find 1 matches.
MATCH: {"lineNumber":0,"lineContent":"// Script resource with the SEARCH-STRING.\n"}
+-- Running test case: SearchInScriptResource.CaseSensitive
+PASS: Should find 1 matches.
+MATCH: {"lineNumber":0,"lineContent":"// Script resource with the SEARCH-STRING.\n"}
+
+-- Running test case: SearchInScriptResource.IsRegex
+PASS: Should find 2 matches.
+MATCH: {"lineNumber":0,"lineContent":"// Script resource with the SEARCH-STRING.\n"}
+MATCH: {"lineNumber":2,"lineContent":"// Script resource with the OTHER-STRING.\n"}
+
+-- Running test case: SearchInScriptResource.CaseSensitiveIsRegex
+PASS: Should find 1 matches.
+MATCH: {"lineNumber":2,"lineContent":"// Script resource with the OTHER-STRING.\n"}
+
-- Running test case: SearchInXHRResource
-PASS: Should find previously mentioned number of matches.
+PASS: Should find 2 matches.
MATCH: {"lineNumber":0,"lineContent":"XHR Resource with the SEARCH-STRING.\n"}
MATCH: {"lineNumber":1,"lineContent":"XHR Resource with the SEARCH-STRING again!\n"}
+-- Running test case: SearchInXHRResource.CaseSensitive
+PASS: Should find 2 matches.
+MATCH: {"lineNumber":0,"lineContent":"XHR Resource with the SEARCH-STRING.\n"}
+MATCH: {"lineNumber":1,"lineContent":"XHR Resource with the SEARCH-STRING again!\n"}
+
+-- Running test case: SearchInXHRResource.IsRegex
+PASS: Should find 4 matches.
+MATCH: {"lineNumber":0,"lineContent":"XHR Resource with the SEARCH-STRING.\n"}
+MATCH: {"lineNumber":1,"lineContent":"XHR Resource with the SEARCH-STRING again!\n"}
+MATCH: {"lineNumber":3,"lineContent":"XHR Resource with the OTHER-STRING.\n"}
+MATCH: {"lineNumber":4,"lineContent":"XHR Resource with the OTHER-STRING again!\n"}
+
+-- Running test case: SearchInXHRResource.CaseSensitiveIsRegex
+PASS: Should find 2 matches.
+MATCH: {"lineNumber":3,"lineContent":"XHR Resource with the OTHER-STRING.\n"}
+MATCH: {"lineNumber":4,"lineContent":"XHR Resource with the OTHER-STRING again!\n"}
+
Modified: trunk/LayoutTests/inspector/page/searchInResources.html (242017 => 242018)
--- trunk/LayoutTests/inspector/page/searchInResources.html 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/LayoutTests/inspector/page/searchInResources.html 2019-02-25 04:27:46 UTC (rev 242018)
@@ -26,9 +26,15 @@
let suite = InspectorTest.createAsyncSuite("Page.searchInResources and Page.searchInResource");
- let searchResults;
- const searchString = "SEARCH-STRING";
+ const searchString = "SeArCh-StRiNg";
+ const searchStringCaseSensitive = searchString.toUpperCase();
+ const searchStringRegex = "(search|OTHER)-STRING";
+ let searchResults = null;
+ let searchResultsCaseSensitive = null;
+ let searchResultsIsRegex = null;
+ let searchResultsCaseSensitiveIsRegex = null;
+
suite.addTestCase({
name: "SearchAllResources",
description: "Able to find text results in different resources.",
@@ -45,6 +51,56 @@
});
suite.addTestCase({
+ name: "SearchAllResources.CaseSensitive",
+ description: "Able to find text results in different resources.",
+ test(resolve, reject) {
+ const caseSensitive = true;
+ PageAgent.searchInResources(searchStringCaseSensitive, caseSensitive, (error, results) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.expectThat(results.length > 0, "Should find results in multiple resources.");
+ searchResultsCaseSensitive = results.sort((a, b) => a.url.localeCompare(b.url));
+ for (let result of searchResultsCaseSensitive)
+ InspectorTest.log(`FOUND: ${sanitizeURL(result.url)} (${result.matchesCount})`);
+ resolve();
+ });
+ }
+ });
+
+ suite.addTestCase({
+ name: "SearchAllResources.IsRegex",
+ description: "Able to find text results in different resources.",
+ test(resolve, reject) {
+ const caseSensitive = undefined;
+ const isRegex = true;
+ PageAgent.searchInResources(searchStringRegex, caseSensitive, isRegex, (error, results) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.expectThat(results.length > 0, "Should find results in multiple resources.");
+ searchResultsIsRegex = results.sort((a, b) => a.url.localeCompare(b.url));
+ for (let result of searchResultsIsRegex)
+ InspectorTest.log(`FOUND: ${sanitizeURL(result.url)} (${result.matchesCount})`);
+ resolve();
+ });
+ }
+ });
+
+ suite.addTestCase({
+ name: "SearchAllResources.CaseSensitiveIsRegex",
+ description: "Able to find text results in different resources.",
+ test(resolve, reject) {
+ const caseSensitive = true;
+ const isRegex = true;
+ PageAgent.searchInResources(searchStringRegex, caseSensitive, isRegex, (error, results) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.expectThat(results.length > 0, "Should find results in multiple resources.");
+ searchResultsCaseSensitiveIsRegex = results.sort((a, b) => a.url.localeCompare(b.url));
+ for (let result of searchResultsCaseSensitiveIsRegex)
+ InspectorTest.log(`FOUND: ${sanitizeURL(result.url)} (${result.matchesCount})`);
+ resolve();
+ });
+ }
+ });
+
+ suite.addTestCase({
name: "SearchInScriptResource",
description: "Able to find text results in an individual Script resource.",
test(resolve, reject) {
@@ -54,7 +110,7 @@
PageAgent.searchInResource(result.frameId, result.url, searchString, (error, matches) => {
InspectorTest.assert(!error, "Should not be a protocol error.");
- InspectorTest.expectThat(matches.length === result.matchesCount, "Should find previously mentioned number of matches.");
+ InspectorTest.expectThat(matches.length === result.matchesCount, `Should find ${result.matchesCount} matches.`);
for (let match of matches)
InspectorTest.log(`MATCH: ${JSON.stringify(match)}`);
resolve();
@@ -63,6 +119,65 @@
});
suite.addTestCase({
+ name: "SearchInScriptResource.CaseSensitive",
+ description: "Able to find text results in an individual Script resource.",
+ test(resolve, reject) {
+ let result = searchResultsCaseSensitive.find((result) => /search-script\.js$/.test(result.url));
+ if (!result)
+ reject();
+
+ const caseSensitive = true;
+ PageAgent.searchInResource(result.frameId, result.url, searchStringCaseSensitive, caseSensitive, (error, matches) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.expectThat(matches.length === result.matchesCount, `Should find ${result.matchesCount} matches.`);
+ for (let match of matches)
+ InspectorTest.log(`MATCH: ${JSON.stringify(match)}`);
+ resolve();
+ });
+ }
+ });
+
+ suite.addTestCase({
+ name: "SearchInScriptResource.IsRegex",
+ description: "Able to find text results in an individual Script resource.",
+ test(resolve, reject) {
+ let result = searchResultsIsRegex.find((result) => /search-script\.js$/.test(result.url));
+ if (!result)
+ reject();
+
+ const caseSensitive = undefined;
+ const isRegex = true;
+ PageAgent.searchInResource(result.frameId, result.url, searchStringRegex, caseSensitive, isRegex, (error, matches) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.expectThat(matches.length === result.matchesCount, `Should find ${result.matchesCount} matches.`);
+ for (let match of matches)
+ InspectorTest.log(`MATCH: ${JSON.stringify(match)}`);
+ resolve();
+ });
+ }
+ });
+
+ suite.addTestCase({
+ name: "SearchInScriptResource.CaseSensitiveIsRegex",
+ description: "Able to find text results in an individual Script resource.",
+ test(resolve, reject) {
+ let result = searchResultsCaseSensitiveIsRegex.find((result) => /search-script\.js$/.test(result.url));
+ if (!result)
+ reject();
+
+ const caseSensitive = true;
+ const isRegex = true;
+ PageAgent.searchInResource(result.frameId, result.url, searchStringRegex, caseSensitive, isRegex, (error, matches) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.expectThat(matches.length === result.matchesCount, `Should find ${result.matchesCount} matches.`);
+ for (let match of matches)
+ InspectorTest.log(`MATCH: ${JSON.stringify(match)}`);
+ resolve();
+ });
+ }
+ });
+
+ suite.addTestCase({
name: "SearchInXHRResource",
description: "Able to find text results in an individual XHR resource.",
test(resolve, reject) {
@@ -75,7 +190,7 @@
PageAgent.searchInResource(result.frameId, result.url, searchString, caseSensitive, isRegex, result.requestId, (error, matches) => {
InspectorTest.assert(!error, "Should not be a protocol error.");
- InspectorTest.expectThat(matches.length === result.matchesCount, "Should find previously mentioned number of matches.");
+ InspectorTest.expectThat(matches.length === result.matchesCount, `Should find ${result.matchesCount} matches.`);
for (let match of matches)
InspectorTest.log(`MATCH: ${JSON.stringify(match)}`);
resolve();
@@ -83,6 +198,69 @@
}
});
+ suite.addTestCase({
+ name: "SearchInXHRResource.CaseSensitive",
+ description: "Able to find text results in an individual XHR resource.",
+ test(resolve, reject) {
+ let result = searchResultsCaseSensitive.find((result) => /search-xhr\.txt$/.test(result.url));
+ if (!result)
+ reject();
+
+ const isRegex = undefined;
+ const caseSensitive = true;
+
+ PageAgent.searchInResource(result.frameId, result.url, searchStringCaseSensitive, caseSensitive, isRegex, result.requestId, (error, matches) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.expectThat(matches.length === result.matchesCount, `Should find ${result.matchesCount} matches.`);
+ for (let match of matches)
+ InspectorTest.log(`MATCH: ${JSON.stringify(match)}`);
+ resolve();
+ });
+ }
+ });
+
+ suite.addTestCase({
+ name: "SearchInXHRResource.IsRegex",
+ description: "Able to find text results in an individual XHR resource.",
+ test(resolve, reject) {
+ let result = searchResultsIsRegex.find((result) => /search-xhr\.txt$/.test(result.url));
+ if (!result)
+ reject();
+
+ const isRegex = true;
+ const caseSensitive = undefined;
+
+ PageAgent.searchInResource(result.frameId, result.url, searchStringRegex, caseSensitive, isRegex, result.requestId, (error, matches) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.expectThat(matches.length === result.matchesCount, `Should find ${result.matchesCount} matches.`);
+ for (let match of matches)
+ InspectorTest.log(`MATCH: ${JSON.stringify(match)}`);
+ resolve();
+ });
+ }
+ });
+
+ suite.addTestCase({
+ name: "SearchInXHRResource.CaseSensitiveIsRegex",
+ description: "Able to find text results in an individual XHR resource.",
+ test(resolve, reject) {
+ let result = searchResultsCaseSensitiveIsRegex.find((result) => /search-xhr\.txt$/.test(result.url));
+ if (!result)
+ reject();
+
+ const isRegex = true;
+ const caseSensitive = true;
+
+ PageAgent.searchInResource(result.frameId, result.url, searchStringRegex, caseSensitive, isRegex, result.requestId, (error, matches) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.expectThat(matches.length === result.matchesCount, `Should find ${result.matchesCount} matches.`);
+ for (let match of matches)
+ InspectorTest.log(`MATCH: ${JSON.stringify(match)}`);
+ resolve();
+ });
+ }
+ });
+
InspectorTest.awaitEvent("PageIsReady")
.then((event) => {
suite.runTestCasesAndFinish();
Modified: trunk/Source/WebInspectorUI/ChangeLog (242017 => 242018)
--- trunk/Source/WebInspectorUI/ChangeLog 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/Source/WebInspectorUI/ChangeLog 2019-02-25 04:27:46 UTC (rev 242018)
@@ -1,5 +1,79 @@
2019-02-24 Devin Rousso <[email protected]>
+ Web Inspector: provide a way to make searches case sensitive or use a regular _expression_
+ https://bugs.webkit.org/show_bug.cgi?id=192527
+
+ Reviewed by Joseph Pecoraro.
+
+ * UserInterface/Base/SearchUtilities.js: Added.
+ (WI.SearchUtilities.get defaultSettings):
+ (WI.SearchUtilities.createSettings):
+ (WI.SearchUtilities.regExpForString):
+ (WI.SearchUtilities.createSettingsButton):
+ (WI.SearchUtilities.createSettingsButton.toggleActive):
+ * UserInterface/Views/Main.css:
+ (.search-settings): Added.
+ (.search-settings > .glyph): Added.
+ (.search-settings:active > .glyph): Added.
+ (.search-settings.active > .glyph): Added.
+ (.search-settings:active.active > .glyph): Added.
+ Create static utility class for handling settings related to searching/filtering.
+
+ * UserInterface/Base/Setting.js:
+ * UserInterface/Views/SettingsTabContentView.js:
+ (WI.SettingsTabContentView.prototype._createGeneralSettingsView):
+ Create default search settings that apply across WebInspector, unless a more specific
+ setting has been created that overrides it (e.g. the navigation sidebar or Search tab).
+
+ * UserInterface/Views/SearchSidebarPanel.js:
+ (WI.SearchSidebarPanel):
+ (WI.SearchSidebarPanel.prototype.performSearch.forEachMatch):
+ (WI.SearchSidebarPanel.prototype.performSearch.resourceCallback):
+ (WI.SearchSidebarPanel.prototype.performSearch.resourcesCallback):
+ (WI.SearchSidebarPanel.prototype.performSearch.searchScripts.scriptCallback):
+ (WI.SearchSidebarPanel.prototype.performSearch.searchScripts):
+ (WI.SearchSidebarPanel.prototype.performSearch.domSearchResults):
+ (WI.SearchSidebarPanel.prototype.performSearch.domCallback):
+ (WI.SearchSidebarPanel.prototype.performSearch):
+ * UserInterface/Views/SearchSidebarPanel.css:
+ (.sidebar > .panel.navigation.search > .search-bar):
+ (.sidebar > .panel.navigation.search > .search-bar > input[type="search"]):
+ Add a (*) settings "gear" after each `<input type="search">` that shows a contextmenu with
+ checkboxes for each search setting. Any settings changed for each input take precedence over
+ the default settings, but will match the corresponding default setting if it's changed.
+
+ * UserInterface/Views/SearchResultTreeElement.js:
+ (WI.SearchResultTreeElement.truncateAndHighlightTitle):
+ Use the length of the found text, rather than the length of the query.
+
+ * UserInterface/Views/DOMTreeElement.js:
+ (WI.DOMTreeElement.prototype._highlightSearchResults):
+ * UserInterface/Views/DataGrid.js:
+ (WI.DataGrid.prototype._updateFilter):
+ * UserInterface/Views/LogContentView.js:
+ (WI.LogContentView.prototype.performSearch):
+ * UserInterface/Views/NetworkTableContentView.js:
+ (WI.NetworkTableContentView.prototype._urlFilterDidChange):
+ * UserInterface/Views/ResourceHeadersContentView.js:
+ (WI.ResourceHeadersContentView.prototype._perfomSearchOnKeyValuePairs):
+ * UserInterface/Views/ResourceSecurityContentView.js:
+ (WI.ResourceSecurityContentView.prototype._perfomSearchOnKeyValuePairs):
+ * UserInterface/Views/SourceCodeTextEditor.js:
+ (WI.SourceCodeTextEditor.prototype.customPerformSearch.searchResultCallback):
+ (WI.SourceCodeTextEditor.prototype.customPerformSearch):
+ * UserInterface/Views/TextEditor.js:
+ (WI.TextEditor.prototype.performSearch):
+ Use the default search settings when searching/filtering.
+
+ * UserInterface/Views/SearchBar.css:
+ (.search-bar > input[type="search"]:placeholder-shown::-webkit-search-cancel-button): Added.
+ Drive-by: prevent the (x) from appearing when no text has been entered.
+
+ * Localizations/en.lproj/localizedStrings.js:
+ * UserInterface/Main.html:
+
+2019-02-24 Devin Rousso <[email protected]>
+
Web Inspector: make debounce Proxy into its own class
https://bugs.webkit.org/show_bug.cgi?id=194721
Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (242017 => 242018)
--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js 2019-02-25 04:27:46 UTC (rev 242018)
@@ -187,6 +187,10 @@
localizedStrings["Canvases"] = "Canvases";
localizedStrings["Capture Screenshot"] = "Capture Screenshot";
localizedStrings["Capturing"] = "Capturing";
+/* Context menu label for whether searches should be case sensitive. */
+localizedStrings["Case Sensitive @ Context Menu"] = "Case Sensitive";
+/* Settings tab checkbox label for whether searches should be case sensitive. */
+localizedStrings["Case Sensitive @ Settings"] = "Case Sensitive";
localizedStrings["Catch Variables"] = "Catch Variables";
localizedStrings["Categories"] = "Categories";
localizedStrings["Certificate"] = "Certificate";
@@ -760,6 +764,10 @@
localizedStrings["Refresh watch expressions"] = "Refresh watch expressions";
localizedStrings["Region announced in its entirety."] = "Region announced in its entirety.";
localizedStrings["Regular _expression_"] = "Regular _expression_";
+/* Context menu label for whether searches should be treated as regular expressions. */
+localizedStrings["Regular _expression_ @ Context Menu"] = "Regular _expression_";
+/* Settings tab checkbox label for whether searches should be treated as regular expressions. */
+localizedStrings["Regular _expression_ @ Settings"] = "Regular _expression_";
localizedStrings["Reload Web Inspector"] = "Reload Web Inspector";
localizedStrings["Reload page (%s)\nReload page ignoring cache (%s)"] = "Reload page (%s)\nReload page ignoring cache (%s)";
localizedStrings["Removals"] = "Removals";
@@ -834,6 +842,8 @@
localizedStrings["Search"] = "Search";
localizedStrings["Search Again"] = "Search Again";
localizedStrings["Search Resource Content"] = "Search Resource Content";
+/* Settings tab label for search related settings */
+localizedStrings["Search: @ Settings"] = "Search:";
localizedStrings["Secure"] = "Secure";
localizedStrings["Security"] = "Security";
localizedStrings["Security Issue"] = "Security Issue";
Added: trunk/Source/WebInspectorUI/UserInterface/Base/SearchUtilities.js (0 => 242018)
--- trunk/Source/WebInspectorUI/UserInterface/Base/SearchUtilities.js (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/SearchUtilities.js 2019-02-25 04:27:46 UTC (rev 242018)
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WI.SearchUtilities = class SearchUtilities {
+ static get defaultSettings()
+ {
+ return {
+ caseSensitive: WI.settings.searchCaseSensitive,
+ regularExpression: WI.settings.searchRegularExpression,
+ };
+ }
+
+ static createSettings(namePrefix, options = {})
+ {
+ let settings = {};
+ for (let [key, defaultSetting] of Object.entries(WI.SearchUtilities.defaultSettings)) {
+ let setting = new WI.Setting(namePrefix + "-" + defaultSetting.name, defaultSetting.value);
+ defaultSetting.addEventListener(WI.Setting.Event.Changed, (event) => {
+ setting.value = defaultSetting.value;
+ });
+ settings[key] = setting;
+
+ if (options.handleChanged)
+ setting.addEventListener(WI.Setting.Event.Changed, options.handleChanged);
+ }
+ return settings;
+ }
+
+ static regExpForString(query, settings = {})
+ {
+ function checkSetting(setting) {
+ return setting instanceof WI.Setting ? setting.value : !!setting;
+ }
+
+ if (!checkSetting(settings.regularExpression))
+ query = simpleGlobStringToRegExp(query);
+
+ let flags = "g";
+ if (!checkSetting(settings.caseSensitive))
+ flags += "i";
+
+ return new RegExp(query, flags);
+ }
+
+ static createSettingsButton(settings)
+ {
+ console.assert(!isEmptyObject(settings));
+
+ let button = document.createElement("button");
+ button.addEventListener("click", (event) => {
+ event.stop();
+
+ let contextMenu = WI.ContextMenu.createFromEvent(event);
+
+ if (settings.caseSensitive) {
+ contextMenu.appendCheckboxItem(WI.UIString("Case Sensitive", "Case Sensitive @ Context Menu", "Context menu label for whether searches should be case sensitive."), () => {
+ settings.caseSensitive.value = !settings.caseSensitive.value;
+ }, settings.caseSensitive.value);
+ }
+
+ if (settings.regularExpression) {
+ contextMenu.appendCheckboxItem(WI.UIString("Regular _expression_", "Regular _expression_ @ Context Menu", "Context menu label for whether searches should be treated as regular expressions."), () => {
+ settings.regularExpression.value = !settings.regularExpression.value;
+ }, settings.regularExpression.value);
+ }
+
+ contextMenu.show();
+ });
+ button.classList.add("search-settings");
+ button.tabIndex = -1;
+
+ button.appendChild(WI.ImageUtilities.useSVGSymbol("Images/Gear.svg", "glyph"));
+
+ function toggleActive() {
+ button.classList.toggle("active", Object.values(settings).some((setting) => !!setting.value));
+ }
+ settings.caseSensitive.addEventListener(WI.Setting.Event.Changed, toggleActive);
+ settings.regularExpression.addEventListener(WI.Setting.Event.Changed, toggleActive);
+ toggleActive();
+
+ return button;
+ }
+};
Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js (242017 => 242018)
--- trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js 2019-02-25 04:27:46 UTC (rev 242018)
@@ -136,6 +136,8 @@
indentUnit: new WI.Setting("indent-unit", 4),
indentWithTabs: new WI.Setting("indent-with-tabs", false),
resourceCachingDisabled: new WI.Setting("disable-resource-caching", false),
+ searchCaseSensitive: new WI.Setting("search-case-sensitive", false),
+ searchRegularExpression: new WI.Setting("search-regular-_expression_", false),
selectedNetworkDetailContentViewIdentifier: new WI.Setting("network-detail-content-view-identifier", "preview"),
sourceMapsEnabled: new WI.Setting("source-maps-enabled", true),
showAllRequestsBreakpoint: new WI.Setting("show-all-requests-breakpoint", true),
Modified: trunk/Source/WebInspectorUI/UserInterface/Main.html (242017 => 242018)
--- trunk/Source/WebInspectorUI/UserInterface/Main.html 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/Source/WebInspectorUI/UserInterface/Main.html 2019-02-25 04:27:46 UTC (rev 242018)
@@ -292,6 +292,7 @@
<script src=""
<script src=""
<script src=""
+ <script src=""
<script src=""
<script src=""
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js (242017 => 242018)
--- trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js 2019-02-25 04:27:46 UTC (rev 242018)
@@ -1707,7 +1707,7 @@
}
var text = this.title.textContent;
- var searchRegex = new RegExp(this._searchQuery.escapeForRegExp(), "gi");
+ let searchRegex = WI.SearchUtilities.regExpForString(this._searchQuery, WI.SearchUtilities.defaultSettings);
var match = searchRegex.exec(text);
var matchRanges = [];
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js (242017 => 242018)
--- trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js 2019-02-25 04:27:46 UTC (rev 242018)
@@ -1843,7 +1843,7 @@
if (!this._rows.length)
return;
- this._textFilterRegex = simpleGlobStringToRegExp(this._filterText, "i");
+ this._textFilterRegex = WI.SearchUtilities.regExpForString(this._filterText, WI.SearchUtilities.defaultSettings);
if (this._applyFilterToNodesTask && this._applyFilterToNodesTask.processing)
this._applyFilterToNodesTask.cancel();
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js (242017 => 242018)
--- trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js 2019-02-25 04:27:46 UTC (rev 242018)
@@ -1062,7 +1062,7 @@
this.element.classList.add(WI.LogContentView.SearchInProgressStyleClassName);
- let searchRegex = new RegExp(this._currentSearchQuery.escapeForRegExp(), "gi");
+ let searchRegex = WI.SearchUtilities.regExpForString(this._currentSearchQuery, WI.SearchUtilities.defaultSettings);
this._unfilteredMessageElements().forEach(function(message) {
let matchRanges = [];
let text = message.textContent;
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/Main.css (242017 => 242018)
--- trunk/Source/WebInspectorUI/UserInterface/Views/Main.css 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/Main.css 2019-02-25 04:27:46 UTC (rev 242018)
@@ -293,6 +293,33 @@
background-image: url(../Images/GoToArrow.svg#selected-active);
}
+.search-settings {
+ display: inline-block;
+ margin: 0;
+ padding: 0;
+ background-color: transparent;
+ border: none;
+ -webkit-appearance: none;
+}
+
+.search-settings > .glyph {
+ width: 16px;
+ height: 16px;
+ color: var(--glyph-color);
+}
+
+.search-settings:active > .glyph {
+ color: var(--glyph-color-pressed);
+}
+
+.search-settings.active > .glyph {
+ color: var(--glyph-color-active);
+}
+
+.search-settings:active.active > .glyph {
+ color: var(--glyph-color-active-pressed);
+}
+
.hidden {
display: none !important;
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js (242017 => 242018)
--- trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js 2019-02-25 04:27:46 UTC (rev 242018)
@@ -1870,7 +1870,7 @@
this._urlFilterIsActive = true;
this._urlFilterSearchText = searchQuery;
- this._urlFilterSearchRegex = new RegExp(searchQuery.escapeForRegExp(), "i");
+ this._urlFilterSearchRegex = WI.SearchUtilities.regExpForString(searchQuery, WI.SearchUtilities.defaultSettings);
this._activeURLFilterResources.clear();
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceHeadersContentView.js (242017 => 242018)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceHeadersContentView.js 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceHeadersContentView.js 2019-02-25 04:27:46 UTC (rev 242018)
@@ -419,7 +419,7 @@
_perfomSearchOnKeyValuePairs()
{
- let searchRegex = new RegExp(this._searchQuery.escapeForRegExp(), "gi");
+ let searchRegex = WI.SearchUtilities.regExpForString(this._searchQuery, WI.SearchUtilities.defaultSettings);
let elements = this.element.querySelectorAll(".key, .value");
for (let element of elements) {
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSecurityContentView.js (242017 => 242018)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSecurityContentView.js 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSecurityContentView.js 2019-02-25 04:27:46 UTC (rev 242018)
@@ -286,7 +286,7 @@
_perfomSearchOnKeyValuePairs()
{
- let searchRegex = new RegExp(this._searchQuery.escapeForRegExp(), "gi");
+ let searchRegex = WI.SearchUtilities.regExpForString(this._searchQuery, WI.SearchUtilities.defaultSettings);
let elements = this.element.querySelectorAll(".key, .value");
for (let element of elements) {
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SearchBar.css (242017 => 242018)
--- trunk/Source/WebInspectorUI/UserInterface/Views/SearchBar.css 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SearchBar.css 2019-02-25 04:27:46 UTC (rev 242018)
@@ -53,6 +53,10 @@
background-color: white;
}
+.search-bar > input[type="search"]:placeholder-shown::-webkit-search-cancel-button {
+ display: none;
+}
+
@media (prefers-color-scheme: dark) {
:matches(.search-bar, .filter-bar) > input[type="search"],
.search-bar > input[type="search"]:not(:placeholder-shown) {
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SearchResultTreeElement.js (242017 => 242018)
--- trunk/Source/WebInspectorUI/UserInterface/Views/SearchResultTreeElement.js 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SearchResultTreeElement.js 2019-02-25 04:27:46 UTC (rev 242018)
@@ -45,7 +45,8 @@
// Use the original location, since those line/column offsets match the line text in title.
var textRange = sourceCodeTextRange.textRange;
- var searchTermIndex = textRange.startColumn;
+ let searchTermIndex = textRange.startColumn;
+ let searchTermLength = textRange.endColumn - textRange.startColumn;
// We should only have one line text ranges, so make sure that is the case.
console.assert(textRange.startLine === textRange.endLine);
@@ -59,10 +60,8 @@
} else
modifiedTitle = title;
- modifiedTitle = modifiedTitle.truncateEnd(searchTermIndex + searchTerm.length + charactersToShowAfterSearchMatch);
+ modifiedTitle = modifiedTitle.truncateEnd(searchTermIndex + searchTermLength + charactersToShowAfterSearchMatch);
- console.assert(modifiedTitle.substring(searchTermIndex, searchTermIndex + searchTerm.length).toLowerCase() === searchTerm.toLowerCase());
-
var highlightedTitle = document.createDocumentFragment();
highlightedTitle.append(modifiedTitle.substring(0, searchTermIndex));
@@ -69,10 +68,10 @@
var highlightSpan = document.createElement("span");
highlightSpan.className = "highlighted";
- highlightSpan.append(modifiedTitle.substring(searchTermIndex, searchTermIndex + searchTerm.length));
+ highlightSpan.append(modifiedTitle.substring(searchTermIndex, searchTermIndex + searchTermLength));
highlightedTitle.appendChild(highlightSpan);
- highlightedTitle.append(modifiedTitle.substring(searchTermIndex + searchTerm.length));
+ highlightedTitle.append(modifiedTitle.substring(searchTermIndex + searchTermLength));
return highlightedTitle;
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.css (242017 => 242018)
--- trunk/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.css 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.css 2019-02-25 04:27:46 UTC (rev 242018)
@@ -28,15 +28,14 @@
}
.sidebar > .panel.navigation.search > .search-bar {
+ display: flex;
+ align-items: center;
position: absolute;
top: 0;
left: 0;
right: 0;
-
- display: flex;
-
height: calc(var(--navigation-bar-height) - 1px);
-
+ margin: 0 6px;
white-space: nowrap;
overflow: hidden;
}
@@ -44,8 +43,9 @@
.sidebar > .panel.navigation.search > .search-bar > input[type="search"] {
display: flex;
flex: 1;
-
- margin: 3px 6px;
+ width: 100%;
+ margin: 0;
+ -webkit-margin-end: 4px;
}
.sidebar > .panel.navigation.search > .search-bar > input[type="search"]::-webkit-search-results-button {
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.js (242017 => 242018)
--- trunk/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.js 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.js 2019-02-25 04:27:46 UTC (rev 242018)
@@ -29,6 +29,12 @@
{
super("search", WI.UIString("Search"), true, true);
+ this._searchInputSettings = WI.SearchUtilities.createSettings("search-sidebar", {
+ handleChanged: (event) => {
+ this.focusSearchField(true);
+ },
+ });
+
var searchElement = document.createElement("div");
searchElement.classList.add("search-bar");
this.element.appendChild(searchElement);
@@ -43,6 +49,8 @@
this._inputElement.setAttribute("placeholder", WI.UIString("Search Resource Content"));
searchElement.appendChild(this._inputElement);
+ searchElement.appendChild(WI.SearchUtilities.createSettingsButton(this._searchInputSettings));
+
this._searchQuerySetting = new WI.Setting("search-sidebar-query", "");
this._inputElement.value = this._searchQuerySetting.value;
@@ -89,13 +97,11 @@
if (this._changedBanner)
this._changedBanner.remove();
- searchQuery = searchQuery.trim();
if (!searchQuery.length)
return;
- // FIXME: Provide UI to toggle regex and case sensitive searches.
- var isCaseSensitive = false;
- var isRegex = false;
+ let isCaseSensitive = !!this._searchInputSettings.caseSensitive.value;
+ let isRegex = !!this._searchInputSettings.regularExpression.value;
var updateEmptyContentPlaceholderTimeout = null;
@@ -130,7 +136,10 @@
function forEachMatch(searchQuery, lineContent, callback)
{
var lineMatch;
- var searchRegex = new RegExp(searchQuery.escapeForRegExp(), "gi");
+ let searchRegex = WI.SearchUtilities.regExpForString(searchQuery, {
+ caseSensitive: isCaseSensitive,
+ regularExpression: isRegex,
+ });
while ((searchRegex.lastIndex < lineContent.length) && (lineMatch = searchRegex.exec(lineContent)))
callback(lineMatch, searchRegex.lastIndex);
}
@@ -167,6 +176,9 @@
});
}
+ if (!resourceTreeElement.children.length)
+ this.contentTreeOutline.removeChild(resourceTreeElement);
+
updateEmptyContentPlaceholder.call(this);
}
@@ -220,6 +232,9 @@
});
}
+ if (!scriptTreeElement.children.length)
+ this.contentTreeOutline.removeChild(scriptTreeElement);
+
updateEmptyContentPlaceholder.call(this);
}
@@ -280,6 +295,9 @@
createTreeElementForMatchObject.call(this, matchObject, resourceTreeElement);
}
+ if (!resourceTreeElement.children.length)
+ this.contentTreeOutline.removeChild(resourceTreeElement);
+
updateEmptyContentPlaceholder.call(this);
}
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js (242017 => 242018)
--- trunk/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js 2019-02-25 04:27:46 UTC (rev 242018)
@@ -211,6 +211,12 @@
generalSettingsView.addSeparator();
+ let searchGroup = generalSettingsView.addGroup(WI.UIString("Search:", "Search: @ Settings", "Settings tab label for search related settings"));
+ searchGroup.addSetting(WI.settings.searchCaseSensitive, WI.UIString("Case Sensitive", "Case Sensitive @ Settings", "Settings tab checkbox label for whether searches should be case sensitive."));
+ searchGroup.addSetting(WI.settings.searchRegularExpression, WI.UIString("Regular _expression_", "Regular _expression_ @ Settings", "Settings tab checkbox label for whether searches should be treated as regular expressions."));
+
+ generalSettingsView.addSeparator();
+
const zoomLevels = [0.6, 0.8, 1, 1.2, 1.4, 1.6, 1.8, 2, 2.2, 2.4];
const zoomValues = zoomLevels.map((level) => [level, Number.percentageString(level, 0)]);
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js (242017 => 242018)
--- trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js 2019-02-25 04:27:46 UTC (rev 242018)
@@ -224,7 +224,7 @@
return;
}
- var queryRegex = new RegExp(query.escapeForRegExp(), "gi");
+ let queryRegex = WI.SearchUtilities.regExpForString(query, WI.SearchUtilities.defaultSettings);
var searchResults = [];
for (var i = 0; i < matches.length; ++i) {
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js (242017 => 242018)
--- trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js 2019-02-25 03:04:01 UTC (rev 242017)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js 2019-02-25 04:27:46 UTC (rev 242018)
@@ -338,7 +338,7 @@
}
// Go down the slow patch for all other text content.
- var queryRegex = new RegExp(query.escapeForRegExp(), "gi");
+ let queryRegex = WI.SearchUtilities.regExpForString(query, WI.SearchUtilities.defaultSettings);
var searchCursor = this._codeMirror.getSearchCursor(queryRegex, {line: 0, ch: 0}, false);
var boundBatchSearch = batchSearch.bind(this);
var numberOfSearchResultsDidChangeTimeout = null;