Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(454)

Side by Side Diff: content/browser/service_worker/service_worker_request_handler_unittest.cc

Issue 2627543002: ServiceWorker: Returns true for IsMojoForServiceWorkerEnabled (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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" 10 #include "content/browser/fileapi/mock_url_request_delegate.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 107
108 protected: 108 protected:
109 TestBrowserThreadBundle browser_thread_bundle_; 109 TestBrowserThreadBundle browser_thread_bundle_;
110 std::unique_ptr<EmbeddedWorkerTestHelper> helper_; 110 std::unique_ptr<EmbeddedWorkerTestHelper> helper_;
111 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; 111 base::WeakPtr<ServiceWorkerProviderHost> provider_host_;
112 net::URLRequestContext url_request_context_; 112 net::URLRequestContext url_request_context_;
113 MockURLRequestDelegate url_request_delegate_; 113 MockURLRequestDelegate url_request_delegate_;
114 storage::BlobStorageContext blob_storage_context_; 114 storage::BlobStorageContext blob_storage_context_;
115 }; 115 };
116 116
117 class ServiceWorkerRequestHandlerTestP 117 TEST_F(ServiceWorkerRequestHandlerTest, InitializeHandler_FTP) {
118 : public MojoServiceWorkerTestP<ServiceWorkerRequestHandlerTest> {};
119
120 TEST_P(ServiceWorkerRequestHandlerTestP, InitializeHandler_FTP) {
121 std::unique_ptr<net::URLRequest> request = 118 std::unique_ptr<net::URLRequest> request =
122 CreateRequest("ftp://host/scope/doc", "GET"); 119 CreateRequest("ftp://host/scope/doc", "GET");
123 InitializeHandler(request.get(), false, RESOURCE_TYPE_MAIN_FRAME); 120 InitializeHandler(request.get(), false, RESOURCE_TYPE_MAIN_FRAME);
124 // Cannot initialize a handler for non-secure origins. 121 // Cannot initialize a handler for non-secure origins.
125 EXPECT_FALSE(GetHandler(request.get())); 122 EXPECT_FALSE(GetHandler(request.get()));
126 } 123 }
127 124
128 TEST_P(ServiceWorkerRequestHandlerTestP, InitializeHandler_HTTP_MAIN_FRAME) { 125 TEST_F(ServiceWorkerRequestHandlerTest, InitializeHandler_HTTP_MAIN_FRAME) {
129 // HTTP should have the handler because the response is possible to be a 126 // HTTP should have the handler because the response is possible to be a
130 // redirect to HTTPS. 127 // redirect to HTTPS.
131 InitializeHandlerSimpleTest("http://host/scope/doc", "GET", false, 128 InitializeHandlerSimpleTest("http://host/scope/doc", "GET", false,
132 RESOURCE_TYPE_MAIN_FRAME); 129 RESOURCE_TYPE_MAIN_FRAME);
133 } 130 }
134 131
135 TEST_P(ServiceWorkerRequestHandlerTestP, InitializeHandler_HTTPS_MAIN_FRAME) { 132 TEST_F(ServiceWorkerRequestHandlerTest, InitializeHandler_HTTPS_MAIN_FRAME) {
136 InitializeHandlerSimpleTest("https://host/scope/doc", "GET", false, 133 InitializeHandlerSimpleTest("https://host/scope/doc", "GET", false,
137 RESOURCE_TYPE_MAIN_FRAME); 134 RESOURCE_TYPE_MAIN_FRAME);
138 } 135 }
139 136
140 TEST_P(ServiceWorkerRequestHandlerTestP, InitializeHandler_HTTP_SUB_FRAME) { 137 TEST_F(ServiceWorkerRequestHandlerTest, InitializeHandler_HTTP_SUB_FRAME) {
141 // HTTP should have the handler because the response is possible to be a 138 // HTTP should have the handler because the response is possible to be a
142 // redirect to HTTPS. 139 // redirect to HTTPS.
143 InitializeHandlerSimpleTest("http://host/scope/doc", "GET", false, 140 InitializeHandlerSimpleTest("http://host/scope/doc", "GET", false,
144 RESOURCE_TYPE_SUB_FRAME); 141 RESOURCE_TYPE_SUB_FRAME);
145 } 142 }
146 143
147 TEST_P(ServiceWorkerRequestHandlerTestP, InitializeHandler_HTTPS_SUB_FRAME) { 144 TEST_F(ServiceWorkerRequestHandlerTest, InitializeHandler_HTTPS_SUB_FRAME) {
148 InitializeHandlerSimpleTest("https://host/scope/doc", "GET", false, 145 InitializeHandlerSimpleTest("https://host/scope/doc", "GET", false,
149 RESOURCE_TYPE_SUB_FRAME); 146 RESOURCE_TYPE_SUB_FRAME);
150 } 147 }
151 148
152 TEST_P(ServiceWorkerRequestHandlerTestP, InitializeHandler_HTTPS_OPTIONS) { 149 TEST_F(ServiceWorkerRequestHandlerTest, InitializeHandler_HTTPS_OPTIONS) {
153 // OPTIONS is also supported. See crbug.com/434660. 150 // OPTIONS is also supported. See crbug.com/434660.
154 InitializeHandlerSimpleTest("https://host/scope/doc", "OPTIONS", false, 151 InitializeHandlerSimpleTest("https://host/scope/doc", "OPTIONS", false,
155 RESOURCE_TYPE_MAIN_FRAME); 152 RESOURCE_TYPE_MAIN_FRAME);
156 } 153 }
157 154
158 TEST_P(ServiceWorkerRequestHandlerTestP, InitializeHandler_HTTPS_SKIP) { 155 TEST_F(ServiceWorkerRequestHandlerTest, InitializeHandler_HTTPS_SKIP) {
159 InitializeHandlerSimpleTest("https://host/scope/doc", "GET", true, 156 InitializeHandlerSimpleTest("https://host/scope/doc", "GET", true,
160 RESOURCE_TYPE_MAIN_FRAME); 157 RESOURCE_TYPE_MAIN_FRAME);
161 } 158 }
162 159
163 TEST_P(ServiceWorkerRequestHandlerTestP, InitializeHandler_IMAGE) { 160 TEST_F(ServiceWorkerRequestHandlerTest, InitializeHandler_IMAGE) {
164 // Check provider host's URL after initializing a handler for an image. 161 // Check provider host's URL after initializing a handler for an image.
165 provider_host_->SetDocumentUrl(GURL("https://host/scope/doc")); 162 provider_host_->SetDocumentUrl(GURL("https://host/scope/doc"));
166 std::unique_ptr<net::URLRequest> request = 163 std::unique_ptr<net::URLRequest> request =
167 CreateRequest("https://host/scope/image", "GET"); 164 CreateRequest("https://host/scope/image", "GET");
168 InitializeHandler(request.get(), true, RESOURCE_TYPE_IMAGE); 165 InitializeHandler(request.get(), true, RESOURCE_TYPE_IMAGE);
169 ASSERT_FALSE(GetHandler(request.get())); 166 ASSERT_FALSE(GetHandler(request.get()));
170 EXPECT_EQ(GURL("https://host/scope/doc"), provider_host_->document_url()); 167 EXPECT_EQ(GURL("https://host/scope/doc"), provider_host_->document_url());
171 } 168 }
172 169
173 INSTANTIATE_TEST_CASE_P(ServiceWorkerRequestHandlerTest,
174 ServiceWorkerRequestHandlerTestP,
175 testing::Bool());
176
177 } // namespace content 170 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698