Chromium Code Reviews| Index: content/browser/service_worker/service_worker_job_unittest.cc |
| diff --git a/content/browser/service_worker/service_worker_job_unittest.cc b/content/browser/service_worker/service_worker_job_unittest.cc |
| index 9974961edfbec797af9060aae0dce8ccfb369413..cddc29a6a0476a7d2a255d26504e195a87670fd2 100644 |
| --- a/content/browser/service_worker/service_worker_job_unittest.cc |
| +++ b/content/browser/service_worker/service_worker_job_unittest.cc |
| @@ -1414,9 +1414,9 @@ class EventCallbackHelper : public EmbeddedWorkerTestHelper { |
| int request_id) override { |
| if (!install_callback_.is_null()) |
| install_callback_.Run(); |
| - SimulateSend( |
| - new ServiceWorkerHostMsg_InstallEventFinished( |
| - embedded_worker_id, request_id, install_event_result_)); |
| + SimulateSend(new ServiceWorkerHostMsg_InstallEventFinished( |
| + embedded_worker_id, request_id, install_event_result_, |
| + has_fetch_handler_)); |
| } |
| void OnActivateEvent(int embedded_worker_id, int request_id) override { |
| SimulateSend( |
| @@ -1433,11 +1433,15 @@ class EventCallbackHelper : public EmbeddedWorkerTestHelper { |
| void set_activate_event_result(blink::WebServiceWorkerEventResult result) { |
| activate_event_result_ = result; |
| } |
| + void set_has_fetch_handler(bool has_fetch_handler) { |
| + has_fetch_handler_ = has_fetch_handler; |
| + } |
| private: |
| base::Closure install_callback_; |
| blink::WebServiceWorkerEventResult install_event_result_; |
| blink::WebServiceWorkerEventResult activate_event_result_; |
| + bool has_fetch_handler_ = true; |
| }; |
| TEST_F(ServiceWorkerJobTest, RemoveControlleeDuringInstall) { |
| @@ -1552,6 +1556,36 @@ TEST_F(ServiceWorkerJobTest, RemoveControlleeDuringInstall_RejectActivate) { |
| FindRegistrationForPattern(pattern, SERVICE_WORKER_OK); |
| } |
| +TEST_F(ServiceWorkerJobTest, HasFetchHandler) { |
| + EventCallbackHelper* helper = new EventCallbackHelper; |
| + helper_.reset(helper); |
| + |
| + GURL pattern("http://www.example.com/"); |
| + GURL script("http://www.example.com/service_worker.js"); |
| + scoped_refptr<ServiceWorkerRegistration> registration; |
| + scoped_refptr<ServiceWorkerVersion> version; |
| + |
| + helper->set_has_fetch_handler(true); |
| + registration = RunRegisterJob(pattern, script); |
| + version = registration->active_version(); |
| + EXPECT_TRUE(version->has_fetch_handler()); |
| + |
| + registration = FindRegistrationForPattern(pattern); |
|
falken
2016/05/25 04:30:17
I think FindRegistraitonForPattern will ultimately
shimazu
2016/05/25 07:22:39
Done.
|
| + version = registration->active_version(); |
| + EXPECT_TRUE(version->has_fetch_handler()); |
| + RunUnregisterJob(pattern); |
| + |
| + helper->set_has_fetch_handler(false); |
| + registration = RunRegisterJob(pattern, script); |
| + version = registration->active_version(); |
| + EXPECT_FALSE(version->has_fetch_handler()); |
| + |
| + registration = FindRegistrationForPattern(pattern); |
| + version = registration->active_version(); |
| + EXPECT_FALSE(version->has_fetch_handler()); |
| + RunUnregisterJob(pattern); |
| +} |
| + |
| TEST_F(ServiceWorkerJobTest, Update_PauseAfterDownload) { |
| UpdateJobTestHelper* update_helper = new UpdateJobTestHelper; |
| helper_.reset(update_helper); |