| OLD | NEW |
| 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 createNetworkRequestWithJSONMIMEType(type) | 8 function createNetworkRequestWithJSONMIMEType(type) |
| 9 { | 9 { |
| 10 InspectorTest.addResult("Creating a NetworkRequest with type: " + type); | 10 InspectorTest.addResult("Creating a NetworkRequest with type: " + type); |
| 11 var request = new WebInspector.NetworkRequest(WebInspector.targetManager
.mainTarget(), 0, 'http://localhost'); | 11 var request = new SDK.NetworkRequest(SDK.targetManager.mainTarget(), 0,
'http://localhost'); |
| 12 request.mimeType = type; | 12 request.mimeType = type; |
| 13 request._content = '{"number": 42}'; | 13 request._content = '{"number": 42}'; |
| 14 return request; | 14 return request; |
| 15 } | 15 } |
| 16 | 16 |
| 17 function testPreviewer(request) | 17 function testPreviewer(request) |
| 18 { | 18 { |
| 19 return new Promise(function(done) { | 19 return new Promise(function(done) { |
| 20 var previewView = new WebInspector.RequestPreviewView(request, null)
; | 20 var previewView = new Network.RequestPreviewView(request, null); |
| 21 | 21 |
| 22 previewView._createPreviewView(function(previewer) { | 22 previewView._createPreviewView(function(previewer) { |
| 23 InspectorTest.addResult("Its previewer is searchable: " + (previ
ewer && previewer instanceof WebInspector.SearchableView)); | 23 InspectorTest.addResult("Its previewer is searchable: " + (previ
ewer && previewer instanceof UI.SearchableView)); |
| 24 InspectorTest.addResult("Its previewer is the JSON previewer: "
+ (previewer && previewer._searchProvider && previewer._searchProvider instanceo
f WebInspector.JSONView)); | 24 InspectorTest.addResult("Its previewer is the JSON previewer: "
+ (previewer && previewer._searchProvider && previewer._searchProvider instanceo
f Network.JSONView)); |
| 25 done(); | 25 done(); |
| 26 }); | 26 }); |
| 27 }); | 27 }); |
| 28 } | 28 } |
| 29 | 29 |
| 30 function testType(contentType, callback) | 30 function testType(contentType, callback) |
| 31 { | 31 { |
| 32 var request = createNetworkRequestWithJSONMIMEType(contentType); | 32 var request = createNetworkRequestWithJSONMIMEType(contentType); |
| 33 testPreviewer(request).then(callback); | 33 testPreviewer(request).then(callback); |
| 34 } | 34 } |
| 35 InspectorTest.runTestSuite([ | 35 InspectorTest.runTestSuite([ |
| 36 function test1(next) | 36 function test1(next) |
| 37 { | 37 { |
| 38 testType("application/json", next); | 38 testType("application/json", next); |
| 39 }, | 39 }, |
| 40 function test2(next) | 40 function test2(next) |
| 41 { | 41 { |
| 42 testType("application/vnd.document+json", next); | 42 testType("application/vnd.document+json", next); |
| 43 }, | 43 }, |
| 44 ]); | 44 ]); |
| 45 } | 45 } |
| 46 </script> | 46 </script> |
| 47 </head> | 47 </head> |
| 48 <body onload="runTest()"> | 48 <body onload="runTest()"> |
| 49 <p>Tests that resources with JSON MIME types are previewed with the JSON viewer.
</p> | 49 <p>Tests that resources with JSON MIME types are previewed with the JSON viewer.
</p> |
| 50 </body> | 50 </body> |
| 51 </html> | 51 </html> |
| OLD | NEW |