| 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 testSearches(view, searches) | 8 function testSearches(view, searches) |
| 9 { | 9 { |
| 10 for (var search of searches) { | 10 for (var search of searches) { |
| 11 view._searchInputElement.value = search; | 11 view._searchInputElement.value = search; |
| 12 view._regexButton.setToggled(false); | 12 view._regexButton.setToggled(false); |
| 13 view._caseSensitiveButton.setToggled(false); | 13 view._caseSensitiveButton.setToggled(false); |
| 14 view.showSearchField(); | 14 view.showSearchField(); |
| 15 InspectorTest.addResult("Should have found and highlighted all: " +
search); | 15 InspectorTest.addResult("Should have found and highlighted all: " +
search); |
| 16 | 16 |
| 17 var foundItems = view.element.querySelectorAll("* /deep/ .highlighte
d-search-result"); | 17 var foundItems = view.element.querySelectorAll("* /deep/ .highlighte
d-search-result"); |
| 18 InspectorTest.addResult("Normal search found " + foundItems.length +
" results in dom."); | 18 InspectorTest.addResult("Normal search found " + foundItems.length +
" results in dom."); |
| 19 | 19 |
| 20 foundItems = view.element.querySelectorAll("* /deep/ .cm-search-high
light-start"); | 20 foundItems = view.element.querySelectorAll("* /deep/ .cm-search-high
light-start"); |
| 21 InspectorTest.addResult("CodeMirror search found " + foundItems.leng
th + " results in dom."); | 21 InspectorTest.addResult("CodeMirror search found " + foundItems.leng
th + " results in dom."); |
| 22 InspectorTest.addResult(""); | 22 InspectorTest.addResult(""); |
| 23 } | 23 } |
| 24 } | 24 } |
| 25 | 25 |
| 26 function previewViewHandled(searches, callback, view) | 26 function previewViewHandled(searches, callback, view) |
| 27 { | 27 { |
| 28 var isSearchable = (view instanceof WebInspector.SearchableView); | 28 var isSearchable = (view instanceof UI.SearchableView); |
| 29 var compontentView = view; | 29 var compontentView = view; |
| 30 var typeName = "unknown"; | 30 var typeName = "unknown"; |
| 31 if (isSearchable) | 31 if (isSearchable) |
| 32 compontentView = view._searchProvider; | 32 compontentView = view._searchProvider; |
| 33 | 33 |
| 34 if (compontentView instanceof WebInspector.ResourceSourceFrame) { | 34 if (compontentView instanceof SourceFrame.ResourceSourceFrame) { |
| 35 typeName = "ResourceSourceFrame"; | 35 typeName = "ResourceSourceFrame"; |
| 36 compontentView._ensureContentLoaded(); | 36 compontentView._ensureContentLoaded(); |
| 37 if (!compontentView.loaded) { | 37 if (!compontentView.loaded) { |
| 38 // try again when content is loaded. | 38 // try again when content is loaded. |
| 39 InspectorTest.addSniffer(compontentView, "onTextEditorContentSet
", previewViewHandled.bind(this, searches, callback, view)); | 39 InspectorTest.addSniffer(compontentView, "onTextEditorContentSet
", previewViewHandled.bind(this, searches, callback, view)); |
| 40 return; | 40 return; |
| 41 } | 41 } |
| 42 } else if (compontentView instanceof WebInspector.XMLView) { | 42 } else if (compontentView instanceof Network.XMLView) { |
| 43 typeName = "XMLView"; | 43 typeName = "XMLView"; |
| 44 } else if(compontentView instanceof WebInspector.JSONView) { | 44 } else if(compontentView instanceof Network.JSONView) { |
| 45 typeName = "JSONView"; | 45 typeName = "JSONView"; |
| 46 } else if(compontentView instanceof WebInspector.RequestHTMLView) { | 46 } else if(compontentView instanceof Network.RequestHTMLView) { |
| 47 typeName = "RequestHTMLView"; | 47 typeName = "RequestHTMLView"; |
| 48 } else if(compontentView instanceof WebInspector.EmptyWidget) { | 48 } else if(compontentView instanceof UI.EmptyWidget) { |
| 49 typeName = "EmptyWidget"; | 49 typeName = "EmptyWidget"; |
| 50 } else if(compontentView instanceof WebInspector.RequestHTMLView) { | 50 } else if(compontentView instanceof Network.RequestHTMLView) { |
| 51 typeName = "RequestHTMLView"; | 51 typeName = "RequestHTMLView"; |
| 52 } | 52 } |
| 53 | 53 |
| 54 InspectorTest.addResult("Is Searchable: " + isSearchable); | 54 InspectorTest.addResult("Is Searchable: " + isSearchable); |
| 55 InspectorTest.addResult("Type: " + typeName); | 55 InspectorTest.addResult("Type: " + typeName); |
| 56 | 56 |
| 57 if (isSearchable) | 57 if (isSearchable) |
| 58 testSearches(view, searches); | 58 testSearches(view, searches); |
| 59 | 59 |
| 60 callback(); | 60 callback(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 function trySearches(request, searches, callback) | 63 function trySearches(request, searches, callback) |
| 64 { | 64 { |
| 65 InspectorTest.addSniffer(WebInspector.RequestPreviewView.prototype, "_pr
eviewViewHandledForTest", previewViewHandled.bind(this, searches, callback)); | 65 InspectorTest.addSniffer(Network.RequestPreviewView.prototype, "_preview
ViewHandledForTest", previewViewHandled.bind(this, searches, callback)); |
| 66 var networkPanel = WebInspector.panels.network; | 66 var networkPanel = UI.panels.network; |
| 67 networkPanel._showRequest(request); | 67 networkPanel._showRequest(request); |
| 68 var itemView = networkPanel._networkItemView; | 68 var itemView = networkPanel._networkItemView; |
| 69 itemView._selectTab("preview"); | 69 itemView._selectTab("preview"); |
| 70 } | 70 } |
| 71 | 71 |
| 72 function testType(contentType, content, searches, callback) | 72 function testType(contentType, content, searches, callback) |
| 73 { | 73 { |
| 74 var url = "data:" + contentType + "," + encodeURIComponent(content); | 74 var url = "data:" + contentType + "," + encodeURIComponent(content); |
| 75 InspectorTest.makeSimpleXHR("GET", url, true, function() { | 75 InspectorTest.makeSimpleXHR("GET", url, true, function() { |
| 76 var request = InspectorTest.findRequestsByURLPattern(new RegExp(url.
escapeForRegExp()))[0]; | 76 var request = InspectorTest.findRequestsByURLPattern(new RegExp(url.
escapeForRegExp()))[0]; |
| 77 request._resourceType = WebInspector.resourceTypes.Document; | 77 request._resourceType = Common.resourceTypes.Document; |
| 78 trySearches(request, searches, callback); | 78 trySearches(request, searches, callback); |
| 79 }); | 79 }); |
| 80 } | 80 } |
| 81 | 81 |
| 82 InspectorTest.runTestSuite([ | 82 InspectorTest.runTestSuite([ |
| 83 function plainTextTest(next) | 83 function plainTextTest(next) |
| 84 { | 84 { |
| 85 testType("text/plain", "foo bar\nfoo bar", ["foo", /*"bar"*/], next)
; | 85 testType("text/plain", "foo bar\nfoo bar", ["foo", /*"bar"*/], next)
; |
| 86 }, | 86 }, |
| 87 function jsonTest(next) | 87 function jsonTest(next) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 113 testType("text/xml", "{foo0: 'barr', 'barr': 'fooo'}", ["fooo", "bar
"], next); | 113 testType("text/xml", "{foo0: 'barr', 'barr': 'fooo'}", ["fooo", "bar
"], next); |
| 114 } | 114 } |
| 115 ]); | 115 ]); |
| 116 } | 116 } |
| 117 </script> | 117 </script> |
| 118 </head> | 118 </head> |
| 119 <body onload="runTest()"> | 119 <body onload="runTest()"> |
| 120 <p>Tests that resources with JSON MIME types are previewed with the JSON viewer.
</p> | 120 <p>Tests that resources with JSON MIME types are previewed with the JSON viewer.
</p> |
| 121 </body> | 121 </body> |
| 122 </html> | 122 </html> |
| OLD | NEW |