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

Unified Diff: content/browser/service_worker/service_worker_job_unittest.cc

Issue 2002883002: ServiceWorker: Store the existence of fetch event handler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
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..62a5d21b9c11e504bcced0532f07921cbb2bec73 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,27 @@ 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;
+
+ helper->set_has_fetch_handler(true);
+ RunRegisterJob(pattern, script);
+ registration = FindRegistrationForPattern(pattern);
+ EXPECT_TRUE(registration->active_version()->has_fetch_handler());
+ RunUnregisterJob(pattern);
+
+ helper->set_has_fetch_handler(false);
+ RunRegisterJob(pattern, script);
+ registration = FindRegistrationForPattern(pattern);
+ EXPECT_FALSE(registration->active_version()->has_fetch_handler());
+ RunUnregisterJob(pattern);
+}
+
TEST_F(ServiceWorkerJobTest, Update_PauseAfterDownload) {
UpdateJobTestHelper* update_helper = new UpdateJobTestHelper;
helper_.reset(update_helper);

Powered by Google App Engine
This is Rietveld 408576698