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

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

Issue 2431313003: Mojofy unittests related to service workers (Closed)
Patch Set: Rebase Created 4 years, 2 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"
11 #include "content/browser/service_worker/embedded_worker_test_helper.h" 11 #include "content/browser/service_worker/embedded_worker_test_helper.h"
12 #include "content/browser/service_worker/service_worker_context_core.h" 12 #include "content/browser/service_worker/service_worker_context_core.h"
13 #include "content/browser/service_worker/service_worker_provider_host.h" 13 #include "content/browser/service_worker/service_worker_provider_host.h"
14 #include "content/browser/service_worker/service_worker_registration.h" 14 #include "content/browser/service_worker/service_worker_registration.h"
15 #include "content/browser/service_worker/service_worker_test_utils.h"
15 #include "content/common/resource_request_body_impl.h" 16 #include "content/common/resource_request_body_impl.h"
16 #include "content/common/service_worker/service_worker_utils.h" 17 #include "content/common/service_worker/service_worker_utils.h"
17 #include "content/public/common/request_context_frame_type.h" 18 #include "content/public/common/request_context_frame_type.h"
18 #include "content/public/common/request_context_type.h" 19 #include "content/public/common/request_context_type.h"
19 #include "content/public/common/resource_type.h" 20 #include "content/public/common/resource_type.h"
20 #include "content/public/test/test_browser_thread_bundle.h" 21 #include "content/public/test/test_browser_thread_bundle.h"
21 #include "net/url_request/url_request_context.h" 22 #include "net/url_request/url_request_context.h"
22 #include "storage/browser/blob/blob_storage_context.h" 23 #include "storage/browser/blob/blob_storage_context.h"
23 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
24 25
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 TestBrowserThreadBundle browser_thread_bundle_; 110 TestBrowserThreadBundle browser_thread_bundle_;
110 std::unique_ptr<EmbeddedWorkerTestHelper> helper_; 111 std::unique_ptr<EmbeddedWorkerTestHelper> helper_;
111 scoped_refptr<ServiceWorkerRegistration> registration_; 112 scoped_refptr<ServiceWorkerRegistration> registration_;
112 scoped_refptr<ServiceWorkerVersion> version_; 113 scoped_refptr<ServiceWorkerVersion> version_;
113 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; 114 base::WeakPtr<ServiceWorkerProviderHost> provider_host_;
114 net::URLRequestContext url_request_context_; 115 net::URLRequestContext url_request_context_;
115 MockURLRequestDelegate url_request_delegate_; 116 MockURLRequestDelegate url_request_delegate_;
116 storage::BlobStorageContext blob_storage_context_; 117 storage::BlobStorageContext blob_storage_context_;
117 }; 118 };
118 119
119 TEST_F(ServiceWorkerRequestHandlerTest, InitializeHandler) { 120 class ServiceWorkerRequestHandlerTestP
121 : public MojoServiceWorkerTestP<ServiceWorkerRequestHandlerTest> {};
122
123 TEST_P(ServiceWorkerRequestHandlerTestP, InitializeHandler) {
120 // Cannot initialize a handler for non-secure origins. 124 // Cannot initialize a handler for non-secure origins.
121 EXPECT_FALSE(InitializeHandlerCheck( 125 EXPECT_FALSE(InitializeHandlerCheck(
122 "ftp://host/scope/doc", "GET", false, RESOURCE_TYPE_MAIN_FRAME)); 126 "ftp://host/scope/doc", "GET", false, RESOURCE_TYPE_MAIN_FRAME));
123 // HTTP is ok because it might redirect to HTTPS. 127 // HTTP is ok because it might redirect to HTTPS.
124 EXPECT_TRUE(InitializeHandlerCheck("http://host/scope/doc", "GET", false, 128 EXPECT_TRUE(InitializeHandlerCheck("http://host/scope/doc", "GET", false,
125 RESOURCE_TYPE_MAIN_FRAME)); 129 RESOURCE_TYPE_MAIN_FRAME));
126 EXPECT_TRUE(InitializeHandlerCheck("https://host/scope/doc", "GET", false, 130 EXPECT_TRUE(InitializeHandlerCheck("https://host/scope/doc", "GET", false,
127 RESOURCE_TYPE_MAIN_FRAME)); 131 RESOURCE_TYPE_MAIN_FRAME));
128 132
129 // OPTIONS is also supported. See crbug.com/434660. 133 // OPTIONS is also supported. See crbug.com/434660.
(...skipping 26 matching lines...) Expand all
156 // Check provider host's URL after initializing a handler for an image. 160 // Check provider host's URL after initializing a handler for an image.
157 provider_host_->SetDocumentUrl(GURL("")); 161 provider_host_->SetDocumentUrl(GURL(""));
158 EXPECT_FALSE(InitializeHandlerCheck( 162 EXPECT_FALSE(InitializeHandlerCheck(
159 "http://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE)); 163 "http://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE));
160 EXPECT_STREQ("", provider_host_->document_url().spec().c_str()); 164 EXPECT_STREQ("", provider_host_->document_url().spec().c_str());
161 EXPECT_FALSE(InitializeHandlerCheck( 165 EXPECT_FALSE(InitializeHandlerCheck(
162 "https://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE)); 166 "https://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE));
163 EXPECT_STREQ("", provider_host_->document_url().spec().c_str()); 167 EXPECT_STREQ("", provider_host_->document_url().spec().c_str());
164 } 168 }
165 169
170 INSTANTIATE_TEST_CASE_P(ServiceWorkerRequestHandlerTest,
171 ServiceWorkerRequestHandlerTestP,
172 testing::Bool());
173
166 } // namespace content 174 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698