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

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

Issue 996123002: ServiceWorker: Ensure live registration during starting worker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests Created 5 years, 9 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_dispatcher_host.h" 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "content/browser/browser_thread_impl.h" 10 #include "content/browser/browser_thread_impl.h"
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 GURL pattern = GURL("http://www.example.com/"); 510 GURL pattern = GURL("http://www.example.com/");
511 scoped_refptr<ServiceWorkerRegistration> registration( 511 scoped_refptr<ServiceWorkerRegistration> registration(
512 new ServiceWorkerRegistration(pattern, 512 new ServiceWorkerRegistration(pattern,
513 1L, 513 1L,
514 helper_->context()->AsWeakPtr())); 514 helper_->context()->AsWeakPtr()));
515 scoped_refptr<ServiceWorkerVersion> version( 515 scoped_refptr<ServiceWorkerVersion> version(
516 new ServiceWorkerVersion(registration.get(), 516 new ServiceWorkerVersion(registration.get(),
517 GURL("http://www.example.com/service_worker.js"), 517 GURL("http://www.example.com/service_worker.js"),
518 1L, 518 1L,
519 helper_->context()->AsWeakPtr())); 519 helper_->context()->AsWeakPtr()));
520
521 // Make the registration findable via storage functions.
522 helper_->context()->storage()->LazyInitialize(base::Bind(&base::DoNothing));
523 base::RunLoop().RunUntilIdle();
524 bool called = false;
525 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_ABORT;
526 helper_->context()->storage()->StoreRegistration(
527 registration.get(),
528 version.get(),
529 base::Bind(&SaveStatusCallback, &called, &status));
530 base::RunLoop().RunUntilIdle();
531 EXPECT_TRUE(called);
532 ASSERT_EQ(SERVICE_WORKER_OK, status);
533
520 helper_->SimulateAddProcessToPattern(pattern, kRenderProcessId); 534 helper_->SimulateAddProcessToPattern(pattern, kRenderProcessId);
521 535
522 // Start up the worker. 536 // Start up the worker.
523 bool called; 537 status = SERVICE_WORKER_ERROR_ABORT;
524 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_ABORT;
525 version->StartWorker(base::Bind(&SaveStatusCallback, &called, &status)); 538 version->StartWorker(base::Bind(&SaveStatusCallback, &called, &status));
526 base::RunLoop().RunUntilIdle(); 539 base::RunLoop().RunUntilIdle();
527 540
528 EXPECT_TRUE(called); 541 EXPECT_TRUE(called);
529 EXPECT_EQ(SERVICE_WORKER_OK, status); 542 EXPECT_EQ(SERVICE_WORKER_OK, status);
530 543
531 EXPECT_TRUE(context()->GetProviderHost(kRenderProcessId, kProviderId)); 544 EXPECT_TRUE(context()->GetProviderHost(kRenderProcessId, kProviderId));
532 EXPECT_EQ(ServiceWorkerVersion::RUNNING, version->running_status()); 545 EXPECT_EQ(ServiceWorkerVersion::RUNNING, version->running_status());
533 546
534 // Simulate the render process crashing. 547 // Simulate the render process crashing.
(...skipping 16 matching lines...) Expand all
551 // the old dispatcher cleaned up the old provider host, the new one won't 564 // the old dispatcher cleaned up the old provider host, the new one won't
552 // complain. 565 // complain.
553 new_dispatcher_host->OnMessageReceived( 566 new_dispatcher_host->OnMessageReceived(
554 ServiceWorkerHostMsg_ProviderCreated( 567 ServiceWorkerHostMsg_ProviderCreated(
555 kProviderId, MSG_ROUTING_NONE, 568 kProviderId, MSG_ROUTING_NONE,
556 SERVICE_WORKER_PROVIDER_FOR_CONTROLLEE)); 569 SERVICE_WORKER_PROVIDER_FOR_CONTROLLEE));
557 EXPECT_EQ(0, new_dispatcher_host->bad_messages_received_count_); 570 EXPECT_EQ(0, new_dispatcher_host->bad_messages_received_count_);
558 } 571 }
559 572
560 } // namespace content 573 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698