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

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

Issue 2653493009: Add two interfaces for ServiceWorkerProviderContext/ProviderHost (Closed)
Patch Set: Addressed comments from falken Created 3 years, 7 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/service_worker/embedded_worker_test_helper.h" 10 #include "content/browser/service_worker/embedded_worker_test_helper.h"
(...skipping 25 matching lines...) Expand all
36 class ServiceWorkerRequestHandlerTest : public testing::Test { 36 class ServiceWorkerRequestHandlerTest : public testing::Test {
37 public: 37 public:
38 ServiceWorkerRequestHandlerTest() 38 ServiceWorkerRequestHandlerTest()
39 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {} 39 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {}
40 40
41 void SetUp() override { 41 void SetUp() override {
42 helper_.reset(new EmbeddedWorkerTestHelper(base::FilePath())); 42 helper_.reset(new EmbeddedWorkerTestHelper(base::FilePath()));
43 43
44 // An empty host. 44 // An empty host.
45 std::unique_ptr<ServiceWorkerProviderHost> host = 45 std::unique_ptr<ServiceWorkerProviderHost> host =
46 CreateProviderHostForWindow( 46 CreateProviderHostForWindow(helper_->mock_render_process_id(),
47 helper_->mock_render_process_id(), kMockProviderId, 47 kMockProviderId,
48 true /* is_parent_frame_secure */, context()->AsWeakPtr()); 48 true /* is_parent_frame_secure */,
49 context()->AsWeakPtr(), &remote_endpoint_);
49 provider_host_ = host->AsWeakPtr(); 50 provider_host_ = host->AsWeakPtr();
50 context()->AddProviderHost(std::move(host)); 51 context()->AddProviderHost(std::move(host));
51 } 52 }
52 53
53 void TearDown() override { 54 void TearDown() override {
54 helper_.reset(); 55 helper_.reset();
55 } 56 }
56 57
57 ServiceWorkerContextCore* context() const { return helper_->context(); } 58 ServiceWorkerContextCore* context() const { return helper_->context(); }
58 ServiceWorkerContextWrapper* context_wrapper() const { 59 ServiceWorkerContextWrapper* context_wrapper() const {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 EXPECT_EQ(url, provider_host_->document_url().spec()); 103 EXPECT_EQ(url, provider_host_->document_url().spec());
103 } 104 }
104 105
105 protected: 106 protected:
106 TestBrowserThreadBundle browser_thread_bundle_; 107 TestBrowserThreadBundle browser_thread_bundle_;
107 std::unique_ptr<EmbeddedWorkerTestHelper> helper_; 108 std::unique_ptr<EmbeddedWorkerTestHelper> helper_;
108 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; 109 base::WeakPtr<ServiceWorkerProviderHost> provider_host_;
109 net::URLRequestContext url_request_context_; 110 net::URLRequestContext url_request_context_;
110 net::TestDelegate url_request_delegate_; 111 net::TestDelegate url_request_delegate_;
111 storage::BlobStorageContext blob_storage_context_; 112 storage::BlobStorageContext blob_storage_context_;
113 ServiceWorkerRemoteProviderEndpoint remote_endpoint_;
112 }; 114 };
113 115
114 TEST_F(ServiceWorkerRequestHandlerTest, InitializeHandler_FTP) { 116 TEST_F(ServiceWorkerRequestHandlerTest, InitializeHandler_FTP) {
115 std::unique_ptr<net::URLRequest> request = 117 std::unique_ptr<net::URLRequest> request =
116 CreateRequest("ftp://host/scope/doc", "GET"); 118 CreateRequest("ftp://host/scope/doc", "GET");
117 InitializeHandler(request.get(), false, RESOURCE_TYPE_MAIN_FRAME); 119 InitializeHandler(request.get(), false, RESOURCE_TYPE_MAIN_FRAME);
118 // Cannot initialize a handler for non-secure origins. 120 // Cannot initialize a handler for non-secure origins.
119 EXPECT_FALSE(GetHandler(request.get())); 121 EXPECT_FALSE(GetHandler(request.get()));
120 } 122 }
121 123
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // 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.
159 provider_host_->SetDocumentUrl(GURL("https://host/scope/doc")); 161 provider_host_->SetDocumentUrl(GURL("https://host/scope/doc"));
160 std::unique_ptr<net::URLRequest> request = 162 std::unique_ptr<net::URLRequest> request =
161 CreateRequest("https://host/scope/image", "GET"); 163 CreateRequest("https://host/scope/image", "GET");
162 InitializeHandler(request.get(), true, RESOURCE_TYPE_IMAGE); 164 InitializeHandler(request.get(), true, RESOURCE_TYPE_IMAGE);
163 ASSERT_FALSE(GetHandler(request.get())); 165 ASSERT_FALSE(GetHandler(request.get()));
164 EXPECT_EQ(GURL("https://host/scope/doc"), provider_host_->document_url()); 166 EXPECT_EQ(GURL("https://host/scope/doc"), provider_host_->document_url());
165 } 167 }
166 168
167 } // namespace content 169 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698