Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/public/browser/service_worker_context.h" | 5 #include "content/public/browser/service_worker_context.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 public: | 169 public: |
| 170 enum class Message { StartWorker, StopWorker }; | 170 enum class Message { StartWorker, StopWorker }; |
| 171 | 171 |
| 172 explicit RecordableEmbeddedWorkerInstanceClient( | 172 explicit RecordableEmbeddedWorkerInstanceClient( |
| 173 base::WeakPtr<EmbeddedWorkerTestHelper> helper) | 173 base::WeakPtr<EmbeddedWorkerTestHelper> helper) |
| 174 : EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient(helper) {} | 174 : EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient(helper) {} |
| 175 | 175 |
| 176 const std::vector<Message>& events() const { return events_; } | 176 const std::vector<Message>& events() const { return events_; } |
| 177 | 177 |
| 178 protected: | 178 protected: |
| 179 void StartWorker( | 179 void StartWorker(const EmbeddedWorkerStartParams& params, |
| 180 const EmbeddedWorkerStartParams& params, | 180 mojom::ServiceWorkerEventDispatcherRequest request, |
| 181 mojom::ServiceWorkerEventDispatcherRequest request) override { | 181 mojom::EmbeddedWorkerInstanceHostAssociatedPtrInfo |
| 182 instance_host) override { | |
| 182 events_.push_back(Message::StartWorker); | 183 events_.push_back(Message::StartWorker); |
| 183 EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient::StartWorker( | 184 EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient::StartWorker( |
| 184 params, std::move(request)); | 185 params, std::move(request), std::move(instance_host)); |
| 185 } | 186 } |
| 186 | 187 |
| 187 void StopWorker(const StopWorkerCallback& callback) override { | 188 void StopWorker(const StopWorkerCallback& callback) override { |
| 188 events_.push_back(Message::StopWorker); | 189 events_.push_back(Message::StopWorker); |
| 189 EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient::StopWorker( | 190 EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient::StopWorker( |
| 190 std::move(callback)); | 191 std::move(callback)); |
| 191 } | 192 } |
| 192 | 193 |
| 193 std::vector<Message> events_; | 194 std::vector<Message> events_; |
| 194 | 195 |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 469 registration_id4, | 470 registration_id4, |
| 470 origin3_p1.GetOrigin(), | 471 origin3_p1.GetOrigin(), |
| 471 base::Bind(&ExpectRegisteredWorkers, | 472 base::Bind(&ExpectRegisteredWorkers, |
| 472 SERVICE_WORKER_OK, | 473 SERVICE_WORKER_OK, |
| 473 false /* expect_waiting */, | 474 false /* expect_waiting */, |
| 474 true /* expect_active */)); | 475 true /* expect_active */)); |
| 475 | 476 |
| 476 base::RunLoop().RunUntilIdle(); | 477 base::RunLoop().RunUntilIdle(); |
| 477 | 478 |
| 478 ASSERT_EQ(6u, notifications_.size()); | 479 ASSERT_EQ(6u, notifications_.size()); |
| 480 // TODO(leonhsl) in this CL: Why the 4 REGISTRATION_STORED notifications are | |
| 481 // in inverse order with the 4 RegisterServiceWorker calls. | |
|
leonhsl(Using Gerrit)
2017/04/04 07:14:04
I'm still investigating,, it would be very helpful
shimazu
2017/04/06 05:01:36
What was the cause of this?
leonhsl(Using Gerrit)
2017/04/06 09:58:55
The root cause is that I was using base::MessageLo
shimazu
2017/04/10 05:10:10
Ah, thanks, I got it.
| |
| 482 EXPECT_EQ(REGISTRATION_STORED, notifications_[3].type); | |
| 483 EXPECT_EQ(registration_id1, notifications_[3].registration_id); | |
| 484 EXPECT_EQ(origin1_p1, notifications_[3].pattern); | |
| 485 EXPECT_EQ(REGISTRATION_STORED, notifications_[2].type); | |
| 486 EXPECT_EQ(origin1_p2, notifications_[2].pattern); | |
| 487 EXPECT_EQ(registration_id2, notifications_[2].registration_id); | |
| 488 EXPECT_EQ(REGISTRATION_STORED, notifications_[1].type); | |
| 489 EXPECT_EQ(origin2_p1, notifications_[1].pattern); | |
| 490 EXPECT_EQ(registration_id3, notifications_[1].registration_id); | |
| 479 EXPECT_EQ(REGISTRATION_STORED, notifications_[0].type); | 491 EXPECT_EQ(REGISTRATION_STORED, notifications_[0].type); |
| 480 EXPECT_EQ(registration_id1, notifications_[0].registration_id); | 492 EXPECT_EQ(origin3_p1, notifications_[0].pattern); |
| 481 EXPECT_EQ(origin1_p1, notifications_[0].pattern); | 493 EXPECT_EQ(registration_id4, notifications_[0].registration_id); |
| 482 EXPECT_EQ(REGISTRATION_STORED, notifications_[1].type); | 494 |
| 483 EXPECT_EQ(origin1_p2, notifications_[1].pattern); | |
| 484 EXPECT_EQ(registration_id2, notifications_[1].registration_id); | |
| 485 EXPECT_EQ(REGISTRATION_STORED, notifications_[2].type); | |
| 486 EXPECT_EQ(origin2_p1, notifications_[2].pattern); | |
| 487 EXPECT_EQ(registration_id3, notifications_[2].registration_id); | |
| 488 EXPECT_EQ(REGISTRATION_STORED, notifications_[3].type); | |
| 489 EXPECT_EQ(origin3_p1, notifications_[3].pattern); | |
| 490 EXPECT_EQ(registration_id4, notifications_[3].registration_id); | |
| 491 EXPECT_EQ(REGISTRATION_DELETED, notifications_[4].type); | 495 EXPECT_EQ(REGISTRATION_DELETED, notifications_[4].type); |
| 492 EXPECT_EQ(origin1_p2, notifications_[4].pattern); | 496 EXPECT_EQ(origin1_p2, notifications_[4].pattern); |
| 493 EXPECT_EQ(registration_id2, notifications_[4].registration_id); | 497 EXPECT_EQ(registration_id2, notifications_[4].registration_id); |
| 494 EXPECT_EQ(REGISTRATION_DELETED, notifications_[5].type); | 498 EXPECT_EQ(REGISTRATION_DELETED, notifications_[5].type); |
| 495 EXPECT_EQ(origin1_p1, notifications_[5].pattern); | 499 EXPECT_EQ(origin1_p1, notifications_[5].pattern); |
| 496 EXPECT_EQ(registration_id1, notifications_[5].registration_id); | 500 EXPECT_EQ(registration_id1, notifications_[5].registration_id); |
| 497 } | 501 } |
| 498 | 502 |
| 499 // Make sure registering a new script shares an existing registration. | 503 // Make sure registering a new script shares an existing registration. |
| 500 TEST_F(ServiceWorkerContextTest, RegisterNewScript) { | 504 TEST_F(ServiceWorkerContextTest, RegisterNewScript) { |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 761 EXPECT_EQ(REGISTRATION_STORED, notifications_[2].type); | 765 EXPECT_EQ(REGISTRATION_STORED, notifications_[2].type); |
| 762 EXPECT_EQ(pattern, notifications_[2].pattern); | 766 EXPECT_EQ(pattern, notifications_[2].pattern); |
| 763 EXPECT_EQ(registration_id, notifications_[2].registration_id); | 767 EXPECT_EQ(registration_id, notifications_[2].registration_id); |
| 764 } | 768 } |
| 765 | 769 |
| 766 INSTANTIATE_TEST_CASE_P(ServiceWorkerContextRecoveryTest, | 770 INSTANTIATE_TEST_CASE_P(ServiceWorkerContextRecoveryTest, |
| 767 ServiceWorkerContextRecoveryTest, | 771 ServiceWorkerContextRecoveryTest, |
| 768 testing::Bool()); | 772 testing::Bool()); |
| 769 | 773 |
| 770 } // namespace content | 774 } // namespace content |
| OLD | NEW |