Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/inspector/network/preview-searchable.html

Issue 1942683006: [Devtools] XMLView now searchable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@FIND_IN_JSON_FINAL
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/inspector/network/preview-searchable.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/network/preview-searchable.html b/third_party/WebKit/LayoutTests/http/tests/inspector/network/preview-searchable.html
index 0c31059c4bdeb8efbb4e759ed685cb673560d969..dea1b266c9228f861936fe6ecd70928615bd5c2b 100644
--- a/third_party/WebKit/LayoutTests/http/tests/inspector/network/preview-searchable.html
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector/network/preview-searchable.html
@@ -5,72 +5,106 @@
<script>
function test()
{
- function createNetworkRequest(mimeType, content)
+ function testSearches(view, searches)
{
- InspectorTest.addResult("Creating a NetworkRequest with mimeType: " + mimeType);
- var request = new WebInspector.NetworkRequest(WebInspector.targetManager.mainTarget(), 0, 'http://localhost');
- request.mimeType = mimeType;
- request._content = content;
- return request;
- }
+ for (var search of searches) {
+ view._searchInputElement.value = search;
+ view._regexButton.setToggled(false);
+ view._caseSensitiveButton.setToggled(false);
+ view.showSearchField();
+ InspectorTest.addResult("Should have found and highlighted all: " + search);
- function getViewName(previewer)
- {
- if (!previewer)
- return "** NONE **";
- if (previewer instanceof WebInspector.SearchableView)
- return "SearchableView > " + previewer._searchProvider.contentElement.className;
- return previewer.contentElement.className;
+ var foundItems = view.element.querySelectorAll("* /deep/ .highlighted-search-result, * /deep/ .cm-search-highlight");
+ for (var item of foundItems)
+ InspectorTest.dumpDeepInnerHTML(item);
+ }
}
- function testPreviewer(request, searches)
+ function previewViewHandled(searches, callback, view)
{
- return new Promise(function(done) {
- var previewView = new WebInspector.RequestPreviewView(request, new WebInspector.RequestResponseView(request));
+ var isSearchable = (view instanceof WebInspector.SearchableView);
+ var compontentView = view;
+ var typeName = "unknown";
+ if (isSearchable)
+ compontentView = view._searchProvider;
- previewView._createPreviewView(function(previewer) {
- InspectorTest.addResult("Its previewer type: " + getViewName(previewer));
- if (previewer instanceof WebInspector.SearchableView) {
- previewer._searchProvider._initialize();
- InspectorTest.addResult("Inner searchable box is: " + getViewName(previewer._searchProvider));
- for (var search of searches) {
- previewer._searchInputElement.value = search;
- previewer._regexButton.setToggled(false);
- previewer._caseSensitiveButton.setToggled(false);
- previewer.showSearchField();
- InspectorTest.addResult("Should have found and highlighted all: " + search);
- var foundItems = previewer._searchProvider._treeOutline._contentElement.getElementsByClassName('highlighted-search-result');
- for (var item of foundItems)
- InspectorTest.dumpDeepInnerHTML(item);
- }
- }
- done();
- });
- });
- }
+ if (compontentView instanceof WebInspector.ResourceSourceFrame) {
+ typeName = "ResourceSourceFrame";
+ compontentView._ensureContentLoaded();
+ if (!compontentView.loaded) {
+ // try again when content is loaded.
+ InspectorTest.addSniffer(compontentView, "onTextEditorContentLoaded", previewViewHandled.bind(this, searches, callback, view));
+ return;
+ }
+ } else if (compontentView instanceof WebInspector.XMLView)
+ typeName = "XMLView";
+ else if(compontentView instanceof WebInspector.JSONView)
+ typeName = "JSONView";
+ else if(compontentView instanceof WebInspector.RequestHTMLView)
+ typeName = "RequestHTMLView";
+ else if(compontentView instanceof WebInspector.EmptyWidget)
+ typeName = "EmptyWidget";
+ else if(compontentView instanceof WebInspector.RequestHTMLView)
+ typeName = "RequestHTMLView";
+
+ InspectorTest.addResult("Is Searchable: " + isSearchable);
+ InspectorTest.addResult("Type: " + typeName);
+ if (isSearchable)
+ testSearches(view, searches);
+
+ callback();
+ }
+ function trySearches(request, searches, callback)
+ {
+ InspectorTest.addSniffer(WebInspector.RequestPreviewView.prototype, "_previewViewHandledForTest", previewViewHandled.bind(this, searches, callback));
+ var networkPanel = WebInspector.panels.network;
+ networkPanel._showRequest(request);
+ var itemView = networkPanel._networkItemView;
+ itemView._selectTab("preview");
+ }
function testType(contentType, content, searches, callback)
{
- var request = createNetworkRequest(contentType, content);
- testPreviewer(request, searches).then(callback);
+ var url = "data:" + contentType + "," + encodeURIComponent(content);
+ InspectorTest.makeSimpleXHR("GET", url, true, function() {
+ var request = InspectorTest.findRequestsByURLPattern(new RegExp(url.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&')))[0];
allada 2016/05/03 18:22:55 I could not figure out if we have a regex escape f
lushnikov 2016/05/04 17:00:47 String.prototype.escapeForRegExp should work
allada 2016/05/04 21:22:35 Done.
+ request._resourceType = WebInspector.resourceTypes.Document;
+ trySearches(request, searches, callback);
+ });
}
InspectorTest.runTestSuite([
- function test1(next)
+ function plainTextTest(next)
+ {
+ testType("text/plain", "foo bar\nfoo bar", ["foo", /*"bar"*/], next);
+ },
+ function jsonTest(next)
{
testType("application/json", "[533,3223]", ["533", "322"], next);
},
- function test2(next)
+ function jsonSpecialMimeTest(next)
{
testType("application/vnd.document+json", "{foo0foo: 123}", ["foo"], next);
},
- function test3(next)
+ function xmlMultipleSearchTest(next)
{
- testType("text/xml", "<bar><foo/></bar>", ["bar"], next);
+ testType("text/xml", "<bar><foo/></bar>", ["bar", "foo", "bar"], next);
},
- function test4(next)
+ function xmlSingleSearchTest(next)
{
- testType("text/xml", "{foo0: 'barr', 'barr': 'fooo'}", ["fooo", "bar"], next);
+ testType("text/xml", "<bar></bar>", ["bar"], next);
+ },
+ function xmlCommentSearchTest(next)
+ {
+ testType("text/xml", "<bar><!-- TEST --></bar>", ["TEST", "/bar", "bar"], next);
},
+ function xmlCDATASearchTest(next)
+ {
+ testType("text/xml", "<a><![CDATA[GGG]]><g tee=\"gee\">tee</g></a>", ["GGG", "tee", "CDATA"], next);
+ },
+ function xmlMimeTypeJsonTest(next)
+ {
+ testType("text/xml", "{foo0: 'barr', 'barr': 'fooo'}", ["fooo", "bar"], next);
+ }
]);
}
</script>

Powered by Google App Engine
This is Rietveld 408576698