| Index: content/browser/service_worker/service_worker_context_unittest.cc
|
| diff --git a/content/browser/service_worker/service_worker_context_unittest.cc b/content/browser/service_worker/service_worker_context_unittest.cc
|
| index c12be514e6abb946d40418ff7dad60376a94bcd3..88870e2511145bb2f0bad075224461c344c3543f 100644
|
| --- a/content/browser/service_worker/service_worker_context_unittest.cc
|
| +++ b/content/browser/service_worker/service_worker_context_unittest.cc
|
| @@ -162,9 +162,6 @@ class ServiceWorkerContextTest : public ServiceWorkerContextObserver,
|
| std::vector<NotificationLog> notifications_;
|
| };
|
|
|
| -class ServiceWorkerContextTestP
|
| - : public MojoServiceWorkerTestP<ServiceWorkerContextTest> {};
|
| -
|
| class RecordableEmbeddedWorkerInstanceClient
|
| : public EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient {
|
| public:
|
| @@ -198,15 +195,13 @@ class RecordableEmbeddedWorkerInstanceClient
|
| };
|
|
|
| // Make sure basic registration is working.
|
| -TEST_P(ServiceWorkerContextTestP, Register) {
|
| +TEST_F(ServiceWorkerContextTest, Register) {
|
| GURL pattern("http://www.example.com/");
|
| GURL script_url("http://www.example.com/service_worker.js");
|
|
|
| RecordableEmbeddedWorkerInstanceClient* client = nullptr;
|
| - if (is_mojo_enabled()) {
|
| - client = helper_->CreateAndRegisterMockInstanceClient<
|
| - RecordableEmbeddedWorkerInstanceClient>(helper_->AsWeakPtr());
|
| - }
|
| + client = helper_->CreateAndRegisterMockInstanceClient<
|
| + RecordableEmbeddedWorkerInstanceClient>(helper_->AsWeakPtr());
|
|
|
| int64_t registration_id = kInvalidServiceWorkerRegistrationId;
|
| bool called = false;
|
| @@ -220,28 +215,17 @@ TEST_P(ServiceWorkerContextTestP, Register) {
|
| base::RunLoop().RunUntilIdle();
|
| EXPECT_TRUE(called);
|
|
|
| - if (is_mojo_enabled()) {
|
| - EXPECT_EQ(2UL, helper_->ipc_sink()->message_count());
|
| - ASSERT_EQ(2UL, client->events().size());
|
| - EXPECT_EQ(RecordableEmbeddedWorkerInstanceClient::Message::StartWorker,
|
| - client->events()[0]);
|
| - EXPECT_TRUE(helper_->inner_ipc_sink()->GetUniqueMessageMatching(
|
| - ServiceWorkerMsg_InstallEvent::ID));
|
| - EXPECT_TRUE(helper_->inner_ipc_sink()->GetUniqueMessageMatching(
|
| - ServiceWorkerMsg_ActivateEvent::ID));
|
| - EXPECT_EQ(RecordableEmbeddedWorkerInstanceClient::Message::StopWorker,
|
| - client->events()[1]);
|
| - } else {
|
| - EXPECT_EQ(4UL, helper_->ipc_sink()->message_count());
|
| - EXPECT_TRUE(helper_->ipc_sink()->GetUniqueMessageMatching(
|
| - EmbeddedWorkerMsg_StartWorker::ID));
|
| - EXPECT_TRUE(helper_->inner_ipc_sink()->GetUniqueMessageMatching(
|
| - ServiceWorkerMsg_InstallEvent::ID));
|
| - EXPECT_TRUE(helper_->inner_ipc_sink()->GetUniqueMessageMatching(
|
| - ServiceWorkerMsg_ActivateEvent::ID));
|
| - EXPECT_TRUE(helper_->ipc_sink()->GetUniqueMessageMatching(
|
| - EmbeddedWorkerMsg_StopWorker::ID));
|
| - }
|
| + EXPECT_EQ(2UL, helper_->ipc_sink()->message_count());
|
| + ASSERT_EQ(2UL, client->events().size());
|
| + EXPECT_EQ(RecordableEmbeddedWorkerInstanceClient::Message::StartWorker,
|
| + client->events()[0]);
|
| + EXPECT_TRUE(helper_->inner_ipc_sink()->GetUniqueMessageMatching(
|
| + ServiceWorkerMsg_InstallEvent::ID));
|
| + EXPECT_TRUE(helper_->inner_ipc_sink()->GetUniqueMessageMatching(
|
| + ServiceWorkerMsg_ActivateEvent::ID));
|
| + EXPECT_EQ(RecordableEmbeddedWorkerInstanceClient::Message::StopWorker,
|
| + client->events()[1]);
|
| +
|
| EXPECT_NE(kInvalidServiceWorkerRegistrationId, registration_id);
|
|
|
| ASSERT_EQ(1u, notifications_.size());
|
| @@ -262,7 +246,7 @@ TEST_P(ServiceWorkerContextTestP, Register) {
|
| // Test registration when the service worker rejects the install event. The
|
| // registration callback should indicate success, but there should be no waiting
|
| // or active worker in the registration.
|
| -TEST_P(ServiceWorkerContextTestP, Register_RejectInstall) {
|
| +TEST_F(ServiceWorkerContextTest, Register_RejectInstall) {
|
| GURL pattern("http://www.example.com/");
|
| GURL script_url("http://www.example.com/service_worker.js");
|
|
|
| @@ -271,10 +255,8 @@ TEST_P(ServiceWorkerContextTestP, Register_RejectInstall) {
|
| helper_->context_wrapper()->AddObserver(this);
|
|
|
| RecordableEmbeddedWorkerInstanceClient* client = nullptr;
|
| - if (is_mojo_enabled()) {
|
| - client = helper_->CreateAndRegisterMockInstanceClient<
|
| - RecordableEmbeddedWorkerInstanceClient>(helper_->AsWeakPtr());
|
| - }
|
| + client = helper_->CreateAndRegisterMockInstanceClient<
|
| + RecordableEmbeddedWorkerInstanceClient>(helper_->AsWeakPtr());
|
|
|
| int64_t registration_id = kInvalidServiceWorkerRegistrationId;
|
| bool called = false;
|
| @@ -288,28 +270,17 @@ TEST_P(ServiceWorkerContextTestP, Register_RejectInstall) {
|
| base::RunLoop().RunUntilIdle();
|
| EXPECT_TRUE(called);
|
|
|
| - if (is_mojo_enabled()) {
|
| - EXPECT_EQ(1UL, helper_->ipc_sink()->message_count());
|
| - ASSERT_EQ(2UL, client->events().size());
|
| - EXPECT_EQ(RecordableEmbeddedWorkerInstanceClient::Message::StartWorker,
|
| - client->events()[0]);
|
| - EXPECT_TRUE(helper_->inner_ipc_sink()->GetUniqueMessageMatching(
|
| - ServiceWorkerMsg_InstallEvent::ID));
|
| - EXPECT_FALSE(helper_->inner_ipc_sink()->GetUniqueMessageMatching(
|
| - ServiceWorkerMsg_ActivateEvent::ID));
|
| - EXPECT_EQ(RecordableEmbeddedWorkerInstanceClient::Message::StopWorker,
|
| - client->events()[1]);
|
| - } else {
|
| - EXPECT_EQ(3UL, helper_->ipc_sink()->message_count());
|
| - EXPECT_TRUE(helper_->ipc_sink()->GetUniqueMessageMatching(
|
| - EmbeddedWorkerMsg_StartWorker::ID));
|
| - EXPECT_TRUE(helper_->inner_ipc_sink()->GetUniqueMessageMatching(
|
| - ServiceWorkerMsg_InstallEvent::ID));
|
| - EXPECT_FALSE(helper_->inner_ipc_sink()->GetUniqueMessageMatching(
|
| - ServiceWorkerMsg_ActivateEvent::ID));
|
| - EXPECT_TRUE(helper_->ipc_sink()->GetUniqueMessageMatching(
|
| - EmbeddedWorkerMsg_StopWorker::ID));
|
| - }
|
| + EXPECT_EQ(1UL, helper_->ipc_sink()->message_count());
|
| + ASSERT_EQ(2UL, client->events().size());
|
| + EXPECT_EQ(RecordableEmbeddedWorkerInstanceClient::Message::StartWorker,
|
| + client->events()[0]);
|
| + EXPECT_TRUE(helper_->inner_ipc_sink()->GetUniqueMessageMatching(
|
| + ServiceWorkerMsg_InstallEvent::ID));
|
| + EXPECT_FALSE(helper_->inner_ipc_sink()->GetUniqueMessageMatching(
|
| + ServiceWorkerMsg_ActivateEvent::ID));
|
| + EXPECT_EQ(RecordableEmbeddedWorkerInstanceClient::Message::StopWorker,
|
| + client->events()[1]);
|
| +
|
| EXPECT_NE(kInvalidServiceWorkerRegistrationId, registration_id);
|
|
|
| ASSERT_EQ(1u, notifications_.size());
|
| @@ -329,7 +300,7 @@ TEST_P(ServiceWorkerContextTestP, Register_RejectInstall) {
|
|
|
| // Test registration when the service worker rejects the activate event. The
|
| // worker should be activated anyway.
|
| -TEST_P(ServiceWorkerContextTestP, Register_RejectActivate) {
|
| +TEST_F(ServiceWorkerContextTest, Register_RejectActivate) {
|
| GURL pattern("http://www.example.com/");
|
| GURL script_url("http://www.example.com/service_worker.js");
|
|
|
| @@ -338,10 +309,8 @@ TEST_P(ServiceWorkerContextTestP, Register_RejectActivate) {
|
| helper_->context_wrapper()->AddObserver(this);
|
|
|
| RecordableEmbeddedWorkerInstanceClient* client = nullptr;
|
| - if (is_mojo_enabled()) {
|
| - client = helper_->CreateAndRegisterMockInstanceClient<
|
| - RecordableEmbeddedWorkerInstanceClient>(helper_->AsWeakPtr());
|
| - }
|
| + client = helper_->CreateAndRegisterMockInstanceClient<
|
| + RecordableEmbeddedWorkerInstanceClient>(helper_->AsWeakPtr());
|
|
|
| int64_t registration_id = kInvalidServiceWorkerRegistrationId;
|
| bool called = false;
|
| @@ -353,28 +322,17 @@ TEST_P(ServiceWorkerContextTestP, Register_RejectActivate) {
|
| base::RunLoop().RunUntilIdle();
|
| EXPECT_TRUE(called);
|
|
|
| - if (is_mojo_enabled()) {
|
| - EXPECT_EQ(2UL, helper_->ipc_sink()->message_count());
|
| - ASSERT_EQ(2UL, client->events().size());
|
| - EXPECT_EQ(RecordableEmbeddedWorkerInstanceClient::Message::StartWorker,
|
| - client->events()[0]);
|
| - EXPECT_TRUE(helper_->inner_ipc_sink()->GetUniqueMessageMatching(
|
| - ServiceWorkerMsg_InstallEvent::ID));
|
| - EXPECT_TRUE(helper_->inner_ipc_sink()->GetUniqueMessageMatching(
|
| - ServiceWorkerMsg_ActivateEvent::ID));
|
| - EXPECT_EQ(RecordableEmbeddedWorkerInstanceClient::Message::StopWorker,
|
| - client->events()[1]);
|
| - } else {
|
| - EXPECT_EQ(4UL, helper_->ipc_sink()->message_count());
|
| - EXPECT_TRUE(helper_->ipc_sink()->GetUniqueMessageMatching(
|
| - EmbeddedWorkerMsg_StartWorker::ID));
|
| - EXPECT_TRUE(helper_->inner_ipc_sink()->GetUniqueMessageMatching(
|
| - ServiceWorkerMsg_InstallEvent::ID));
|
| - EXPECT_TRUE(helper_->inner_ipc_sink()->GetUniqueMessageMatching(
|
| - ServiceWorkerMsg_ActivateEvent::ID));
|
| - EXPECT_TRUE(helper_->ipc_sink()->GetUniqueMessageMatching(
|
| - EmbeddedWorkerMsg_StopWorker::ID));
|
| - }
|
| + EXPECT_EQ(2UL, helper_->ipc_sink()->message_count());
|
| + ASSERT_EQ(2UL, client->events().size());
|
| + EXPECT_EQ(RecordableEmbeddedWorkerInstanceClient::Message::StartWorker,
|
| + client->events()[0]);
|
| + EXPECT_TRUE(helper_->inner_ipc_sink()->GetUniqueMessageMatching(
|
| + ServiceWorkerMsg_InstallEvent::ID));
|
| + EXPECT_TRUE(helper_->inner_ipc_sink()->GetUniqueMessageMatching(
|
| + ServiceWorkerMsg_ActivateEvent::ID));
|
| + EXPECT_EQ(RecordableEmbeddedWorkerInstanceClient::Message::StopWorker,
|
| + client->events()[1]);
|
| +
|
| EXPECT_NE(kInvalidServiceWorkerRegistrationId, registration_id);
|
|
|
| ASSERT_EQ(1u, notifications_.size());
|
| @@ -390,7 +348,7 @@ TEST_P(ServiceWorkerContextTestP, Register_RejectActivate) {
|
| }
|
|
|
| // Make sure registrations are cleaned up when they are unregistered.
|
| -TEST_P(ServiceWorkerContextTestP, Unregister) {
|
| +TEST_F(ServiceWorkerContextTest, Unregister) {
|
| GURL pattern("http://www.example.com/");
|
|
|
| bool called = false;
|
| @@ -433,7 +391,7 @@ TEST_P(ServiceWorkerContextTestP, Unregister) {
|
| }
|
|
|
| // Make sure registrations are cleaned up when they are unregistered in bulk.
|
| -TEST_P(ServiceWorkerContextTestP, UnregisterMultiple) {
|
| +TEST_F(ServiceWorkerContextTest, UnregisterMultiple) {
|
| GURL origin1_p1("http://www.example.com/test");
|
| GURL origin1_p2("http://www.example.com/hello");
|
| GURL origin2_p1("http://www.example.com:8080/again");
|
| @@ -536,7 +494,7 @@ TEST_P(ServiceWorkerContextTestP, UnregisterMultiple) {
|
| }
|
|
|
| // Make sure registering a new script shares an existing registration.
|
| -TEST_P(ServiceWorkerContextTestP, RegisterNewScript) {
|
| +TEST_F(ServiceWorkerContextTest, RegisterNewScript) {
|
| GURL pattern("http://www.example.com/");
|
|
|
| bool called = false;
|
| @@ -578,7 +536,7 @@ TEST_P(ServiceWorkerContextTestP, RegisterNewScript) {
|
|
|
| // Make sure that when registering a duplicate pattern+script_url
|
| // combination, that the same registration is used.
|
| -TEST_P(ServiceWorkerContextTestP, RegisterDuplicateScript) {
|
| +TEST_F(ServiceWorkerContextTest, RegisterDuplicateScript) {
|
| GURL pattern("http://www.example.com/");
|
| GURL script_url("http://www.example.com/service_worker.js");
|
|
|
| @@ -617,7 +575,7 @@ TEST_P(ServiceWorkerContextTestP, RegisterDuplicateScript) {
|
| EXPECT_EQ(old_registration_id, notifications_[1].registration_id);
|
| }
|
|
|
| -TEST_P(ServiceWorkerContextTestP, ProviderHostIterator) {
|
| +TEST_F(ServiceWorkerContextTest, ProviderHostIterator) {
|
| const int kRenderProcessId1 = 1;
|
| const int kRenderProcessId2 = 2;
|
| const GURL kOrigin1 = GURL("http://www.example.com/");
|
| @@ -701,22 +659,13 @@ TEST_P(ServiceWorkerContextTestP, ProviderHostIterator) {
|
|
|
| class ServiceWorkerContextRecoveryTest
|
| : public ServiceWorkerContextTest,
|
| - public testing::WithParamInterface<testing::tuple<bool, bool>> {
|
| + public testing::WithParamInterface<bool> {
|
| public:
|
| ServiceWorkerContextRecoveryTest() {}
|
| virtual ~ServiceWorkerContextRecoveryTest() {}
|
|
|
| protected:
|
| - void SetUp() override {
|
| - if (!is_mojo_enabled()) {
|
| - base::CommandLine::ForCurrentProcess()->AppendSwitch(
|
| - switches::kDisableMojoServiceWorker);
|
| - }
|
| - ServiceWorkerContextTest::SetUp();
|
| - }
|
| -
|
| - bool is_mojo_enabled() const { return testing::get<0>(GetParam()); }
|
| - bool is_storage_on_disk() const { return testing::get<1>(GetParam()); }
|
| + bool is_storage_on_disk() const { return GetParam(); }
|
| };
|
|
|
| TEST_P(ServiceWorkerContextRecoveryTest, DeleteAndStartOver) {
|
| @@ -811,12 +760,8 @@ TEST_P(ServiceWorkerContextRecoveryTest, DeleteAndStartOver) {
|
| EXPECT_EQ(registration_id, notifications_[2].registration_id);
|
| }
|
|
|
| -INSTANTIATE_TEST_CASE_P(ServiceWorkerContextTest,
|
| - ServiceWorkerContextTestP,
|
| - testing::Bool());
|
| -
|
| INSTANTIATE_TEST_CASE_P(ServiceWorkerContextRecoveryTest,
|
| ServiceWorkerContextRecoveryTest,
|
| - testing::Combine(testing::Bool(), testing::Bool()));
|
| + testing::Bool());
|
|
|
| } // namespace content
|
|
|