Chromium Code Reviews| Index: content/browser/service_worker/link_header_support_unittest.cc |
| diff --git a/content/browser/service_worker/link_header_support_unittest.cc b/content/browser/service_worker/link_header_support_unittest.cc |
| index 869ea41882d6c83b9aaf3b7bb1f55c94b211451c..16076a467e6817f9ef8a6358e8297f0f681c8455 100644 |
| --- a/content/browser/service_worker/link_header_support_unittest.cc |
| +++ b/content/browser/service_worker/link_header_support_unittest.cc |
| @@ -111,7 +111,8 @@ class LinkHeaderServiceWorkerTest : public ::testing::Test { |
| context()->AddProviderHost(std::move(host)); |
| scoped_refptr<ServiceWorkerRegistration> registration = |
| - new ServiceWorkerRegistration(GURL("https://host/scope"), 1L, |
| + new ServiceWorkerRegistration(GURL("https://host/scope"), |
| + false /* use_cache* */, 1L, |
|
nhiroki
2017/03/28 06:49:51
There is an extra * ("use_cache*")
yuryu
2017/07/20 10:15:12
Acknowledged.
|
| context()->AsWeakPtr()); |
| scoped_refptr<ServiceWorkerVersion> version = new ServiceWorkerVersion( |
| registration.get(), GURL("https://host/script.js"), 1L, |
| @@ -181,6 +182,7 @@ TEST_F(LinkHeaderServiceWorkerTest, InstallServiceWorker_Basic) { |
| EXPECT_EQ(GURL("https://example.com/foo/"), registrations[0].pattern); |
| EXPECT_EQ(GURL("https://example.com/foo/foo.js"), |
| registrations[0].active_version.script_url); |
| + EXPECT_FALSE(registrations[0].use_cache); |
| } |
| TEST_F(LinkHeaderServiceWorkerTest, InstallServiceWorker_ScopeWithFragment) { |
| @@ -196,6 +198,7 @@ TEST_F(LinkHeaderServiceWorkerTest, InstallServiceWorker_ScopeWithFragment) { |
| registrations[0].pattern); |
| EXPECT_EQ(GURL("https://example.com/foo/bar.js"), |
| registrations[0].active_version.script_url); |
| + EXPECT_FALSE(registrations[0].use_cache); |
| } |
| TEST_F(LinkHeaderServiceWorkerTest, InstallServiceWorker_ScopeAbsoluteUrl) { |
| @@ -213,6 +216,7 @@ TEST_F(LinkHeaderServiceWorkerTest, InstallServiceWorker_ScopeAbsoluteUrl) { |
| registrations[0].pattern); |
| EXPECT_EQ(GURL("https://example.com/foo/bar/bar.js"), |
| registrations[0].active_version.script_url); |
| + EXPECT_FALSE(registrations[0].use_cache); |
| } |
| TEST_F(LinkHeaderServiceWorkerTest, InstallServiceWorker_ScopeDifferentOrigin) { |
| @@ -263,6 +267,7 @@ TEST_F(LinkHeaderServiceWorkerTest, InstallServiceWorker_ScriptAbsoluteUrl) { |
| EXPECT_EQ(GURL("https://example.com/foobar/foo"), registrations[0].pattern); |
| EXPECT_EQ(GURL("https://example.com/bar.js"), |
| registrations[0].active_version.script_url); |
| + EXPECT_FALSE(registrations[0].use_cache); |
| } |
| TEST_F(LinkHeaderServiceWorkerTest, |
| @@ -278,12 +283,27 @@ TEST_F(LinkHeaderServiceWorkerTest, |
| ASSERT_EQ(0u, registrations.size()); |
| } |
| +TEST_F(LinkHeaderServiceWorkerTest, InstallServiceWorker_UseCache) { |
| + CreateDocumentProviderHost(); |
| + ProcessLinkHeaderForRequest( |
| + CreateSubresourceRequest(GURL("https://example.com/foo/bar/")).get(), |
| + "<../foo.js>; rel=serviceworker; usecache", context_wrapper()); |
| + base::RunLoop().RunUntilIdle(); |
| + |
| + std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations(); |
| + ASSERT_EQ(1u, registrations.size()); |
| + EXPECT_EQ(GURL("https://example.com/foo/"), registrations[0].pattern); |
| + EXPECT_EQ(GURL("https://example.com/foo/foo.js"), |
| + registrations[0].active_version.script_url); |
| + EXPECT_TRUE(registrations[0].use_cache); |
| +} |
| + |
| TEST_F(LinkHeaderServiceWorkerTest, InstallServiceWorker_MultipleWorkers) { |
| CreateDocumentProviderHost(); |
| ProcessLinkHeaderForRequest( |
| CreateSubresourceRequest(GURL("https://example.com/foobar/")).get(), |
| "<bar.js>; rel=serviceworker; scope=foo, <baz.js>; " |
| - "rel=serviceworker; scope=scope", |
| + "rel=serviceworker; scope=scope; usecache", |
| context_wrapper()); |
| base::RunLoop().RunUntilIdle(); |
| @@ -292,9 +312,11 @@ TEST_F(LinkHeaderServiceWorkerTest, InstallServiceWorker_MultipleWorkers) { |
| EXPECT_EQ(GURL("https://example.com/foobar/foo"), registrations[0].pattern); |
| EXPECT_EQ(GURL("https://example.com/foobar/bar.js"), |
| registrations[0].active_version.script_url); |
| + EXPECT_FALSE(registrations[0].use_cache); |
| EXPECT_EQ(GURL("https://example.com/foobar/scope"), registrations[1].pattern); |
| EXPECT_EQ(GURL("https://example.com/foobar/baz.js"), |
| registrations[1].active_version.script_url); |
| + EXPECT_TRUE(registrations[1].use_cache); |
| } |
| TEST_F(LinkHeaderServiceWorkerTest, |
| @@ -347,6 +369,7 @@ TEST_F(LinkHeaderServiceWorkerTest, |
| EXPECT_EQ(GURL("https://example.com/foo/"), registrations[0].pattern); |
| EXPECT_EQ(GURL("https://example.com/foo/foo.js"), |
| registrations[0].active_version.script_url); |
| + EXPECT_FALSE(registrations[0].use_cache); |
| } |
| TEST_F(LinkHeaderServiceWorkerTest, |