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

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

Issue 1899893003: [Devtools] JSONView implements Searchable interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
(Empty)
1 <html>
2 <head>
3 <script src="../inspector-test.js"></script>
4 <script src="../network-test.js"></script>
5 <script>
6 function test()
7 {
8 function testSearches(view, searches)
9 {
10 for (var search of searches) {
11 view._searchInputElement.value = search;
12 view._regexButton.setToggled(false);
13 view._caseSensitiveButton.setToggled(false);
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 }
24 }
25
26 function previewViewHandled(searches, callback, view)
27 {
28 var isSearchable = (view instanceof WebInspector.SearchableView);
29 var compontentView = view;
30 var typeName = "unknown";
31 if (isSearchable)
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
54 InspectorTest.addResult("Is Searchable: " + isSearchable);
55 InspectorTest.addResult("Type: " + typeName);
56
57 if (isSearchable)
58 testSearches(view, searches);
59
60 callback();
61 }
62
63 function trySearches(request, searches, callback)
64 {
65 InspectorTest.addSniffer(WebInspector.RequestPreviewView.prototype, "_pr eviewViewHandledForTest", previewViewHandled.bind(this, searches, callback));
66 var networkPanel = WebInspector.panels.network;
67 networkPanel._showRequest(request);
68 var itemView = networkPanel._networkItemView;
69 itemView._selectTab("preview");
70 }
71
72 function testType(contentType, content, searches, callback)
73 {
74 var url = "data:" + contentType + "," + encodeURIComponent(content);
75 InspectorTest.makeSimpleXHR("GET", url, true, function() {
76 var request = InspectorTest.findRequestsByURLPattern(new RegExp(url. escapeForRegExp()))[0];
77 request._resourceType = WebInspector.resourceTypes.Document;
78 trySearches(request, searches, callback);
79 });
80 }
81
82 InspectorTest.runTestSuite([
83 function plainTextTest(next)
84 {
85 testType("text/plain", "foo bar\nfoo bar", ["foo", /*"bar"*/], next) ;
86 },
87 function jsonTest(next)
88 {
89 testType("application/json", "[533,3223]", ["533", "322"], next);
90 },
91 function jsonSpecialMimeTest(next)
92 {
93 testType("application/vnd.document+json", "{foo0foo: 123}", ["foo"], next);
94 },
95 function xmlMultipleSearchTest(next)
96 {
97 testType("text/xml", "<bar><foo/></bar>", ["bar", "foo", "bar"], ne xt);
98 },
99 function xmlSingleSearchTest(next)
100 {
101 testType("text/xml", "<bar></bar>", ["bar"], next);
102 },
103 function xmlCommentSearchTest(next)
104 {
105 testType("text/xml", "<bar><!-- TEST --></bar>", ["TEST", "/bar", "b ar"], next);
106 },
107 function xmlCDATASearchTest(next)
108 {
109 testType("text/xml", "<a><![CDATA[GGG]]><g tee=\"gee\">tee</g></a>", ["GGG", "tee", "CDATA"], next);
110 },
111 function xmlMimeTypeJsonTest(next)
112 {
113 testType("text/xml", "{foo0: 'barr', 'barr': 'fooo'}", ["fooo", "bar "], next);
114 }
115 ]);
116 }
117 </script>
118 </head>
119 <body onload="runTest()">
120 <p>Tests that resources with JSON MIME types are previewed with the JSON viewer. </p>
121 </body>
122 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698