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

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

Issue 2771823002: Implement updateViaCache flag and no-cache by default for main service worker scripts
Patch Set: change useCache to updateViaCache Created 3 years, 6 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_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 6f36f034a304706cf8895c02feaf4cc3259adf53..9bd818b958571253c62d69ce394f956750a0e999 100644
--- a/content/browser/service_worker/service_worker_context_unittest.cc
+++ b/content/browser/service_worker/service_worker_context_unittest.cc
@@ -79,6 +79,9 @@ void ExpectRegisteredWorkers(
} else {
EXPECT_FALSE(registration->active_version());
}
+
+ EXPECT_EQ(blink::WebServiceWorkerUpdateViaCache::kImports,
+ registration->update_via_cache());
}
class RejectInstallTestHelper : public EmbeddedWorkerTestHelper {
@@ -210,9 +213,7 @@ TEST_F(ServiceWorkerContextTest, Register) {
int64_t registration_id = kInvalidServiceWorkerRegistrationId;
bool called = false;
context()->RegisterServiceWorker(
- pattern,
- script_url,
- NULL,
+ script_url, ServiceWorkerRegistrationOptions(pattern), NULL,
MakeRegisteredCallback(&called, &registration_id));
ASSERT_FALSE(called);
@@ -265,9 +266,7 @@ TEST_F(ServiceWorkerContextTest, Register_RejectInstall) {
int64_t registration_id = kInvalidServiceWorkerRegistrationId;
bool called = false;
context()->RegisterServiceWorker(
- pattern,
- script_url,
- NULL,
+ script_url, ServiceWorkerRegistrationOptions(pattern), NULL,
MakeRegisteredCallback(&called, &registration_id));
ASSERT_FALSE(called);
@@ -317,7 +316,7 @@ TEST_F(ServiceWorkerContextTest, Register_RejectActivate) {
int64_t registration_id = kInvalidServiceWorkerRegistrationId;
bool called = false;
context()->RegisterServiceWorker(
- pattern, script_url, NULL,
+ script_url, ServiceWorkerRegistrationOptions(pattern), NULL,
MakeRegisteredCallback(&called, &registration_id));
ASSERT_FALSE(called);
@@ -356,9 +355,8 @@ TEST_F(ServiceWorkerContextTest, Unregister) {
bool called = false;
int64_t registration_id = kInvalidServiceWorkerRegistrationId;
context()->RegisterServiceWorker(
- pattern,
GURL("http://www.example.com/service_worker.js"),
- NULL,
+ ServiceWorkerRegistrationOptions(pattern), NULL,
MakeRegisteredCallback(&called, &registration_id));
ASSERT_FALSE(called);
@@ -405,24 +403,20 @@ TEST_F(ServiceWorkerContextTest, UnregisterMultiple) {
int64_t registration_id3 = kInvalidServiceWorkerRegistrationId;
int64_t registration_id4 = kInvalidServiceWorkerRegistrationId;
context()->RegisterServiceWorker(
- origin1_p1,
GURL("http://www.example.com/service_worker.js"),
- NULL,
+ ServiceWorkerRegistrationOptions(origin1_p1), NULL,
MakeRegisteredCallback(&called, &registration_id1));
context()->RegisterServiceWorker(
- origin1_p2,
GURL("http://www.example.com/service_worker2.js"),
- NULL,
+ ServiceWorkerRegistrationOptions(origin1_p2), NULL,
MakeRegisteredCallback(&called, &registration_id2));
context()->RegisterServiceWorker(
- origin2_p1,
GURL("http://www.example.com:8080/service_worker3.js"),
- NULL,
+ ServiceWorkerRegistrationOptions(origin2_p1), NULL,
MakeRegisteredCallback(&called, &registration_id3));
context()->RegisterServiceWorker(
- origin3_p1,
GURL("http://www.other.com/service_worker4.js"),
- NULL,
+ ServiceWorkerRegistrationOptions(origin3_p1), NULL,
MakeRegisteredCallback(&called, &registration_id4));
ASSERT_FALSE(called);
@@ -502,9 +496,8 @@ TEST_F(ServiceWorkerContextTest, RegisterNewScript) {
bool called = false;
int64_t old_registration_id = kInvalidServiceWorkerRegistrationId;
context()->RegisterServiceWorker(
- pattern,
GURL("http://www.example.com/service_worker.js"),
- NULL,
+ ServiceWorkerRegistrationOptions(pattern), NULL,
MakeRegisteredCallback(&called, &old_registration_id));
ASSERT_FALSE(called);
@@ -515,9 +508,8 @@ TEST_F(ServiceWorkerContextTest, RegisterNewScript) {
called = false;
int64_t new_registration_id = kInvalidServiceWorkerRegistrationId;
context()->RegisterServiceWorker(
- pattern,
GURL("http://www.example.com/service_worker_new.js"),
- NULL,
+ ServiceWorkerRegistrationOptions(pattern), NULL,
MakeRegisteredCallback(&called, &new_registration_id));
ASSERT_FALSE(called);
@@ -545,9 +537,7 @@ TEST_F(ServiceWorkerContextTest, RegisterDuplicateScript) {
bool called = false;
int64_t old_registration_id = kInvalidServiceWorkerRegistrationId;
context()->RegisterServiceWorker(
- pattern,
- script_url,
- NULL,
+ script_url, ServiceWorkerRegistrationOptions(pattern), NULL,
MakeRegisteredCallback(&called, &old_registration_id));
ASSERT_FALSE(called);
@@ -558,9 +548,7 @@ TEST_F(ServiceWorkerContextTest, RegisterDuplicateScript) {
called = false;
int64_t new_registration_id = kInvalidServiceWorkerRegistrationId;
context()->RegisterServiceWorker(
- pattern,
- script_url,
- NULL,
+ script_url, ServiceWorkerRegistrationOptions(pattern), NULL,
MakeRegisteredCallback(&called, &new_registration_id));
ASSERT_FALSE(called);
@@ -690,9 +678,7 @@ TEST_P(ServiceWorkerContextRecoveryTest, DeleteAndStartOver) {
int64_t registration_id = kInvalidServiceWorkerRegistrationId;
bool called = false;
context()->RegisterServiceWorker(
- pattern,
- script_url,
- NULL,
+ script_url, ServiceWorkerRegistrationOptions(pattern), NULL,
MakeRegisteredCallback(&called, &registration_id));
ASSERT_FALSE(called);
@@ -735,9 +721,7 @@ TEST_P(ServiceWorkerContextRecoveryTest, DeleteAndStartOver) {
called = false;
context()->RegisterServiceWorker(
- pattern,
- script_url,
- NULL,
+ script_url, ServiceWorkerRegistrationOptions(pattern), NULL,
MakeRegisteredCallback(&called, &registration_id));
ASSERT_FALSE(called);

Powered by Google App Engine
This is Rietveld 408576698