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

Side by Side 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, 7 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 unified diff | Download patch
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script src="../inspector-test.js"></script> 3 <script src="../inspector-test.js"></script>
4 <script src="../network-test.js"></script> 4 <script src="../network-test.js"></script>
5 <script> 5 <script>
6 function test() 6 function test()
7 { 7 {
8 function createNetworkRequest(mimeType, content) 8 function testSearches(view, searches)
9 { 9 {
10 InspectorTest.addResult("Creating a NetworkRequest with mimeType: " + mi meType); 10 for (var search of searches) {
11 var request = new WebInspector.NetworkRequest(WebInspector.targetManager .mainTarget(), 0, 'http://localhost'); 11 view._searchInputElement.value = search;
12 request.mimeType = mimeType; 12 view._regexButton.setToggled(false);
13 request._content = content; 13 view._caseSensitiveButton.setToggled(false);
14 return request; 14 view.showSearchField();
15 InspectorTest.addResult("Should have found and highlighted all: " + search);
16
17 var foundItems = view.element.querySelectorAll("* /deep/ .highlighte d-search-result");
18 InspectorTest.addResult("Normal search found " + foundItems.length + " results in dom.");
19
20 foundItems = view.element.querySelectorAll("* /deep/ .cm-search-high light-start");
21 InspectorTest.addResult("CodeMirror search found " + foundItems.leng th + " results in dom.");
22 InspectorTest.addResult("");
23 }
15 } 24 }
16 25
17 function getViewName(previewer) 26 function previewViewHandled(searches, callback, view)
18 { 27 {
19 if (!previewer) 28 var isSearchable = (view instanceof WebInspector.SearchableView);
20 return "** NONE **"; 29 var compontentView = view;
21 if (previewer instanceof WebInspector.SearchableView) 30 var typeName = "unknown";
22 return "SearchableView > " + previewer._searchProvider.contentElemen t.className; 31 if (isSearchable)
23 return previewer.contentElement.className; 32 compontentView = view._searchProvider;
33
34 if (compontentView instanceof WebInspector.ResourceSourceFrame) {
35 typeName = "ResourceSourceFrame";
36 compontentView._ensureContentLoaded();
37 if (!compontentView.loaded) {
38 // try again when content is loaded.
39 InspectorTest.addSniffer(compontentView, "onTextEditorContentLoa ded", previewViewHandled.bind(this, searches, callback, view));
40 return;
41 }
42 } else if (compontentView instanceof WebInspector.XMLView)
43 typeName = "XMLView";
44 else if(compontentView instanceof WebInspector.JSONView)
45 typeName = "JSONView";
46 else if(compontentView instanceof WebInspector.RequestHTMLView)
47 typeName = "RequestHTMLView";
48 else if(compontentView instanceof WebInspector.EmptyWidget)
49 typeName = "EmptyWidget";
50 else if(compontentView instanceof WebInspector.RequestHTMLView)
51 typeName = "RequestHTMLView";
52
53 InspectorTest.addResult("Is Searchable: " + isSearchable);
54 InspectorTest.addResult("Type: " + typeName);
55
56 if (isSearchable)
57 testSearches(view, searches);
58
59 callback();
24 } 60 }
lushnikov 2016/05/05 00:10:34 nit: new line after }
allada 2016/05/05 19:17:59 Done.
25 61 function trySearches(request, searches, callback)
26 function testPreviewer(request, searches)
27 { 62 {
28 return new Promise(function(done) { 63 InspectorTest.addSniffer(WebInspector.RequestPreviewView.prototype, "_pr eviewViewHandledForTest", previewViewHandled.bind(this, searches, callback));
29 var previewView = new WebInspector.RequestPreviewView(request, new W ebInspector.RequestResponseView(request)); 64 var networkPanel = WebInspector.panels.network;
30 65 networkPanel._showRequest(request);
31 previewView._createPreviewView(function(previewer) { 66 var itemView = networkPanel._networkItemView;
32 InspectorTest.addResult("Its previewer type: " + getViewName(pre viewer)); 67 itemView._selectTab("preview");
33 if (previewer instanceof WebInspector.SearchableView) { 68 }
lushnikov 2016/05/05 00:10:34 nit: new line after }
allada 2016/05/05 19:17:59 Done.
34 previewer._searchProvider._initialize(); 69 function testType(contentType, content, searches, callback)
35 InspectorTest.addResult("Inner searchable box is: " + getVie wName(previewer._searchProvider)); 70 {
36 for (var search of searches) { 71 var url = "data:" + contentType + "," + encodeURIComponent(content);
37 previewer._searchInputElement.value = search; 72 InspectorTest.makeSimpleXHR("GET", url, true, function() {
38 previewer._regexButton.setToggled(false); 73 var request = InspectorTest.findRequestsByURLPattern(new RegExp(url. escapeForRegExp()))[0];
39 previewer._caseSensitiveButton.setToggled(false); 74 request._resourceType = WebInspector.resourceTypes.Document;
40 previewer.showSearchField(); 75 trySearches(request, searches, callback);
41 InspectorTest.addResult("Should have found and highlight ed all: " + search);
42 var foundItems = previewer._searchProvider._treeOutline. _contentElement.getElementsByClassName('highlighted-search-result');
43 for (var item of foundItems)
44 InspectorTest.dumpDeepInnerHTML(item);
45 }
46 }
47 done();
48 });
49 }); 76 });
50 } 77 }
lushnikov 2016/05/05 00:10:34 nit: new line after }
allada 2016/05/05 19:17:59 Done.
51
52 function testType(contentType, content, searches, callback)
53 {
54 var request = createNetworkRequest(contentType, content);
55 testPreviewer(request, searches).then(callback);
56 }
57 InspectorTest.runTestSuite([ 78 InspectorTest.runTestSuite([
58 function test1(next) 79 function plainTextTest(next)
80 {
81 testType("text/plain", "foo bar\nfoo bar", ["foo", /*"bar"*/], next) ;
82 },
83 function jsonTest(next)
59 { 84 {
60 testType("application/json", "[533,3223]", ["533", "322"], next); 85 testType("application/json", "[533,3223]", ["533", "322"], next);
61 }, 86 },
62 function test2(next) 87 function jsonSpecialMimeTest(next)
63 { 88 {
64 testType("application/vnd.document+json", "{foo0foo: 123}", ["foo"], next); 89 testType("application/vnd.document+json", "{foo0foo: 123}", ["foo"], next);
65 }, 90 },
66 function test3(next) 91 function xmlMultipleSearchTest(next)
67 { 92 {
68 testType("text/xml", "<bar><foo/></bar>", ["bar"], next); 93 testType("text/xml", "<bar><foo/></bar>", ["bar", "foo", "bar"], ne xt);
69 }, 94 },
70 function test4(next) 95 function xmlSingleSearchTest(next)
96 {
97 testType("text/xml", "<bar></bar>", ["bar"], next);
98 },
99 function xmlCommentSearchTest(next)
100 {
101 testType("text/xml", "<bar><!-- TEST --></bar>", ["TEST", "/bar", "b ar"], next);
102 },
103 function xmlCDATASearchTest(next)
104 {
105 testType("text/xml", "<a><![CDATA[GGG]]><g tee=\"gee\">tee</g></a>", ["GGG", "tee", "CDATA"], next);
106 },
107 function xmlMimeTypeJsonTest(next)
71 { 108 {
72 testType("text/xml", "{foo0: 'barr', 'barr': 'fooo'}", ["fooo", "bar "], next); 109 testType("text/xml", "{foo0: 'barr', 'barr': 'fooo'}", ["fooo", "bar "], next);
73 }, 110 }
74 ]); 111 ]);
75 } 112 }
76 </script> 113 </script>
77 </head> 114 </head>
78 <body onload="runTest()"> 115 <body onload="runTest()">
79 <p>Tests that resources with JSON MIME types are previewed with the JSON viewer. </p> 116 <p>Tests that resources with JSON MIME types are previewed with the JSON viewer. </p>
80 </body> 117 </body>
81 </html> 118 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698