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

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";
lushnikov 2016/05/06 18:46:25 these should be wrapped in { } per style guide
allada 2016/05/06 19:31:50 Done.
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();
60 }
61
62 function trySearches(request, searches, callback)
63 {
64 InspectorTest.addSniffer(WebInspector.RequestPreviewView.prototype, "_pr eviewViewHandledForTest", previewViewHandled.bind(this, searches, callback));
65 var networkPanel = WebInspector.panels.network;
66 networkPanel._showRequest(request);
67 var itemView = networkPanel._networkItemView;
68 itemView._selectTab("preview");
69 }
70
71 function testType(contentType, content, searches, callback)
72 {
73 var url = "data:" + contentType + "," + encodeURIComponent(content);
74 InspectorTest.makeSimpleXHR("GET", url, true, function() {
75 var request = InspectorTest.findRequestsByURLPattern(new RegExp(url. escapeForRegExp()))[0];
76 request._resourceType = WebInspector.resourceTypes.Document;
77 trySearches(request, searches, callback);
78 });
79 }
80
81 InspectorTest.runTestSuite([
82 function plainTextTest(next)
83 {
84 testType("text/plain", "foo bar\nfoo bar", ["foo", /*"bar"*/], next) ;
85 },
86 function jsonTest(next)
87 {
88 testType("application/json", "[533,3223]", ["533", "322"], next);
89 },
90 function jsonSpecialMimeTest(next)
91 {
92 testType("application/vnd.document+json", "{foo0foo: 123}", ["foo"], next);
93 },
94 function xmlMultipleSearchTest(next)
95 {
96 testType("text/xml", "<bar><foo/></bar>", ["bar", "foo", "bar"], ne xt);
97 },
98 function xmlSingleSearchTest(next)
99 {
100 testType("text/xml", "<bar></bar>", ["bar"], next);
101 },
102 function xmlCommentSearchTest(next)
103 {
104 testType("text/xml", "<bar><!-- TEST --></bar>", ["TEST", "/bar", "b ar"], next);
105 },
106 function xmlCDATASearchTest(next)
107 {
108 testType("text/xml", "<a><![CDATA[GGG]]><g tee=\"gee\">tee</g></a>", ["GGG", "tee", "CDATA"], next);
109 },
110 function xmlMimeTypeJsonTest(next)
111 {
112 testType("text/xml", "{foo0: 'barr', 'barr': 'fooo'}", ["fooo", "bar "], next);
113 }
114 ]);
115 }
116 </script>
117 </head>
118 <body onload="runTest()">
119 <p>Tests that resources with JSON MIME types are previewed with the JSON viewer. </p>
120 </body>
121 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698