| 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
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..37af28d4fc5a853113ce5eb9d91f37eb5bfd677e
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/inspector/network/preview-searchable.html
|
| @@ -0,0 +1,81 @@
|
| +<html>
|
| +<head>
|
| +<script src="../inspector-test.js"></script>
|
| +<script src="../network-test.js"></script>
|
| +<script>
|
| +function test()
|
| +{
|
| + function createNetworkRequest(mimeType, content)
|
| + {
|
| + 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;
|
| + }
|
| +
|
| + function getViewName(previewer)
|
| + {
|
| + if (!previewer)
|
| + return "** NONE **";
|
| + if (previewer instanceof WebInspector.SearchableView)
|
| + return "SearchableView > " + previewer._searchProvider.contentElement.className;
|
| + return previewer.contentElement.className;
|
| + }
|
| +
|
| + function testPreviewer(request, searches)
|
| + {
|
| + return new Promise(function(done) {
|
| + var previewView = new WebInspector.RequestPreviewView(request, new WebInspector.RequestResponseView(request));
|
| +
|
| + 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._section._contentElement.getElementsByClassName('highlighted-search-result');
|
| + for (var item of foundItems)
|
| + InspectorTest.dumpDeepInnerHTML(item);
|
| + }
|
| + }
|
| + done();
|
| + });
|
| + });
|
| + }
|
| +
|
| + function testType(contentType, content, searches, callback)
|
| + {
|
| + var request = createNetworkRequest(contentType, content);
|
| + testPreviewer(request, searches).then(callback);
|
| + }
|
| + InspectorTest.runTestSuite([
|
| + function test1(next)
|
| + {
|
| + testType("application/json", "[533,3223]", ["533", "322"], next);
|
| + },
|
| + function test2(next)
|
| + {
|
| + testType("application/vnd.document+json", "{foo0foo: 123}", ["foo"], next);
|
| + },
|
| + function test3(next)
|
| + {
|
| + testType("text/xml", "<bar><foo/></bar>", ["bar"], next);
|
| + },
|
| + function test4(next)
|
| + {
|
| + testType("text/xml", "{foo0: 'barr', 'barr': 'fooo'}", ["fooo", "bar"], next);
|
| + },
|
| + ]);
|
| +}
|
| +</script>
|
| +</head>
|
| +<body onload="runTest()">
|
| +<p>Tests that resources with JSON MIME types are previewed with the JSON viewer.</p>
|
| +</body>
|
| +</html>
|
|
|