| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/service_worker/service_worker_request_handler.h" | 5 #include "content/browser/service_worker/service_worker_request_handler.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "content/browser/fileapi/mock_url_request_delegate.h" | |
| 11 #include "content/browser/service_worker/embedded_worker_test_helper.h" | 10 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
| 12 #include "content/browser/service_worker/service_worker_context_core.h" | 11 #include "content/browser/service_worker/service_worker_context_core.h" |
| 13 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 12 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 14 #include "content/browser/service_worker/service_worker_provider_host.h" | 13 #include "content/browser/service_worker/service_worker_provider_host.h" |
| 15 #include "content/browser/service_worker/service_worker_test_utils.h" | 14 #include "content/browser/service_worker/service_worker_test_utils.h" |
| 16 #include "content/common/resource_request_body_impl.h" | 15 #include "content/common/resource_request_body_impl.h" |
| 17 #include "content/common/service_worker/service_worker_utils.h" | 16 #include "content/common/service_worker/service_worker_utils.h" |
| 18 #include "content/public/common/request_context_frame_type.h" | 17 #include "content/public/common/request_context_frame_type.h" |
| 19 #include "content/public/common/request_context_type.h" | 18 #include "content/public/common/request_context_type.h" |
| 20 #include "content/public/common/resource_type.h" | 19 #include "content/public/common/resource_type.h" |
| 21 #include "content/public/test/test_browser_thread_bundle.h" | 20 #include "content/public/test/test_browser_thread_bundle.h" |
| 22 #include "net/url_request/redirect_info.h" | 21 #include "net/url_request/redirect_info.h" |
| 23 #include "net/url_request/url_request_context.h" | 22 #include "net/url_request/url_request_context.h" |
| 24 #include "net/url_request/url_request_job.h" | 23 #include "net/url_request/url_request_job.h" |
| 24 #include "net/url_request/url_request_test_util.h" |
| 25 #include "storage/browser/blob/blob_storage_context.h" | 25 #include "storage/browser/blob/blob_storage_context.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 27 | 27 |
| 28 namespace content { | 28 namespace content { |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 int kMockProviderId = 1; | 32 int kMockProviderId = 1; |
| 33 | 33 |
| 34 } | 34 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 ASSERT_TRUE(GetHandler(request.get())); | 100 ASSERT_TRUE(GetHandler(request.get())); |
| 101 MaybeCreateJob(request.get()); | 101 MaybeCreateJob(request.get()); |
| 102 EXPECT_EQ(url, provider_host_->document_url().spec()); | 102 EXPECT_EQ(url, provider_host_->document_url().spec()); |
| 103 } | 103 } |
| 104 | 104 |
| 105 protected: | 105 protected: |
| 106 TestBrowserThreadBundle browser_thread_bundle_; | 106 TestBrowserThreadBundle browser_thread_bundle_; |
| 107 std::unique_ptr<EmbeddedWorkerTestHelper> helper_; | 107 std::unique_ptr<EmbeddedWorkerTestHelper> helper_; |
| 108 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; | 108 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; |
| 109 net::URLRequestContext url_request_context_; | 109 net::URLRequestContext url_request_context_; |
| 110 MockURLRequestDelegate url_request_delegate_; | 110 net::TestDelegate url_request_delegate_; |
| 111 storage::BlobStorageContext blob_storage_context_; | 111 storage::BlobStorageContext blob_storage_context_; |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 TEST_F(ServiceWorkerRequestHandlerTest, InitializeHandler_FTP) { | 114 TEST_F(ServiceWorkerRequestHandlerTest, InitializeHandler_FTP) { |
| 115 std::unique_ptr<net::URLRequest> request = | 115 std::unique_ptr<net::URLRequest> request = |
| 116 CreateRequest("ftp://host/scope/doc", "GET"); | 116 CreateRequest("ftp://host/scope/doc", "GET"); |
| 117 InitializeHandler(request.get(), false, RESOURCE_TYPE_MAIN_FRAME); | 117 InitializeHandler(request.get(), false, RESOURCE_TYPE_MAIN_FRAME); |
| 118 // Cannot initialize a handler for non-secure origins. | 118 // Cannot initialize a handler for non-secure origins. |
| 119 EXPECT_FALSE(GetHandler(request.get())); | 119 EXPECT_FALSE(GetHandler(request.get())); |
| 120 } | 120 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 // Check provider host's URL after initializing a handler for an image. | 158 // Check provider host's URL after initializing a handler for an image. |
| 159 provider_host_->SetDocumentUrl(GURL("https://host/scope/doc")); | 159 provider_host_->SetDocumentUrl(GURL("https://host/scope/doc")); |
| 160 std::unique_ptr<net::URLRequest> request = | 160 std::unique_ptr<net::URLRequest> request = |
| 161 CreateRequest("https://host/scope/image", "GET"); | 161 CreateRequest("https://host/scope/image", "GET"); |
| 162 InitializeHandler(request.get(), true, RESOURCE_TYPE_IMAGE); | 162 InitializeHandler(request.get(), true, RESOURCE_TYPE_IMAGE); |
| 163 ASSERT_FALSE(GetHandler(request.get())); | 163 ASSERT_FALSE(GetHandler(request.get())); |
| 164 EXPECT_EQ(GURL("https://host/scope/doc"), provider_host_->document_url()); | 164 EXPECT_EQ(GURL("https://host/scope/doc"), provider_host_->document_url()); |
| 165 } | 165 } |
| 166 | 166 |
| 167 } // namespace content | 167 } // namespace content |
| OLD | NEW |