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

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

Issue 1315483002: Service workers: Allow HTTPS pages arrived at via HTTP redirect to use SW (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix unittest Created 5 years, 4 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
« no previous file with comments | « content/browser/service_worker/service_worker_request_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "content/browser/fileapi/mock_url_request_delegate.h" 8 #include "content/browser/fileapi/mock_url_request_delegate.h"
9 #include "content/browser/service_worker/embedded_worker_test_helper.h" 9 #include "content/browser/service_worker/embedded_worker_test_helper.h"
10 #include "content/browser/service_worker/service_worker_context_core.h" 10 #include "content/browser/service_worker/service_worker_context_core.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 scoped_refptr<ServiceWorkerRegistration> registration_; 106 scoped_refptr<ServiceWorkerRegistration> registration_;
107 scoped_refptr<ServiceWorkerVersion> version_; 107 scoped_refptr<ServiceWorkerVersion> version_;
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 MockURLRequestDelegate url_request_delegate_;
111 storage::BlobStorageContext blob_storage_context_; 111 storage::BlobStorageContext blob_storage_context_;
112 }; 112 };
113 113
114 TEST_F(ServiceWorkerRequestHandlerTest, InitializeHandler) { 114 TEST_F(ServiceWorkerRequestHandlerTest, InitializeHandler) {
115 // Cannot initialize a handler for non-secure origins. 115 // Cannot initialize a handler for non-secure origins.
116 EXPECT_FALSE(InitializeHandlerCheck("http://host/scope/doc", "GET", false,
117 RESOURCE_TYPE_MAIN_FRAME));
118 EXPECT_FALSE(InitializeHandlerCheck( 116 EXPECT_FALSE(InitializeHandlerCheck(
119 "ftp://host/scope/doc", "GET", false, RESOURCE_TYPE_MAIN_FRAME)); 117 "ftp://host/scope/doc", "GET", false, RESOURCE_TYPE_MAIN_FRAME));
118 // HTTP is ok because it might redirect to HTTPS.
119 EXPECT_TRUE(InitializeHandlerCheck("http://host/scope/doc", "GET", false,
120 RESOURCE_TYPE_MAIN_FRAME));
120 EXPECT_TRUE(InitializeHandlerCheck("https://host/scope/doc", "GET", false, 121 EXPECT_TRUE(InitializeHandlerCheck("https://host/scope/doc", "GET", false,
121 RESOURCE_TYPE_MAIN_FRAME)); 122 RESOURCE_TYPE_MAIN_FRAME));
122 123
123 // OPTIONS is also supported. See crbug.com/434660. 124 // OPTIONS is also supported. See crbug.com/434660.
124 EXPECT_TRUE(InitializeHandlerCheck( 125 EXPECT_TRUE(InitializeHandlerCheck(
125 "https://host/scope/doc", "OPTIONS", false, RESOURCE_TYPE_MAIN_FRAME)); 126 "https://host/scope/doc", "OPTIONS", false, RESOURCE_TYPE_MAIN_FRAME));
126 127
128 // Check provider host's URL after initializing a handler for main
129 // frame.
127 provider_host_->SetDocumentUrl(GURL("")); 130 provider_host_->SetDocumentUrl(GURL(""));
128 EXPECT_FALSE(InitializeHandlerCheck( 131 EXPECT_FALSE(InitializeHandlerCheck(
129 "http://host/scope/doc", "GET", true, RESOURCE_TYPE_MAIN_FRAME)); 132 "http://host/scope/doc", "GET", true, RESOURCE_TYPE_MAIN_FRAME));
130 // Cannot initialize a handler for non-secure origins. 133 EXPECT_STREQ("http://host/scope/doc",
131 EXPECT_STREQ("", provider_host_->document_url().spec().c_str()); 134 provider_host_->document_url().spec().c_str());
132 EXPECT_FALSE(InitializeHandlerCheck( 135 EXPECT_FALSE(InitializeHandlerCheck(
133 "https://host/scope/doc", "GET", true, RESOURCE_TYPE_MAIN_FRAME)); 136 "https://host/scope/doc", "GET", true, RESOURCE_TYPE_MAIN_FRAME));
134 EXPECT_STREQ("https://host/scope/doc", 137 EXPECT_STREQ("https://host/scope/doc",
135 provider_host_->document_url().spec().c_str()); 138 provider_host_->document_url().spec().c_str());
136 139
140 // Check provider host's URL after initializing a handler for a subframe.
137 provider_host_->SetDocumentUrl(GURL("")); 141 provider_host_->SetDocumentUrl(GURL(""));
138 EXPECT_FALSE(InitializeHandlerCheck( 142 EXPECT_FALSE(InitializeHandlerCheck(
139 "http://host/scope/doc", "GET", true, RESOURCE_TYPE_SUB_FRAME)); 143 "http://host/scope/doc", "GET", true, RESOURCE_TYPE_SUB_FRAME));
140 // Cannot initialize a handler for non-secure origins. 144 EXPECT_STREQ("http://host/scope/doc",
141 EXPECT_STREQ("", provider_host_->document_url().spec().c_str()); 145 provider_host_->document_url().spec().c_str());
142 EXPECT_FALSE(InitializeHandlerCheck( 146 EXPECT_FALSE(InitializeHandlerCheck(
143 "https://host/scope/doc", "GET", true, RESOURCE_TYPE_SUB_FRAME)); 147 "https://host/scope/doc", "GET", true, RESOURCE_TYPE_SUB_FRAME));
144 EXPECT_STREQ("https://host/scope/doc", 148 EXPECT_STREQ("https://host/scope/doc",
145 provider_host_->document_url().spec().c_str()); 149 provider_host_->document_url().spec().c_str());
146 150
151 // Check provider host's URL after initializing a handler for an image.
147 provider_host_->SetDocumentUrl(GURL("")); 152 provider_host_->SetDocumentUrl(GURL(""));
148 EXPECT_FALSE(InitializeHandlerCheck( 153 EXPECT_FALSE(InitializeHandlerCheck(
149 "http://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE)); 154 "http://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE));
150 EXPECT_STREQ("", provider_host_->document_url().spec().c_str()); 155 EXPECT_STREQ("", provider_host_->document_url().spec().c_str());
151 EXPECT_FALSE(InitializeHandlerCheck( 156 EXPECT_FALSE(InitializeHandlerCheck(
152 "https://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE)); 157 "https://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE));
153 EXPECT_STREQ("", provider_host_->document_url().spec().c_str()); 158 EXPECT_STREQ("", provider_host_->document_url().spec().c_str());
154 } 159 }
155 160
156 } // namespace content 161 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_request_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698