| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/test/scoped_feature_list.h" | 10 #include "base/test/scoped_feature_list.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 const char kMaxAgeCacheControl[] = "max-age=0"; | 32 const char kMaxAgeCacheControl[] = "max-age=0"; |
| 33 const char kNoCacheCacheControl[] = "no-cache"; | 33 const char kNoCacheCacheControl[] = "no-cache"; |
| 34 | 34 |
| 35 struct RequestLog { | 35 struct RequestLog { |
| 36 std::string relative_url; | 36 std::string relative_url; |
| 37 std::string cache_control; | 37 std::string cache_control; |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 class ReloadCacheControlBrowserTest : public ContentBrowserTest { | 40 class ReloadCacheControlBrowserTest : public ContentBrowserTest { |
| 41 protected: | 41 protected: |
| 42 ReloadCacheControlBrowserTest() = default; | 42 ReloadCacheControlBrowserTest() { |
| 43 ~ReloadCacheControlBrowserTest() override = default; | |
| 44 | |
| 45 void SetUpOnMainThread() override { | |
| 46 // TODO(toyoshim): Tests in this file depend on current reload behavior, | 43 // TODO(toyoshim): Tests in this file depend on current reload behavior, |
| 47 // and should be modified when we enable the new reload behavior. | 44 // and should be modified when we enable the new reload behavior. |
| 48 scoped_feature_list_.InitAndDisableFeature( | 45 scoped_feature_list_.InitAndDisableFeature( |
| 49 features::kNonValidatingReloadOnNormalReload); | 46 features::kNonValidatingReloadOnNormalReload); |
| 47 } |
| 48 ~ReloadCacheControlBrowserTest() override = default; |
| 50 | 49 |
| 50 void SetUpOnMainThread() override { |
| 51 SetUpTestServerOnMainThread(); | 51 SetUpTestServerOnMainThread(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void SetUpTestServerOnMainThread() { | 54 void SetUpTestServerOnMainThread() { |
| 55 // ContentBrowserTest creates embedded_test_server instance with | 55 // ContentBrowserTest creates embedded_test_server instance with |
| 56 // a registered HandleFileRequest for "content/test/data". | 56 // a registered HandleFileRequest for "content/test/data". |
| 57 // Because the handler is registered as the first handler, MonitorHandler | 57 // Because the handler is registered as the first handler, MonitorHandler |
| 58 // is needed to capture all requests. | 58 // is needed to capture all requests. |
| 59 embedded_test_server()->RegisterRequestMonitor(base::Bind( | 59 embedded_test_server()->RegisterRequestMonitor(base::Bind( |
| 60 &ReloadCacheControlBrowserTest::MonitorRequestHandler, | 60 &ReloadCacheControlBrowserTest::MonitorRequestHandler, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 78 } | 78 } |
| 79 | 79 |
| 80 base::test::ScopedFeatureList scoped_feature_list_; | 80 base::test::ScopedFeatureList scoped_feature_list_; |
| 81 | 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(ReloadCacheControlBrowserTest); | 82 DISALLOW_COPY_AND_ASSIGN(ReloadCacheControlBrowserTest); |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 class ReloadCacheControlWithAnExperimentBrowserTest | 85 class ReloadCacheControlWithAnExperimentBrowserTest |
| 86 : public ReloadCacheControlBrowserTest { | 86 : public ReloadCacheControlBrowserTest { |
| 87 protected: | 87 protected: |
| 88 ReloadCacheControlWithAnExperimentBrowserTest() = default; | 88 ReloadCacheControlWithAnExperimentBrowserTest() { |
| 89 scoped_feature_list_.InitAndEnableFeature( |
| 90 features::kNonValidatingReloadOnNormalReload); |
| 91 } |
| 89 ~ReloadCacheControlWithAnExperimentBrowserTest() override = default; | 92 ~ReloadCacheControlWithAnExperimentBrowserTest() override = default; |
| 90 | 93 |
| 91 void SetUpOnMainThread() override { | 94 void SetUpOnMainThread() override { |
| 92 scoped_feature_list_.InitAndEnableFeature( | |
| 93 features::kNonValidatingReloadOnNormalReload); | |
| 94 | |
| 95 SetUpTestServerOnMainThread(); | 95 SetUpTestServerOnMainThread(); |
| 96 } | 96 } |
| 97 | 97 |
| 98 base::test::ScopedFeatureList scoped_feature_list_; | 98 base::test::ScopedFeatureList scoped_feature_list_; |
| 99 | 99 |
| 100 DISALLOW_COPY_AND_ASSIGN(ReloadCacheControlWithAnExperimentBrowserTest); | 100 DISALLOW_COPY_AND_ASSIGN(ReloadCacheControlWithAnExperimentBrowserTest); |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 IN_PROC_BROWSER_TEST_F(ReloadCacheControlBrowserTest, NormalReload) { | 103 IN_PROC_BROWSER_TEST_F(ReloadCacheControlBrowserTest, NormalReload) { |
| 104 GURL url(embedded_test_server()->GetURL(kReloadTestPath)); | 104 GURL url(embedded_test_server()->GetURL(kReloadTestPath)); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 EXPECT_EQ(kMaxAgeCacheControl, request_log_[2].cache_control); | 153 EXPECT_EQ(kMaxAgeCacheControl, request_log_[2].cache_control); |
| 154 EXPECT_EQ(kReloadImagePath, request_log_[3].relative_url); | 154 EXPECT_EQ(kReloadImagePath, request_log_[3].relative_url); |
| 155 EXPECT_EQ(kNoCacheControl, request_log_[3].cache_control); | 155 EXPECT_EQ(kNoCacheControl, request_log_[3].cache_control); |
| 156 } | 156 } |
| 157 | 157 |
| 158 // TODO(toyoshim): Add another set of reload tests with DevTools open. | 158 // TODO(toyoshim): Add another set of reload tests with DevTools open. |
| 159 | 159 |
| 160 } // namespace | 160 } // namespace |
| 161 | 161 |
| 162 } // namespace content | 162 } // namespace content |
| OLD | NEW |