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

Side by Side Diff: content/browser/shared_worker/shared_worker_service_impl_unittest.cc

Issue 2422793002: HTML MessagePort as mojo::MessagePipeHandle (Closed)
Patch Set: Eliminate unnecessary PostTask Created 3 years, 10 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/shared_worker/shared_worker_service_impl.h" 5 #include "content/browser/shared_worker/shared_worker_service_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <tuple> 13 #include <tuple>
14 14
15 #include "base/atomic_sequence_num.h" 15 #include "base/atomic_sequence_num.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ptr_util.h" 17 #include "base/memory/ptr_util.h"
18 #include "base/strings/string16.h" 18 #include "base/strings/string16.h"
19 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
20 #include "base/synchronization/lock.h" 20 #include "base/synchronization/lock.h"
21 #include "content/browser/message_port_message_filter.h" 21 #include "base/synchronization/waitable_event.h"
22 #include "content/browser/shared_worker/shared_worker_message_filter.h" 22 #include "content/browser/shared_worker/shared_worker_message_filter.h"
23 #include "content/browser/shared_worker/worker_storage_partition.h" 23 #include "content/browser/shared_worker/worker_storage_partition.h"
24 #include "content/common/message_port_messages.h"
25 #include "content/common/view_messages.h" 24 #include "content/common/view_messages.h"
26 #include "content/common/worker_messages.h" 25 #include "content/common/worker_messages.h"
27 #include "content/public/browser/storage_partition.h" 26 #include "content/public/browser/storage_partition.h"
28 #include "content/public/test/test_browser_context.h" 27 #include "content/public/test/test_browser_context.h"
29 #include "content/public/test/test_browser_thread_bundle.h" 28 #include "content/public/test/test_browser_thread_bundle.h"
30 #include "content/public/test/test_utils.h" 29 #include "content/public/test/test_utils.h"
31 #include "ipc/ipc_sync_message.h" 30 #include "ipc/ipc_sync_message.h"
32 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
33 32
34 namespace content { 33 namespace content {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 std::vector<int> SharedWorkerServiceImplTest::s_worker_dependency_removed_ids_; 104 std::vector<int> SharedWorkerServiceImplTest::s_worker_dependency_removed_ids_;
106 base::Lock SharedWorkerServiceImplTest::s_lock_; 105 base::Lock SharedWorkerServiceImplTest::s_lock_;
107 std::set<int> SharedWorkerServiceImplTest::s_running_process_id_set_; 106 std::set<int> SharedWorkerServiceImplTest::s_running_process_id_set_;
108 107
109 namespace { 108 namespace {
110 109
111 static const int kProcessIDs[] = {100, 101, 102}; 110 static const int kProcessIDs[] = {100, 101, 102};
112 static const unsigned long long kDocumentIDs[] = {200, 201, 202}; 111 static const unsigned long long kDocumentIDs[] = {200, 201, 202};
113 static const int kRenderFrameRouteIDs[] = {300, 301, 302}; 112 static const int kRenderFrameRouteIDs[] = {300, 301, 302};
114 113
115 class MockMessagePortMessageFilter : public MessagePortMessageFilter { 114 void BlockingReadFromMessagePort(MessagePort port, base::string16* message) {
116 public: 115 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL,
117 MockMessagePortMessageFilter( 116 base::WaitableEvent::InitialState::NOT_SIGNALED);
118 const NextRoutingIDCallback& callback, 117 port.SetCallback(
119 std::vector<std::unique_ptr<IPC::Message>>* message_queue) 118 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event)));
120 : MessagePortMessageFilter(callback), message_queue_(message_queue) {} 119 event.Wait();
121 120
122 bool Send(IPC::Message* message) override { 121 std::vector<MessagePort> should_be_empty;
123 std::unique_ptr<IPC::Message> owned(message); 122 EXPECT_TRUE(port.GetMessage(message, &should_be_empty));
124 if (!message_queue_) 123 EXPECT_TRUE(should_be_empty.empty());
125 return false; 124 }
126 message_queue_->push_back(std::move(owned));
127 return true;
128 }
129
130 void Close() {
131 message_queue_ = nullptr;
132 OnChannelClosing();
133 }
134
135 private:
136 ~MockMessagePortMessageFilter() override {}
137 std::vector<std::unique_ptr<IPC::Message>>* message_queue_;
138 };
139 125
140 class MockSharedWorkerMessageFilter : public SharedWorkerMessageFilter { 126 class MockSharedWorkerMessageFilter : public SharedWorkerMessageFilter {
141 public: 127 public:
142 MockSharedWorkerMessageFilter( 128 MockSharedWorkerMessageFilter(
143 int render_process_id, 129 int render_process_id,
144 ResourceContext* resource_context, 130 ResourceContext* resource_context,
145 const WorkerStoragePartition& partition, 131 const WorkerStoragePartition& partition,
146 MessagePortMessageFilter* message_port_filter, 132 const SharedWorkerMessageFilter::NextRoutingIDCallback& callback,
147 std::vector<std::unique_ptr<IPC::Message>>* message_queue) 133 std::vector<std::unique_ptr<IPC::Message>>* message_queue)
148 : SharedWorkerMessageFilter(render_process_id, 134 : SharedWorkerMessageFilter(render_process_id,
149 resource_context, 135 resource_context,
150 partition, 136 partition,
151 message_port_filter), 137 callback),
152 message_queue_(message_queue) {} 138 message_queue_(message_queue) {}
153 139
154 bool Send(IPC::Message* message) override { 140 bool Send(IPC::Message* message) override {
155 std::unique_ptr<IPC::Message> owned(message); 141 std::unique_ptr<IPC::Message> owned(message);
156 if (!message_queue_) 142 if (!message_queue_)
157 return false; 143 return false;
158 message_queue_->push_back(std::move(owned)); 144 message_queue_->push_back(std::move(owned));
159 return true; 145 return true;
160 } 146 }
161 147
162 void Close() { 148 void Close() {
163 message_queue_ = nullptr; 149 message_queue_ = nullptr;
164 OnChannelClosing(); 150 OnChannelClosing();
165 } 151 }
166 152
167 private: 153 private:
168 ~MockSharedWorkerMessageFilter() override {} 154 ~MockSharedWorkerMessageFilter() override {}
169 std::vector<std::unique_ptr<IPC::Message>>* message_queue_; 155 std::vector<std::unique_ptr<IPC::Message>>* message_queue_;
170 }; 156 };
171 157
172 class MockRendererProcessHost { 158 class MockRendererProcessHost {
173 public: 159 public:
174 MockRendererProcessHost(int process_id, 160 MockRendererProcessHost(int process_id,
175 ResourceContext* resource_context, 161 ResourceContext* resource_context,
176 const WorkerStoragePartition& partition) 162 const WorkerStoragePartition& partition)
177 : process_id_(process_id), 163 : process_id_(process_id),
178 message_filter_(new MockMessagePortMessageFilter( 164 worker_filter_(new MockSharedWorkerMessageFilter(
165 process_id,
166 resource_context,
167 partition,
179 base::Bind(&base::AtomicSequenceNumber::GetNext, 168 base::Bind(&base::AtomicSequenceNumber::GetNext,
180 base::Unretained(&next_routing_id_)), 169 base::Unretained(&next_routing_id_)),
181 &queued_messages_)), 170 &queued_messages_)) {
182 worker_filter_(new MockSharedWorkerMessageFilter(process_id,
183 resource_context,
184 partition,
185 message_filter_.get(),
186 &queued_messages_)) {
187 SharedWorkerServiceImplTest::RegisterRunningProcessID(process_id); 171 SharedWorkerServiceImplTest::RegisterRunningProcessID(process_id);
188 } 172 }
189 173
190 ~MockRendererProcessHost() { 174 ~MockRendererProcessHost() {
191 SharedWorkerServiceImplTest::UnregisterRunningProcessID(process_id_); 175 SharedWorkerServiceImplTest::UnregisterRunningProcessID(process_id_);
192 message_filter_->Close();
193 worker_filter_->Close(); 176 worker_filter_->Close();
194 } 177 }
195 178
196 bool OnMessageReceived(IPC::Message* message) { 179 bool OnMessageReceived(IPC::Message* message) {
197 std::unique_ptr<IPC::Message> msg(message); 180 std::unique_ptr<IPC::Message> msg(message);
198 const bool ret = message_filter_->OnMessageReceived(*message) || 181 const bool ret = worker_filter_->OnMessageReceived(*message);
199 worker_filter_->OnMessageReceived(*message);
200 if (message->is_sync()) { 182 if (message->is_sync()) {
201 CHECK(!queued_messages_.empty()); 183 CHECK(!queued_messages_.empty());
202 std::unique_ptr<IPC::Message> response_msg( 184 std::unique_ptr<IPC::Message> response_msg(
203 queued_messages_.back().release()); 185 queued_messages_.back().release());
204 queued_messages_.pop_back(); 186 queued_messages_.pop_back();
205 IPC::SyncMessage* sync_msg = static_cast<IPC::SyncMessage*>(message); 187 IPC::SyncMessage* sync_msg = static_cast<IPC::SyncMessage*>(message);
206 std::unique_ptr<IPC::MessageReplyDeserializer> reply_serializer( 188 std::unique_ptr<IPC::MessageReplyDeserializer> reply_serializer(
207 sync_msg->GetReplyDeserializer()); 189 sync_msg->GetReplyDeserializer());
208 bool result = reply_serializer->SerializeOutputParameters(*response_msg); 190 bool result = reply_serializer->SerializeOutputParameters(*response_msg);
209 CHECK(result); 191 CHECK(result);
(...skipping 11 matching lines...) Expand all
221 } 203 }
222 204
223 void FastShutdownIfPossible() { 205 void FastShutdownIfPossible() {
224 SharedWorkerServiceImplTest::UnregisterRunningProcessID(process_id_); 206 SharedWorkerServiceImplTest::UnregisterRunningProcessID(process_id_);
225 } 207 }
226 208
227 private: 209 private:
228 const int process_id_; 210 const int process_id_;
229 std::vector<std::unique_ptr<IPC::Message>> queued_messages_; 211 std::vector<std::unique_ptr<IPC::Message>> queued_messages_;
230 base::AtomicSequenceNumber next_routing_id_; 212 base::AtomicSequenceNumber next_routing_id_;
231 scoped_refptr<MockMessagePortMessageFilter> message_filter_;
232 scoped_refptr<MockSharedWorkerMessageFilter> worker_filter_; 213 scoped_refptr<MockSharedWorkerMessageFilter> worker_filter_;
233 }; 214 };
234 215
235 void CreateMessagePortPair(MockRendererProcessHost* renderer,
236 int* route_1,
237 int* port_1,
238 int* route_2,
239 int* port_2) {
240 EXPECT_TRUE(renderer->OnMessageReceived(
241 new MessagePortHostMsg_CreateMessagePort(route_1, port_1)));
242 EXPECT_TRUE(renderer->OnMessageReceived(
243 new MessagePortHostMsg_CreateMessagePort(route_2, port_2)));
244 EXPECT_TRUE(renderer->OnMessageReceived(
245 new MessagePortHostMsg_Entangle(*port_1, *port_2)));
246 EXPECT_TRUE(renderer->OnMessageReceived(
247 new MessagePortHostMsg_Entangle(*port_2, *port_1)));
248 }
249
250 void PostCreateWorker(MockRendererProcessHost* renderer, 216 void PostCreateWorker(MockRendererProcessHost* renderer,
251 const std::string& url, 217 const std::string& url,
252 const std::string& name, 218 const std::string& name,
253 unsigned long long document_id, 219 unsigned long long document_id,
254 int render_frame_route_id, 220 int render_frame_route_id,
255 ViewHostMsg_CreateWorker_Reply* reply) { 221 ViewHostMsg_CreateWorker_Reply* reply) {
256 ViewHostMsg_CreateWorker_Params params; 222 ViewHostMsg_CreateWorker_Params params;
257 params.url = GURL(url); 223 params.url = GURL(url);
258 params.name = base::ASCIIToUTF16(name); 224 params.name = base::ASCIIToUTF16(name);
259 params.content_security_policy = base::string16(); 225 params.content_security_policy = base::string16();
260 params.security_policy_type = blink::WebContentSecurityPolicyTypeReport; 226 params.security_policy_type = blink::WebContentSecurityPolicyTypeReport;
261 params.document_id = document_id; 227 params.document_id = document_id;
262 params.render_frame_route_id = render_frame_route_id; 228 params.render_frame_route_id = render_frame_route_id;
263 params.creation_context_type = 229 params.creation_context_type =
264 blink::WebSharedWorkerCreationContextTypeSecure; 230 blink::WebSharedWorkerCreationContextTypeSecure;
265 EXPECT_TRUE( 231 EXPECT_TRUE(
266 renderer->OnMessageReceived(new ViewHostMsg_CreateWorker(params, reply))); 232 renderer->OnMessageReceived(new ViewHostMsg_CreateWorker(params, reply)));
267 } 233 }
268 234
269 class MockSharedWorkerConnector { 235 class MockSharedWorkerConnector {
270 public: 236 public:
271 MockSharedWorkerConnector(MockRendererProcessHost* renderer_host) 237 MockSharedWorkerConnector(MockRendererProcessHost* renderer_host)
272 : renderer_host_(renderer_host), 238 : renderer_host_(renderer_host) {}
273 temporary_remote_port_route_id_(0),
274 remote_port_id_(0),
275 local_port_route_id_(0),
276 local_port_id_(0) {}
277 void Create(const std::string& url, 239 void Create(const std::string& url,
278 const std::string& name, 240 const std::string& name,
279 unsigned long long document_id, 241 unsigned long long document_id,
280 int render_frame_route_id) { 242 int render_frame_route_id) {
281 CreateMessagePortPair(renderer_host_,
282 &temporary_remote_port_route_id_,
283 &remote_port_id_,
284 &local_port_route_id_,
285 &local_port_id_);
286 PostCreateWorker(renderer_host_, url, name, document_id, 243 PostCreateWorker(renderer_host_, url, name, document_id,
287 render_frame_route_id, &create_worker_reply_); 244 render_frame_route_id, &create_worker_reply_);
288 } 245 }
289 void SendQueueMessages() {
290 EXPECT_TRUE(renderer_host_->OnMessageReceived(
291 new MessagePortHostMsg_QueueMessages(remote_port_id_)));
292 }
293 void SendPostMessage(const std::string& data) {
294 const std::vector<int> empty_ports;
295 EXPECT_TRUE(
296 renderer_host_->OnMessageReceived(new MessagePortHostMsg_PostMessage(
297 local_port_id_, base::ASCIIToUTF16(data), empty_ports)));
298 }
299 void SendConnect() { 246 void SendConnect() {
247 mojo::MessagePipe message_pipe;
248 local_port_ = MessagePort(std::move(message_pipe.handle0));
249
300 EXPECT_TRUE( 250 EXPECT_TRUE(
301 renderer_host_->OnMessageReceived(new ViewHostMsg_ConnectToWorker( 251 renderer_host_->OnMessageReceived(new ViewHostMsg_ConnectToWorker(
302 create_worker_reply_.route_id, remote_port_id_))); 252 create_worker_reply_.route_id,
253 MessagePort(std::move(message_pipe.handle1)))));
303 } 254 }
304 void SendSendQueuedMessages( 255 MessagePort local_port() { return local_port_; }
305 const std::vector<QueuedMessage>& queued_messages) {
306 EXPECT_TRUE(renderer_host_->OnMessageReceived(
307 new MessagePortHostMsg_SendQueuedMessages(remote_port_id_,
308 queued_messages)));
309 }
310 int temporary_remote_port_route_id() {
311 return temporary_remote_port_route_id_;
312 }
313 int remote_port_id() { return remote_port_id_; }
314 int local_port_route_id() { return local_port_route_id_; }
315 int local_port_id() { return local_port_id_; }
316 int route_id() { return create_worker_reply_.route_id; } 256 int route_id() { return create_worker_reply_.route_id; }
317 blink::WebWorkerCreationError creation_error() { 257 blink::WebWorkerCreationError creation_error() {
318 return create_worker_reply_.error; 258 return create_worker_reply_.error;
319 } 259 }
320
321 private: 260 private:
322 MockRendererProcessHost* renderer_host_; 261 MockRendererProcessHost* renderer_host_;
323 int temporary_remote_port_route_id_; 262 MessagePort local_port_;
324 int remote_port_id_;
325 int local_port_route_id_;
326 int local_port_id_;
327 ViewHostMsg_CreateWorker_Reply create_worker_reply_; 263 ViewHostMsg_CreateWorker_Reply create_worker_reply_;
328 }; 264 };
329 265
330 void CheckWorkerProcessMsgCreateWorker( 266 void CheckWorkerProcessMsgCreateWorker(
331 MockRendererProcessHost* renderer_host, 267 MockRendererProcessHost* renderer_host,
332 const std::string& expected_url, 268 const std::string& expected_url,
333 const std::string& expected_name, 269 const std::string& expected_name,
334 blink::WebContentSecurityPolicyType expected_security_policy_type, 270 blink::WebContentSecurityPolicyType expected_security_policy_type,
335 int* route_id) { 271 int* route_id) {
336 std::unique_ptr<IPC::Message> msg(renderer_host->PopMessage()); 272 std::unique_ptr<IPC::Message> msg(renderer_host->PopMessage());
337 EXPECT_EQ(WorkerProcessMsg_CreateWorker::ID, msg->type()); 273 EXPECT_EQ(WorkerProcessMsg_CreateWorker::ID, msg->type());
338 std::tuple<WorkerProcessMsg_CreateWorker_Params> param; 274 std::tuple<WorkerProcessMsg_CreateWorker_Params> param;
339 EXPECT_TRUE(WorkerProcessMsg_CreateWorker::Read(msg.get(), &param)); 275 EXPECT_TRUE(WorkerProcessMsg_CreateWorker::Read(msg.get(), &param));
340 EXPECT_EQ(GURL(expected_url), std::get<0>(param).url); 276 EXPECT_EQ(GURL(expected_url), std::get<0>(param).url);
341 EXPECT_EQ(base::ASCIIToUTF16(expected_name), std::get<0>(param).name); 277 EXPECT_EQ(base::ASCIIToUTF16(expected_name), std::get<0>(param).name);
342 EXPECT_EQ(expected_security_policy_type, 278 EXPECT_EQ(expected_security_policy_type,
343 std::get<0>(param).security_policy_type); 279 std::get<0>(param).security_policy_type);
344 *route_id = std::get<0>(param).route_id; 280 *route_id = std::get<0>(param).route_id;
345 } 281 }
346 282
347 void CheckViewMsgWorkerCreated(MockRendererProcessHost* renderer_host, 283 void CheckViewMsgWorkerCreated(MockRendererProcessHost* renderer_host,
348 MockSharedWorkerConnector* connector) { 284 MockSharedWorkerConnector* connector) {
349 std::unique_ptr<IPC::Message> msg(renderer_host->PopMessage()); 285 std::unique_ptr<IPC::Message> msg(renderer_host->PopMessage());
350 EXPECT_EQ(ViewMsg_WorkerCreated::ID, msg->type()); 286 EXPECT_EQ(ViewMsg_WorkerCreated::ID, msg->type());
351 EXPECT_EQ(connector->route_id(), msg->routing_id()); 287 EXPECT_EQ(connector->route_id(), msg->routing_id());
352 } 288 }
353 289
354 void CheckMessagePortMsgMessagesQueued(MockRendererProcessHost* renderer_host,
355 MockSharedWorkerConnector* connector) {
356 std::unique_ptr<IPC::Message> msg(renderer_host->PopMessage());
357 EXPECT_EQ(MessagePortMsg_MessagesQueued::ID, msg->type());
358 EXPECT_EQ(connector->temporary_remote_port_route_id(), msg->routing_id());
359 }
360
361 void CheckWorkerMsgConnect(MockRendererProcessHost* renderer_host, 290 void CheckWorkerMsgConnect(MockRendererProcessHost* renderer_host,
362 int expected_msg_route_id, 291 int expected_msg_route_id,
363 int expected_sent_message_port_id, 292 int* connection_request_id,
364 int* routing_id) { 293 MessagePort* port) {
365 std::unique_ptr<IPC::Message> msg(renderer_host->PopMessage()); 294 std::unique_ptr<IPC::Message> msg(renderer_host->PopMessage());
366 EXPECT_EQ(WorkerMsg_Connect::ID, msg->type()); 295 EXPECT_EQ(WorkerMsg_Connect::ID, msg->type());
367 EXPECT_EQ(expected_msg_route_id, msg->routing_id()); 296 EXPECT_EQ(expected_msg_route_id, msg->routing_id());
368 WorkerMsg_Connect::Param params; 297 WorkerMsg_Connect::Param params;
369 EXPECT_TRUE(WorkerMsg_Connect::Read(msg.get(), &params)); 298 EXPECT_TRUE(WorkerMsg_Connect::Read(msg.get(), &params));
370 int port_id = std::get<0>(params); 299 *connection_request_id = std::get<0>(params);
371 *routing_id = std::get<1>(params); 300 *port = std::get<1>(params);
372 EXPECT_EQ(expected_sent_message_port_id, port_id);
373 }
374
375 void CheckMessagePortMsgMessage(MockRendererProcessHost* renderer_host,
376 int expected_msg_route_id,
377 std::string expected_data) {
378 std::unique_ptr<IPC::Message> msg(renderer_host->PopMessage());
379 EXPECT_EQ(MessagePortMsg_Message::ID, msg->type());
380 EXPECT_EQ(expected_msg_route_id, msg->routing_id());
381 MessagePortMsg_Message::Param params;
382 EXPECT_TRUE(MessagePortMsg_Message::Read(msg.get(), &params));
383 base::string16 data = std::get<0>(params);
384 EXPECT_EQ(base::ASCIIToUTF16(expected_data), data);
385 } 301 }
386 302
387 void CheckViewMsgWorkerConnected(MockRendererProcessHost* renderer_host, 303 void CheckViewMsgWorkerConnected(MockRendererProcessHost* renderer_host,
388 MockSharedWorkerConnector* connector) { 304 MockSharedWorkerConnector* connector) {
389 std::unique_ptr<IPC::Message> msg(renderer_host->PopMessage()); 305 std::unique_ptr<IPC::Message> msg(renderer_host->PopMessage());
390 EXPECT_EQ(ViewMsg_WorkerConnected::ID, msg->type()); 306 EXPECT_EQ(ViewMsg_WorkerConnected::ID, msg->type());
391 EXPECT_EQ(connector->route_id(), msg->routing_id()); 307 EXPECT_EQ(connector->route_id(), msg->routing_id());
392 } 308 }
393 309
394 } // namespace 310 } // namespace
395 311
396 TEST_F(SharedWorkerServiceImplTest, BasicTest) { 312 TEST_F(SharedWorkerServiceImplTest, BasicTest) {
397 std::unique_ptr<MockRendererProcessHost> renderer_host( 313 std::unique_ptr<MockRendererProcessHost> renderer_host(
398 new MockRendererProcessHost(kProcessIDs[0], 314 new MockRendererProcessHost(kProcessIDs[0],
399 browser_context_->GetResourceContext(), 315 browser_context_->GetResourceContext(),
400 *partition_.get())); 316 *partition_.get()));
401 std::unique_ptr<MockSharedWorkerConnector> connector( 317 std::unique_ptr<MockSharedWorkerConnector> connector(
402 new MockSharedWorkerConnector(renderer_host.get())); 318 new MockSharedWorkerConnector(renderer_host.get()));
403 int worker_route_id; 319 int worker_route_id;
404 int worker_msg_port_route_id;
405 320
406 // SharedWorkerConnector creates two message ports and sends 321 // Sends ViewHostMsg_CreateWorker.
407 // ViewHostMsg_CreateWorker.
408 connector->Create("http://example.com/w.js", 322 connector->Create("http://example.com/w.js",
409 "name", 323 "name",
410 kDocumentIDs[0], 324 kDocumentIDs[0],
411 kRenderFrameRouteIDs[0]); 325 kRenderFrameRouteIDs[0]);
412 // We need to go to UI thread to call ReserveRenderProcessOnUI().
413 RunAllPendingInMessageLoop(); 326 RunAllPendingInMessageLoop();
414 EXPECT_EQ(2U, renderer_host->QueuedMessageCount()); 327 EXPECT_EQ(2U, renderer_host->QueuedMessageCount());
415 // WorkerProcessMsg_CreateWorker should be sent to the renderer in which 328 // WorkerProcessMsg_CreateWorker should be sent to the renderer in which
416 // SharedWorker will be created. 329 // SharedWorker will be created.
417 CheckWorkerProcessMsgCreateWorker(renderer_host.get(), 330 CheckWorkerProcessMsgCreateWorker(renderer_host.get(),
418 "http://example.com/w.js", 331 "http://example.com/w.js",
419 "name", 332 "name",
420 blink::WebContentSecurityPolicyTypeReport, 333 blink::WebContentSecurityPolicyTypeReport,
421 &worker_route_id); 334 &worker_route_id);
422 // ViewMsg_WorkerCreated(1) should be sent back to SharedWorkerConnector side. 335 // ViewMsg_WorkerCreated(1) should be sent back to SharedWorkerConnector side.
423 CheckViewMsgWorkerCreated(renderer_host.get(), connector.get()); 336 CheckViewMsgWorkerCreated(renderer_host.get(), connector.get());
424 337
425 // SharedWorkerConnector side sends MessagePortHostMsg_QueueMessages in
426 // WebSharedWorkerProxy::connect.
427 connector->SendQueueMessages();
428 EXPECT_EQ(1U, renderer_host->QueuedMessageCount());
429 // MessagePortMsg_MessagesQueued(2) should be sent back to
430 // SharedWorkerConnector side.
431 CheckMessagePortMsgMessagesQueued(renderer_host.get(), connector.get());
432
433 // When SharedWorkerConnector receives ViewMsg_WorkerCreated(1), it sends 338 // When SharedWorkerConnector receives ViewMsg_WorkerCreated(1), it sends
434 // WorkerMsg_Connect wrapped in ViewHostMsg_ForwardToWorker. 339 // WorkerMsg_Connect via ViewHostMsg_ConnectToWorker.
435 connector->SendConnect(); 340 connector->SendConnect();
436 EXPECT_EQ(1U, renderer_host->QueuedMessageCount()); 341 EXPECT_EQ(1U, renderer_host->QueuedMessageCount());
437 // WorkerMsg_Connect should be sent to SharedWorker side. 342 // WorkerMsg_Connect should be sent to SharedWorker side.
438 CheckWorkerMsgConnect(renderer_host.get(), 343 int worker_msg_connection_request_id;
439 worker_route_id, 344 MessagePort worker_msg_port;
440 connector->remote_port_id(), 345 CheckWorkerMsgConnect(renderer_host.get(), worker_route_id,
441 &worker_msg_port_route_id); 346 &worker_msg_connection_request_id, &worker_msg_port);
442
443 // When SharedWorkerConnector receives MessagePortMsg_MessagesQueued(2), it
444 // sends MessagePortHostMsg_SendQueuedMessages.
445 std::vector<QueuedMessage> empty_messages;
446 connector->SendSendQueuedMessages(empty_messages);
447 EXPECT_EQ(0U, renderer_host->QueuedMessageCount());
448 347
449 // SharedWorker sends WorkerHostMsg_WorkerReadyForInspection in 348 // SharedWorker sends WorkerHostMsg_WorkerReadyForInspection in
450 // EmbeddedSharedWorkerStub::WorkerReadyForInspection(). 349 // EmbeddedSharedWorkerStub::WorkerReadyForInspection().
451 EXPECT_TRUE(renderer_host->OnMessageReceived( 350 EXPECT_TRUE(renderer_host->OnMessageReceived(
452 new WorkerHostMsg_WorkerReadyForInspection(worker_route_id))); 351 new WorkerHostMsg_WorkerReadyForInspection(worker_route_id)));
453 EXPECT_EQ(0U, renderer_host->QueuedMessageCount()); 352 EXPECT_EQ(0U, renderer_host->QueuedMessageCount());
454 353
455 // SharedWorker sends WorkerHostMsg_WorkerScriptLoaded in 354 // SharedWorker sends WorkerHostMsg_WorkerScriptLoaded in
456 // EmbeddedSharedWorkerStub::workerScriptLoaded(). 355 // EmbeddedSharedWorkerStub::workerScriptLoaded().
457 EXPECT_TRUE(renderer_host->OnMessageReceived( 356 EXPECT_TRUE(renderer_host->OnMessageReceived(
458 new WorkerHostMsg_WorkerScriptLoaded(worker_route_id))); 357 new WorkerHostMsg_WorkerScriptLoaded(worker_route_id)));
459 EXPECT_EQ(0U, renderer_host->QueuedMessageCount()); 358 EXPECT_EQ(0U, renderer_host->QueuedMessageCount());
460 359
461 // SharedWorker sends WorkerHostMsg_WorkerConnected in 360 // SharedWorker sends WorkerHostMsg_WorkerConnected in
462 // EmbeddedSharedWorkerStub::workerScriptLoaded(). 361 // EmbeddedSharedWorkerStub::workerScriptLoaded().
463 EXPECT_TRUE( 362 EXPECT_TRUE(
464 renderer_host->OnMessageReceived(new WorkerHostMsg_WorkerConnected( 363 renderer_host->OnMessageReceived(new WorkerHostMsg_WorkerConnected(
465 connector->remote_port_id(), worker_route_id))); 364 worker_msg_connection_request_id, worker_route_id)));
466 EXPECT_EQ(1U, renderer_host->QueuedMessageCount()); 365 EXPECT_EQ(1U, renderer_host->QueuedMessageCount());
467 // ViewMsg_WorkerConnected should be sent to SharedWorkerConnector side. 366 // ViewMsg_WorkerConnected should be sent to SharedWorkerConnector side.
468 CheckViewMsgWorkerConnected(renderer_host.get(), connector.get()); 367 CheckViewMsgWorkerConnected(renderer_host.get(), connector.get());
469 368
470 // When SharedWorkerConnector side sends MessagePortHostMsg_PostMessage, 369 // Verify that |worker_msg_port| corresponds to |connector->local_port()|.
471 // SharedWorker side shuold receive MessagePortMsg_Message. 370 base::string16 expected_message(base::ASCIIToUTF16("test1"));
472 connector->SendPostMessage("test1"); 371 connector->local_port().PostMessage(expected_message,
473 EXPECT_EQ(1U, renderer_host->QueuedMessageCount()); 372 std::vector<MessagePort>());
474 CheckMessagePortMsgMessage( 373 base::string16 received_message;
475 renderer_host.get(), worker_msg_port_route_id, "test1"); 374 BlockingReadFromMessagePort(worker_msg_port, &received_message);
476 375 EXPECT_EQ(expected_message, received_message);
477 // When SharedWorker side sends MessagePortHostMsg_PostMessage,
478 // SharedWorkerConnector side shuold receive MessagePortMsg_Message.
479 const std::vector<int> empty_ports;
480 EXPECT_TRUE(
481 renderer_host->OnMessageReceived(new MessagePortHostMsg_PostMessage(
482 connector->remote_port_id(),
483 base::ASCIIToUTF16("test2"), empty_ports)));
484 EXPECT_EQ(1U, renderer_host->QueuedMessageCount());
485 CheckMessagePortMsgMessage(
486 renderer_host.get(), connector->local_port_route_id(), "test2");
487 376
488 // UpdateWorkerDependency should not be called. 377 // UpdateWorkerDependency should not be called.
489 EXPECT_EQ(0, s_update_worker_dependency_call_count_); 378 EXPECT_EQ(0, s_update_worker_dependency_call_count_);
490 } 379 }
491 380
492 TEST_F(SharedWorkerServiceImplTest, TwoRendererTest) { 381 TEST_F(SharedWorkerServiceImplTest, TwoRendererTest) {
493 // The first renderer host. 382 // The first renderer host.
494 std::unique_ptr<MockRendererProcessHost> renderer_host0( 383 std::unique_ptr<MockRendererProcessHost> renderer_host0(
495 new MockRendererProcessHost(kProcessIDs[0], 384 new MockRendererProcessHost(kProcessIDs[0],
496 browser_context_->GetResourceContext(), 385 browser_context_->GetResourceContext(),
497 *partition_.get())); 386 *partition_.get()));
498 std::unique_ptr<MockSharedWorkerConnector> connector0( 387 std::unique_ptr<MockSharedWorkerConnector> connector0(
499 new MockSharedWorkerConnector(renderer_host0.get())); 388 new MockSharedWorkerConnector(renderer_host0.get()));
500 int worker_route_id; 389 int worker_route_id;
501 int worker_msg_port_route_id1;
502 390
503 // SharedWorkerConnector creates two message ports and sends 391 // Sends ViewHostMsg_CreateWorker.
504 // ViewHostMsg_CreateWorker.
505 connector0->Create("http://example.com/w.js", 392 connector0->Create("http://example.com/w.js",
506 "name", 393 "name",
507 kDocumentIDs[0], 394 kDocumentIDs[0],
508 kRenderFrameRouteIDs[0]); 395 kRenderFrameRouteIDs[0]);
509 // We need to go to UI thread to call ReserveRenderProcessOnUI().
510 RunAllPendingInMessageLoop(); 396 RunAllPendingInMessageLoop();
511 EXPECT_EQ(2U, renderer_host0->QueuedMessageCount()); 397 EXPECT_EQ(2U, renderer_host0->QueuedMessageCount());
512 // WorkerProcessMsg_CreateWorker should be sent to the renderer in which 398 // WorkerProcessMsg_CreateWorker should be sent to the renderer in which
513 // SharedWorker will be created. 399 // SharedWorker will be created.
514 CheckWorkerProcessMsgCreateWorker(renderer_host0.get(), 400 CheckWorkerProcessMsgCreateWorker(renderer_host0.get(),
515 "http://example.com/w.js", 401 "http://example.com/w.js",
516 "name", 402 "name",
517 blink::WebContentSecurityPolicyTypeReport, 403 blink::WebContentSecurityPolicyTypeReport,
518 &worker_route_id); 404 &worker_route_id);
519 // ViewMsg_WorkerCreated(1) should be sent back to SharedWorkerConnector side. 405 // ViewMsg_WorkerCreated(1) should be sent back to SharedWorkerConnector side.
520 CheckViewMsgWorkerCreated(renderer_host0.get(), connector0.get()); 406 CheckViewMsgWorkerCreated(renderer_host0.get(), connector0.get());
521 407
522 // SharedWorkerConnector side sends MessagePortHostMsg_QueueMessages in
523 // WebSharedWorkerProxy::connect.
524 connector0->SendQueueMessages();
525 EXPECT_EQ(1U, renderer_host0->QueuedMessageCount());
526 // MessagePortMsg_MessagesQueued(2) should be sent back to
527 // SharedWorkerConnector side.
528 CheckMessagePortMsgMessagesQueued(renderer_host0.get(), connector0.get());
529
530 // When SharedWorkerConnector receives ViewMsg_WorkerCreated(1), it sends 408 // When SharedWorkerConnector receives ViewMsg_WorkerCreated(1), it sends
531 // WorkerMsg_Connect wrapped in ViewHostMsg_ForwardToWorker. 409 // WorkerMsg_Connect wrapped in ViewHostMsg_ForwardToWorker.
532 connector0->SendConnect(); 410 connector0->SendConnect();
533 EXPECT_EQ(1U, renderer_host0->QueuedMessageCount()); 411 EXPECT_EQ(1U, renderer_host0->QueuedMessageCount());
534 // WorkerMsg_Connect should be sent to SharedWorker side. 412 // WorkerMsg_Connect should be sent to SharedWorker side.
535 CheckWorkerMsgConnect(renderer_host0.get(), 413 int worker_msg_connection_request_id1;
536 worker_route_id, 414 MessagePort worker_msg_port1;
537 connector0->remote_port_id(), 415 CheckWorkerMsgConnect(renderer_host0.get(), worker_route_id,
538 &worker_msg_port_route_id1); 416 &worker_msg_connection_request_id1, &worker_msg_port1);
539
540 // When SharedWorkerConnector receives MessagePortMsg_MessagesQueued(2), it
541 // sends MessagePortHostMsg_SendQueuedMessages.
542 std::vector<QueuedMessage> empty_messages;
543 connector0->SendSendQueuedMessages(empty_messages);
544 EXPECT_EQ(0U, renderer_host0->QueuedMessageCount());
545 417
546 // SharedWorker sends WorkerHostMsg_WorkerReadyForInspection in 418 // SharedWorker sends WorkerHostMsg_WorkerReadyForInspection in
547 // EmbeddedSharedWorkerStub::WorkerReadyForInspection(). 419 // EmbeddedSharedWorkerStub::WorkerReadyForInspection().
548 EXPECT_TRUE(renderer_host0->OnMessageReceived( 420 EXPECT_TRUE(renderer_host0->OnMessageReceived(
549 new WorkerHostMsg_WorkerReadyForInspection(worker_route_id))); 421 new WorkerHostMsg_WorkerReadyForInspection(worker_route_id)));
550 EXPECT_EQ(0U, renderer_host0->QueuedMessageCount()); 422 EXPECT_EQ(0U, renderer_host0->QueuedMessageCount());
551 423
552 // SharedWorker sends WorkerHostMsg_WorkerScriptLoaded in 424 // SharedWorker sends WorkerHostMsg_WorkerScriptLoaded in
553 // EmbeddedSharedWorkerStub::workerScriptLoaded(). 425 // EmbeddedSharedWorkerStub::workerScriptLoaded().
554 EXPECT_TRUE(renderer_host0->OnMessageReceived( 426 EXPECT_TRUE(renderer_host0->OnMessageReceived(
555 new WorkerHostMsg_WorkerScriptLoaded(worker_route_id))); 427 new WorkerHostMsg_WorkerScriptLoaded(worker_route_id)));
556 EXPECT_EQ(0U, renderer_host0->QueuedMessageCount()); 428 EXPECT_EQ(0U, renderer_host0->QueuedMessageCount());
557 429
558 // SharedWorker sends WorkerHostMsg_WorkerConnected in 430 // SharedWorker sends WorkerHostMsg_WorkerConnected in
559 // EmbeddedSharedWorkerStub::workerScriptLoaded(). 431 // EmbeddedSharedWorkerStub::workerScriptLoaded().
560 EXPECT_TRUE( 432 EXPECT_TRUE(
561 renderer_host0->OnMessageReceived(new WorkerHostMsg_WorkerConnected( 433 renderer_host0->OnMessageReceived(new WorkerHostMsg_WorkerConnected(
562 connector0->remote_port_id(), worker_route_id))); 434 worker_msg_connection_request_id1, worker_route_id)));
563 EXPECT_EQ(1U, renderer_host0->QueuedMessageCount()); 435 EXPECT_EQ(1U, renderer_host0->QueuedMessageCount());
564 // ViewMsg_WorkerConnected should be sent to SharedWorkerConnector side. 436 // ViewMsg_WorkerConnected should be sent to SharedWorkerConnector side.
565 CheckViewMsgWorkerConnected(renderer_host0.get(), connector0.get()); 437 CheckViewMsgWorkerConnected(renderer_host0.get(), connector0.get());
566 438
567 // When SharedWorkerConnector side sends MessagePortHostMsg_PostMessage, 439 // Verify that |worker_msg_port1| corresponds to |connector0->local_port()|.
568 // SharedWorker side shuold receive MessagePortMsg_Message. 440 base::string16 expected_message1(base::ASCIIToUTF16("test1"));
569 connector0->SendPostMessage("test1"); 441 connector0->local_port().PostMessage(expected_message1,
570 EXPECT_EQ(1U, renderer_host0->QueuedMessageCount()); 442 std::vector<MessagePort>());
571 CheckMessagePortMsgMessage( 443 base::string16 received_message1;
572 renderer_host0.get(), worker_msg_port_route_id1, "test1"); 444 BlockingReadFromMessagePort(worker_msg_port1, &received_message1);
573 445 EXPECT_EQ(expected_message1, received_message1);
574 // When SharedWorker side sends MessagePortHostMsg_PostMessage,
575 // SharedWorkerConnector side shuold receive MessagePortMsg_Message.
576 const std::vector<int> empty_ports;
577 EXPECT_TRUE(
578 renderer_host0->OnMessageReceived(new MessagePortHostMsg_PostMessage(
579 connector0->remote_port_id(),
580 base::ASCIIToUTF16("test2"), empty_ports)));
581 EXPECT_EQ(1U, renderer_host0->QueuedMessageCount());
582 CheckMessagePortMsgMessage(
583 renderer_host0.get(), connector0->local_port_route_id(), "test2");
584 446
585 // The second renderer host. 447 // The second renderer host.
586 std::unique_ptr<MockRendererProcessHost> renderer_host1( 448 std::unique_ptr<MockRendererProcessHost> renderer_host1(
587 new MockRendererProcessHost(kProcessIDs[1], 449 new MockRendererProcessHost(kProcessIDs[1],
588 browser_context_->GetResourceContext(), 450 browser_context_->GetResourceContext(),
589 *partition_.get())); 451 *partition_.get()));
590 std::unique_ptr<MockSharedWorkerConnector> connector1( 452 std::unique_ptr<MockSharedWorkerConnector> connector1(
591 new MockSharedWorkerConnector(renderer_host1.get())); 453 new MockSharedWorkerConnector(renderer_host1.get()));
592 int worker_msg_port_route_id2;
593 454
594 // UpdateWorkerDependency should not be called yet. 455 // UpdateWorkerDependency should not be called yet.
595 EXPECT_EQ(0, s_update_worker_dependency_call_count_); 456 EXPECT_EQ(0, s_update_worker_dependency_call_count_);
596 457
597 // SharedWorkerConnector creates two message ports and sends 458 // SharedWorkerConnector creates two message ports and sends
598 // ViewHostMsg_CreateWorker. 459 // ViewHostMsg_CreateWorker.
599 connector1->Create("http://example.com/w.js", 460 connector1->Create("http://example.com/w.js",
600 "name", 461 "name",
601 kDocumentIDs[1], 462 kDocumentIDs[1],
602 kRenderFrameRouteIDs[1]); 463 kRenderFrameRouteIDs[1]);
603 // We need to go to UI thread to call ReserveRenderProcessOnUI(). 464 // We need to go to UI thread to call ReserveRenderProcessOnUI().
604 RunAllPendingInMessageLoop(); 465 RunAllPendingInMessageLoop();
605 EXPECT_EQ(1U, renderer_host1->QueuedMessageCount()); 466 EXPECT_EQ(1U, renderer_host1->QueuedMessageCount());
606 // ViewMsg_WorkerCreated(3) should be sent back to SharedWorkerConnector side. 467 // ViewMsg_WorkerCreated(3) should be sent back to SharedWorkerConnector side.
607 CheckViewMsgWorkerCreated(renderer_host1.get(), connector1.get()); 468 CheckViewMsgWorkerCreated(renderer_host1.get(), connector1.get());
608 469
609 // UpdateWorkerDependency should be called. 470 // UpdateWorkerDependency should be called.
610 EXPECT_EQ(1, s_update_worker_dependency_call_count_); 471 EXPECT_EQ(1, s_update_worker_dependency_call_count_);
611 EXPECT_EQ(1U, s_worker_dependency_added_ids_.size()); 472 EXPECT_EQ(1U, s_worker_dependency_added_ids_.size());
612 EXPECT_EQ(kProcessIDs[0], s_worker_dependency_added_ids_[0]); 473 EXPECT_EQ(kProcessIDs[0], s_worker_dependency_added_ids_[0]);
613 EXPECT_EQ(0U, s_worker_dependency_removed_ids_.size()); 474 EXPECT_EQ(0U, s_worker_dependency_removed_ids_.size());
614 475
615 // SharedWorkerConnector side sends MessagePortHostMsg_QueueMessages in
616 // WebSharedWorkerProxy::connect.
617 connector1->SendQueueMessages();
618 EXPECT_EQ(1U, renderer_host1->QueuedMessageCount());
619 // MessagePortMsg_MessagesQueued(4) should be sent back to
620 // SharedWorkerConnector side.
621 CheckMessagePortMsgMessagesQueued(renderer_host1.get(), connector1.get());
622
623 // When SharedWorkerConnector receives ViewMsg_WorkerCreated(3), it sends 476 // When SharedWorkerConnector receives ViewMsg_WorkerCreated(3), it sends
624 // WorkerMsg_Connect wrapped in ViewHostMsg_ForwardToWorker. 477 // WorkerMsg_Connect wrapped in ViewHostMsg_ForwardToWorker.
625 connector1->SendConnect(); 478 connector1->SendConnect();
626 EXPECT_EQ(1U, renderer_host0->QueuedMessageCount()); 479 EXPECT_EQ(1U, renderer_host0->QueuedMessageCount());
627 // WorkerMsg_Connect should be sent to SharedWorker side. 480 // WorkerMsg_Connect should be sent to SharedWorker side.
628 CheckWorkerMsgConnect(renderer_host0.get(), 481 int worker_msg_connection_request_id2;
629 worker_route_id, 482 MessagePort worker_msg_port2;
630 connector1->remote_port_id(), 483 CheckWorkerMsgConnect(renderer_host0.get(), worker_route_id,
631 &worker_msg_port_route_id2); 484 &worker_msg_connection_request_id2, &worker_msg_port2);
632
633 // When SharedWorkerConnector receives MessagePortMsg_MessagesQueued(4), it
634 // sends MessagePortHostMsg_SendQueuedMessages.
635 connector1->SendSendQueuedMessages(empty_messages);
636 EXPECT_EQ(0U, renderer_host1->QueuedMessageCount());
637 485
638 // SharedWorker sends WorkerHostMsg_WorkerConnected in 486 // SharedWorker sends WorkerHostMsg_WorkerConnected in
639 // EmbeddedSharedWorkerStub::OnConnect(). 487 // EmbeddedSharedWorkerStub::OnConnect().
640 EXPECT_TRUE( 488 EXPECT_TRUE(
641 renderer_host0->OnMessageReceived(new WorkerHostMsg_WorkerConnected( 489 renderer_host0->OnMessageReceived(new WorkerHostMsg_WorkerConnected(
642 connector1->remote_port_id(), worker_route_id))); 490 worker_msg_connection_request_id2, worker_route_id)));
643 EXPECT_EQ(1U, renderer_host1->QueuedMessageCount()); 491 EXPECT_EQ(1U, renderer_host1->QueuedMessageCount());
644 // ViewMsg_WorkerConnected should be sent to SharedWorkerConnector side. 492 // ViewMsg_WorkerConnected should be sent to SharedWorkerConnector side.
645 CheckViewMsgWorkerConnected(renderer_host1.get(), connector1.get()); 493 CheckViewMsgWorkerConnected(renderer_host1.get(), connector1.get());
646 494
647 // When SharedWorkerConnector side sends MessagePortHostMsg_PostMessage, 495 // Verify that |worker_msg_port2| corresponds to |connector1->local_port()|.
648 // SharedWorker side shuold receive MessagePortMsg_Message. 496 base::string16 expected_message2(base::ASCIIToUTF16("test2"));
649 connector1->SendPostMessage("test3"); 497 connector1->local_port().PostMessage(expected_message2,
650 EXPECT_EQ(1U, renderer_host0->QueuedMessageCount()); 498 std::vector<MessagePort>());
651 CheckMessagePortMsgMessage( 499 base::string16 received_message2;
652 renderer_host0.get(), worker_msg_port_route_id2, "test3"); 500 BlockingReadFromMessagePort(worker_msg_port2, &received_message2);
653 501 EXPECT_EQ(expected_message2, received_message2);
654 // When SharedWorker side sends MessagePortHostMsg_PostMessage,
655 // SharedWorkerConnector side shuold receive MessagePortMsg_Message.
656 EXPECT_TRUE(
657 renderer_host0->OnMessageReceived(new MessagePortHostMsg_PostMessage(
658 connector1->remote_port_id(),
659 base::ASCIIToUTF16("test4"), empty_ports)));
660 EXPECT_EQ(1U, renderer_host1->QueuedMessageCount());
661 CheckMessagePortMsgMessage(
662 renderer_host1.get(), connector1->local_port_route_id(), "test4");
663 502
664 EXPECT_EQ(1, s_update_worker_dependency_call_count_); 503 EXPECT_EQ(1, s_update_worker_dependency_call_count_);
665 renderer_host1.reset(); 504 renderer_host1.reset();
666 // UpdateWorkerDependency should be called. 505 // UpdateWorkerDependency should be called.
667 EXPECT_EQ(2, s_update_worker_dependency_call_count_); 506 EXPECT_EQ(2, s_update_worker_dependency_call_count_);
668 EXPECT_EQ(0U, s_worker_dependency_added_ids_.size()); 507 EXPECT_EQ(0U, s_worker_dependency_added_ids_.size());
669 EXPECT_EQ(1U, s_worker_dependency_removed_ids_.size()); 508 EXPECT_EQ(1U, s_worker_dependency_removed_ids_.size());
670 EXPECT_EQ(kProcessIDs[0], s_worker_dependency_removed_ids_[0]); 509 EXPECT_EQ(kProcessIDs[0], s_worker_dependency_removed_ids_[0]);
671 } 510 }
672 511
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 kDocumentIDs[2], 816 kDocumentIDs[2],
978 kRenderFrameRouteIDs[2]); 817 kRenderFrameRouteIDs[2]);
979 EXPECT_NE(MSG_ROUTING_NONE, connector2->route_id()); 818 EXPECT_NE(MSG_ROUTING_NONE, connector2->route_id());
980 EXPECT_EQ(0U, renderer_host2->QueuedMessageCount()); 819 EXPECT_EQ(0U, renderer_host2->QueuedMessageCount());
981 RunAllPendingInMessageLoop(); 820 RunAllPendingInMessageLoop();
982 EXPECT_EQ(1U, renderer_host2->QueuedMessageCount()); 821 EXPECT_EQ(1U, renderer_host2->QueuedMessageCount());
983 CheckViewMsgWorkerCreated(renderer_host2.get(), connector2.get()); 822 CheckViewMsgWorkerCreated(renderer_host2.get(), connector2.get());
984 } 823 }
985 824
986 } // namespace content 825 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698