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

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

Issue 2009453002: service worker: Don't control a subframe of an insecure context (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: selfreview 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_provider_host.h" 5 #include "content/browser/service_worker/service_worker_provider_host.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 17 matching lines...) Expand all
28 helper_.reset(new EmbeddedWorkerTestHelper(base::FilePath())); 28 helper_.reset(new EmbeddedWorkerTestHelper(base::FilePath()));
29 context_ = helper_->context(); 29 context_ = helper_->context();
30 script_url_ = GURL("http://www.example.com/service_worker.js"); 30 script_url_ = GURL("http://www.example.com/service_worker.js");
31 registration1_ = new ServiceWorkerRegistration( 31 registration1_ = new ServiceWorkerRegistration(
32 GURL("http://www.example.com/"), 1L, context_->AsWeakPtr()); 32 GURL("http://www.example.com/"), 1L, context_->AsWeakPtr());
33 registration2_ = new ServiceWorkerRegistration( 33 registration2_ = new ServiceWorkerRegistration(
34 GURL("http://www.example.com/example"), 2L, context_->AsWeakPtr()); 34 GURL("http://www.example.com/example"), 2L, context_->AsWeakPtr());
35 35
36 // Prepare provider hosts (for the same process). 36 // Prepare provider hosts (for the same process).
37 std::unique_ptr<ServiceWorkerProviderHost> host1( 37 std::unique_ptr<ServiceWorkerProviderHost> host1(
38 new ServiceWorkerProviderHost(helper_->mock_render_process_id(), 38 new ServiceWorkerProviderHost(
39 MSG_ROUTING_NONE, 1 /* provider_id */, 39 helper_->mock_render_process_id(), MSG_ROUTING_NONE,
40 SERVICE_WORKER_PROVIDER_FOR_WINDOW, 40 1 /* provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW,
41 context_->AsWeakPtr(), NULL)); 41 true /* is_parent_frame_secure */, context_->AsWeakPtr(), NULL));
42 host1->SetDocumentUrl(GURL("http://www.example.com/example1.html")); 42 host1->SetDocumentUrl(GURL("http://www.example.com/example1.html"));
43 std::unique_ptr<ServiceWorkerProviderHost> host2( 43 std::unique_ptr<ServiceWorkerProviderHost> host2(
44 new ServiceWorkerProviderHost(helper_->mock_render_process_id(), 44 new ServiceWorkerProviderHost(
45 MSG_ROUTING_NONE, 2 /* provider_id */, 45 helper_->mock_render_process_id(), MSG_ROUTING_NONE,
46 SERVICE_WORKER_PROVIDER_FOR_WINDOW, 46 2 /* provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW,
47 context_->AsWeakPtr(), NULL)); 47 true /* is_parent_frame_secure */, context_->AsWeakPtr(), NULL));
48 host2->SetDocumentUrl(GURL("http://www.example.com/example2.html")); 48 host2->SetDocumentUrl(GURL("http://www.example.com/example2.html"));
49 provider_host1_ = host1->AsWeakPtr(); 49 provider_host1_ = host1->AsWeakPtr();
50 provider_host2_ = host2->AsWeakPtr(); 50 provider_host2_ = host2->AsWeakPtr();
51 context_->AddProviderHost(base::WrapUnique(host1.release())); 51 context_->AddProviderHost(base::WrapUnique(host1.release()));
52 context_->AddProviderHost(base::WrapUnique(host2.release())); 52 context_->AddProviderHost(base::WrapUnique(host2.release()));
53 } 53 }
54 54
55 void TearDown() override { 55 void TearDown() override {
56 registration1_ = 0; 56 registration1_ = 0;
57 registration2_ = 0; 57 registration2_ = 0;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 ASSERT_EQ(provider_host1_->MatchRegistration(), registration2_); 122 ASSERT_EQ(provider_host1_->MatchRegistration(), registration2_);
123 provider_host1_->RemoveMatchingRegistration(registration2_.get()); 123 provider_host1_->RemoveMatchingRegistration(registration2_.get());
124 ASSERT_EQ(provider_host1_->MatchRegistration(), registration1_); 124 ASSERT_EQ(provider_host1_->MatchRegistration(), registration1_);
125 125
126 // Should return nullptr after removing all matching registrations. 126 // Should return nullptr after removing all matching registrations.
127 provider_host1_->RemoveMatchingRegistration(registration1_.get()); 127 provider_host1_->RemoveMatchingRegistration(registration1_.get());
128 ASSERT_EQ(provider_host1_->MatchRegistration(), nullptr); 128 ASSERT_EQ(provider_host1_->MatchRegistration(), nullptr);
129 } 129 }
130 130
131 } // namespace content 131 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698