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

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 createNetworkRequest(mimeType, content)
9 {
10 InspectorTest.addResult("Creating a NetworkRequest with mimeType: " + mi meType);
11 var request = new WebInspector.NetworkRequest(WebInspector.targetManager .mainTarget(), 0, 'http://localhost');
12 request.mimeType = mimeType;
13 request._content = content;
14 return request;
15 }
16
17 function getViewName(previewer)
18 {
19 if (!previewer)
20 return "** NONE **";
21 if (previewer instanceof WebInspector.SearchableView)
22 return "SearchableView > " + previewer._searchProvider.contentElemen t.className;
23 return previewer.contentElement.className;
24 }
25
26 function testPreviewer(request, searches)
27 {
28 return new Promise(function(done) {
29 var previewView = new WebInspector.RequestPreviewView(request, new W ebInspector.RequestResponseView(request));
30
31 previewView._createPreviewView(function(previewer) {
32 InspectorTest.addResult("Its previewer type: " + getViewName(pre viewer));
33 if (previewer instanceof WebInspector.SearchableView) {
34 previewer._searchProvider._initialize();
35 InspectorTest.addResult("Inner searchable box is: " + getVie wName(previewer._searchProvider));
36 for (var search of searches) {
37 previewer._searchInputElement.value = search;
38 previewer._regexButton.setToggled(false);
39 previewer._caseSensitiveButton.setToggled(false);
40 previewer.showSearchField();
41 InspectorTest.addResult("Should have found and highlight ed all: " + search);
42 var foundItems = previewer._searchProvider._section._con tentElement.getElementsByClassName('highlighted-search-result');
43 for (var item of foundItems)
44 InspectorTest.dumpDeepInnerHTML(item);
45 }
46 }
47 done();
48 });
49 });
50 }
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([
58 function test1(next)
59 {
60 testType("application/json", "[533,3223]", ["533", "322"], next);
61 },
62 function test2(next)
63 {
64 testType("application/vnd.document+json", "{foo0foo: 123}", ["foo"], next);
65 },
66 function test3(next)
67 {
68 testType("text/xml", "<bar><foo/></bar>", ["bar"], next);
69 },
70 function test4(next)
71 {
72 testType("text/xml", "{foo0: 'barr', 'barr': 'fooo'}", ["fooo", "bar "], next);
73 },
74 ]);
75 }
76 </script>
77 </head>
78 <body onload="runTest()">
79 <p>Tests that resources with JSON MIME types are previewed with the JSON viewer. </p>
80 </body>
81 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698