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

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

Issue 2071433003: Reland: service worker: Don't control a subframe of an insecure context (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revised Created 4 years, 6 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 24 matching lines...) Expand all
35 35
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 // A new unstored registration/version. 44 // A new unstored registration/version.
45 registration_ = new ServiceWorkerRegistration( 45 registration_ = new ServiceWorkerRegistration(GURL("https://host/scope/"),
46 GURL("http://host/scope/"), 1L, context()->AsWeakPtr()); 46 1L, context()->AsWeakPtr());
47 version_ = new ServiceWorkerVersion(registration_.get(), 47 version_ = new ServiceWorkerVersion(registration_.get(),
48 GURL("http://host/script.js"), 48 GURL("https://host/script.js"), 1L,
49 1L,
50 context()->AsWeakPtr()); 49 context()->AsWeakPtr());
51 50
52 // An empty host. 51 // An empty host.
53 std::unique_ptr<ServiceWorkerProviderHost> host( 52 std::unique_ptr<ServiceWorkerProviderHost> host(
54 new ServiceWorkerProviderHost(helper_->mock_render_process_id(), 53 new ServiceWorkerProviderHost(
55 MSG_ROUTING_NONE, kMockProviderId, 54 helper_->mock_render_process_id(), MSG_ROUTING_NONE,
56 SERVICE_WORKER_PROVIDER_FOR_WINDOW, 55 kMockProviderId, SERVICE_WORKER_PROVIDER_FOR_WINDOW,
57 context()->AsWeakPtr(), nullptr)); 56 ServiceWorkerProviderHost::FrameSecurityLevel::SECURE,
58 host->SetDocumentUrl(GURL("http://host/scope/")); 57 context()->AsWeakPtr(), nullptr));
58 host->SetDocumentUrl(GURL("https://host/scope/"));
59 provider_host_ = host->AsWeakPtr(); 59 provider_host_ = host->AsWeakPtr();
60 context()->AddProviderHost(std::move(host)); 60 context()->AddProviderHost(std::move(host));
61 61
62 context()->storage()->LazyInitialize(base::Bind(&EmptyCallback)); 62 context()->storage()->LazyInitialize(base::Bind(&EmptyCallback));
63 base::RunLoop().RunUntilIdle(); 63 base::RunLoop().RunUntilIdle();
64 64
65 version_->SetStatus(ServiceWorkerVersion::ACTIVATED); 65 version_->SetStatus(ServiceWorkerVersion::ACTIVATED);
66 registration_->SetActiveVersion(version_); 66 registration_->SetActiveVersion(version_);
67 context()->storage()->StoreRegistration( 67 context()->storage()->StoreRegistration(
68 registration_.get(), 68 registration_.get(),
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 provider_host_->SetDocumentUrl(GURL("")); 155 provider_host_->SetDocumentUrl(GURL(""));
156 EXPECT_FALSE(InitializeHandlerCheck( 156 EXPECT_FALSE(InitializeHandlerCheck(
157 "http://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE)); 157 "http://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE));
158 EXPECT_STREQ("", provider_host_->document_url().spec().c_str()); 158 EXPECT_STREQ("", provider_host_->document_url().spec().c_str());
159 EXPECT_FALSE(InitializeHandlerCheck( 159 EXPECT_FALSE(InitializeHandlerCheck(
160 "https://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE)); 160 "https://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE));
161 EXPECT_STREQ("", provider_host_->document_url().spec().c_str()); 161 EXPECT_STREQ("", provider_host_->document_url().spec().c_str());
162 } 162 }
163 163
164 } // namespace content 164 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698