Index: content/browser/loader/mime_type_resource_handler_unittest.cc |
diff --git a/content/browser/loader/mime_type_resource_handler_unittest.cc b/content/browser/loader/mime_type_resource_handler_unittest.cc |
index ca9de0b4a77373b57b8254ed39c15d3cbf07c7fa..0943f266c5c51af0015d83b0cdab8388b04c63b6 100644 |
--- a/content/browser/loader/mime_type_resource_handler_unittest.cc |
+++ b/content/browser/loader/mime_type_resource_handler_unittest.cc |
@@ -216,10 +216,6 @@ class MimeTypeResourceHandlerTest : public testing::Test { |
void set_plugin_stale(bool plugin_stale) { plugin_stale_ = plugin_stale; } |
- bool TestStreamIsIntercepted(bool allow_download, |
- bool must_download, |
- ResourceType request_resource_type); |
- |
std::string TestAcceptHeaderSetting(ResourceType request_resource_type); |
std::string TestAcceptHeaderSettingWithURLRequest( |
ResourceType request_resource_type, |
@@ -234,51 +230,6 @@ class MimeTypeResourceHandlerTest : public testing::Test { |
TestBrowserThreadBundle thread_bundle_; |
}; |
-bool MimeTypeResourceHandlerTest::TestStreamIsIntercepted( |
- bool allow_download, |
- bool must_download, |
- ResourceType request_resource_type) { |
- net::URLRequestContext context; |
- std::unique_ptr<net::URLRequest> request(context.CreateRequest( |
- GURL("http://www.google.com"), net::DEFAULT_PRIORITY, nullptr)); |
- bool is_main_frame = request_resource_type == RESOURCE_TYPE_MAIN_FRAME; |
- ResourceRequestInfo::AllocateForTesting( |
- request.get(), |
- request_resource_type, |
- nullptr, // context |
- 0, // render_process_id |
- 0, // render_view_id |
- 0, // render_frame_id |
- is_main_frame, // is_main_frame |
- false, // parent_is_main_frame |
- allow_download, // allow_download |
- true, // is_async |
- false); // is_using_lofi |
- |
- TestResourceDispatcherHost host(stream_has_handler_); |
- TestResourceDispatcherHostDelegate host_delegate(must_download); |
- host.SetDelegate(&host_delegate); |
- |
- TestFakePluginService plugin_service(plugin_available_, plugin_stale_); |
- std::unique_ptr<ResourceHandler> mime_sniffing_handler( |
- new MimeTypeResourceHandler( |
- std::unique_ptr<ResourceHandler>(new TestResourceHandler()), &host, |
- &plugin_service, request.get())); |
- TestResourceController resource_controller; |
- mime_sniffing_handler->SetController(&resource_controller); |
- |
- scoped_refptr<ResourceResponse> response(new ResourceResponse); |
- // The MIME type isn't important but it shouldn't be empty. |
- response->head.mime_type = "application/pdf"; |
- |
- bool defer = false; |
- mime_sniffing_handler->OnResponseStarted(response.get(), &defer); |
- |
- content::RunAllPendingInMessageLoop(); |
- EXPECT_LT(host.intercepted_as_stream_count(), 2); |
- return host.intercepted_as_stream(); |
-} |
- |
std::string MimeTypeResourceHandlerTest::TestAcceptHeaderSetting( |
ResourceType request_resource_type) { |
net::URLRequestContext context; |
@@ -305,14 +256,10 @@ std::string MimeTypeResourceHandlerTest::TestAcceptHeaderSettingWithURLRequest( |
true, // is_async |
false); // is_using_lofi |
- TestResourceDispatcherHost host(stream_has_handler_); |
- TestResourceDispatcherHostDelegate host_delegate(false); |
- host.SetDelegate(&host_delegate); |
- |
std::unique_ptr<ResourceHandler> mime_sniffing_handler( |
new MimeTypeResourceHandler( |
- std::unique_ptr<ResourceHandler>(new TestResourceHandler()), &host, |
- nullptr, request)); |
+ std::unique_ptr<ResourceHandler>(new TestResourceHandler()), |
+ request)); |
bool defer = false; |
mime_sniffing_handler->OnWillStart(request->url(), &defer); |
@@ -362,102 +309,6 @@ TEST_F(MimeTypeResourceHandlerTest, AcceptHeaders) { |
TestAcceptHeaderSettingWithURLRequest(RESOURCE_TYPE_XHR, request.get())); |
} |
-// Test that stream requests are correctly intercepted under the right |
-// circumstances. Test is not relevent when plugins are disabled. |
-#if defined(ENABLE_PLUGINS) |
-TEST_F(MimeTypeResourceHandlerTest, StreamHandling) { |
- bool allow_download; |
- bool must_download; |
- ResourceType resource_type; |
- |
- // Ensure the stream is handled by MaybeInterceptAsStream in the |
- // ResourceDispatcherHost. |
- set_stream_has_handler(true); |
- set_plugin_available(true); |
- |
- // Main frame request with no download allowed. Stream shouldn't be |
- // intercepted. |
- allow_download = false; |
- must_download = false; |
- resource_type = RESOURCE_TYPE_MAIN_FRAME; |
- EXPECT_FALSE( |
- TestStreamIsIntercepted(allow_download, must_download, resource_type)); |
- |
- // Main frame request with download allowed. Stream should be intercepted. |
- allow_download = true; |
- must_download = false; |
- resource_type = RESOURCE_TYPE_MAIN_FRAME; |
- EXPECT_TRUE( |
- TestStreamIsIntercepted(allow_download, must_download, resource_type)); |
- |
- // Main frame request with download forced. Stream shouldn't be intercepted. |
- allow_download = true; |
- must_download = true; |
- resource_type = RESOURCE_TYPE_MAIN_FRAME; |
- EXPECT_FALSE( |
- TestStreamIsIntercepted(allow_download, must_download, resource_type)); |
- |
- // Sub-resource request with download not allowed. Stream shouldn't be |
- // intercepted. |
- allow_download = false; |
- must_download = false; |
- resource_type = RESOURCE_TYPE_SUB_RESOURCE; |
- EXPECT_FALSE( |
- TestStreamIsIntercepted(allow_download, must_download, resource_type)); |
- |
- // Plugin resource request with download not allowed. Stream shouldn't be |
- // intercepted. |
- allow_download = false; |
- must_download = false; |
- resource_type = RESOURCE_TYPE_PLUGIN_RESOURCE; |
- EXPECT_FALSE( |
- TestStreamIsIntercepted(allow_download, must_download, resource_type)); |
- |
- // Object request with download not allowed. Stream should be intercepted. |
- allow_download = false; |
- must_download = false; |
- resource_type = RESOURCE_TYPE_OBJECT; |
- EXPECT_TRUE( |
- TestStreamIsIntercepted(allow_download, must_download, resource_type)); |
- |
- // Test the cases where the stream isn't handled by MaybeInterceptAsStream |
- // in the ResourceDispatcherHost. |
- set_stream_has_handler(false); |
- allow_download = false; |
- must_download = false; |
- resource_type = RESOURCE_TYPE_OBJECT; |
- EXPECT_FALSE( |
- TestStreamIsIntercepted(allow_download, must_download, resource_type)); |
- |
- allow_download = true; |
- must_download = false; |
- resource_type = RESOURCE_TYPE_MAIN_FRAME; |
- EXPECT_FALSE( |
- TestStreamIsIntercepted(allow_download, must_download, resource_type)); |
- |
- // Test the cases where the stream handled by MaybeInterceptAsStream |
- // with plugin not available. This is the case when intercepting streams for |
- // the streamsPrivate extensions API. |
- set_stream_has_handler(true); |
- set_plugin_available(false); |
- allow_download = false; |
- must_download = false; |
- resource_type = RESOURCE_TYPE_OBJECT; |
- EXPECT_TRUE( |
- TestStreamIsIntercepted(allow_download, must_download, resource_type)); |
- |
- // Test the cases where the stream handled by MaybeInterceptAsStream |
- // with plugin not available. This is the case when intercepting streams for |
- // the streamsPrivate extensions API with stale plugin. |
- set_plugin_stale(true); |
- allow_download = false; |
- must_download = false; |
- resource_type = RESOURCE_TYPE_OBJECT; |
- EXPECT_TRUE( |
- TestStreamIsIntercepted(allow_download, must_download, resource_type)); |
-} |
-#endif |
mattm
2016/06/09 22:55:32
These tests are simply removed. Should they instea
|
- |
} // namespace |
} // namespace content |