OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
19 #include "base/synchronization/lock.h" | 19 #include "base/synchronization/lock.h" |
20 #include "base/threading/sequenced_worker_pool.h" | 20 #include "base/threading/sequenced_worker_pool.h" |
21 #include "base/values.h" | 21 #include "base/values.h" |
22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
23 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 23 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
24 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 24 |
25 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | |
26 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" | 25 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" |
27 #include "chrome/browser/net/net_error_diagnostics_dialog.h" | 26 #include "chrome/browser/net/net_error_diagnostics_dialog.h" |
28 #include "chrome/browser/net/url_request_mock_util.h" | 27 #include "chrome/browser/net/url_request_mock_util.h" |
29 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
30 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" | 29 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" |
31 #include "chrome/browser/ui/browser.h" | 30 #include "chrome/browser/ui/browser.h" |
32 #include "chrome/browser/ui/browser_commands.h" | 31 #include "chrome/browser/ui/browser_commands.h" |
33 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 32 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
34 #include "chrome/common/chrome_paths.h" | 33 #include "chrome/common/chrome_paths.h" |
35 #include "chrome/common/chrome_switches.h" | 34 #include "chrome/common/chrome_switches.h" |
36 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
37 #include "chrome/test/base/in_process_browser_test.h" | 36 #include "chrome/test/base/in_process_browser_test.h" |
38 #include "chrome/test/base/ui_test_utils.h" | 37 #include "chrome/test/base/ui_test_utils.h" |
39 #include "components/error_page/common/error_page_switches.h" | 38 #include "components/error_page/common/error_page_switches.h" |
40 #include "components/google/core/browser/google_util.h" | 39 #include "components/google/core/browser/google_util.h" |
41 #include "components/policy/core/browser/browser_policy_connector.h" | 40 #include "components/policy/core/browser/browser_policy_connector.h" |
42 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 41 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
43 #include "components/policy/core/common/policy_map.h" | 42 #include "components/policy/core/common/policy_map.h" |
44 #include "components/policy/policy_constants.h" | 43 #include "components/policy/policy_constants.h" |
45 #include "components/prefs/pref_service.h" | 44 #include "components/prefs/pref_service.h" |
46 #include "components/strings/grit/components_strings.h" | 45 #include "components/strings/grit/components_strings.h" |
47 #include "content/public/browser/browser_thread.h" | 46 #include "content/public/browser/browser_thread.h" |
| 47 #include "content/public/browser/browsing_data_remover.h" |
48 #include "content/public/browser/navigation_handle.h" | 48 #include "content/public/browser/navigation_handle.h" |
49 #include "content/public/browser/notification_service.h" | 49 #include "content/public/browser/notification_service.h" |
50 #include "content/public/browser/notification_types.h" | 50 #include "content/public/browser/notification_types.h" |
51 #include "content/public/browser/render_frame_host.h" | 51 #include "content/public/browser/render_frame_host.h" |
52 #include "content/public/browser/render_view_host.h" | 52 #include "content/public/browser/render_view_host.h" |
53 #include "content/public/browser/web_contents.h" | 53 #include "content/public/browser/web_contents.h" |
54 #include "content/public/browser/web_contents_observer.h" | 54 #include "content/public/browser/web_contents_observer.h" |
55 #include "content/public/test/browser_test_utils.h" | 55 #include "content/public/test/browser_test_utils.h" |
56 #include "content/public/test/test_navigation_observer.h" | 56 #include "content/public/test/test_navigation_observer.h" |
57 #include "net/base/filename_util.h" | 57 #include "net/base/filename_util.h" |
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 | 1000 |
1001 // Reload the same URL with a post request; confirm the error page is told | 1001 // Reload the same URL with a post request; confirm the error page is told |
1002 // that there is no cached copy. | 1002 // that there is no cached copy. |
1003 ui_test_utils::NavigateToURLWithPost(browser(), test_url); | 1003 ui_test_utils::NavigateToURLWithPost(browser(), test_url); |
1004 EXPECT_TRUE(ProbeStaleCopyValue(false)); | 1004 EXPECT_TRUE(ProbeStaleCopyValue(false)); |
1005 EXPECT_FALSE(IsDisplayingText(browser(), GetShowSavedButtonLabel())); | 1005 EXPECT_FALSE(IsDisplayingText(browser(), GetShowSavedButtonLabel())); |
1006 EXPECT_EQ(0, link_doctor_interceptor()->num_requests()); | 1006 EXPECT_EQ(0, link_doctor_interceptor()->num_requests()); |
1007 | 1007 |
1008 // Clear the cache and reload the same URL; confirm the error page is told | 1008 // Clear the cache and reload the same URL; confirm the error page is told |
1009 // that there is no cached copy. | 1009 // that there is no cached copy. |
1010 BrowsingDataRemover* remover = | 1010 content::BrowsingDataRemover* remover = |
1011 BrowsingDataRemoverFactory::GetForBrowserContext(browser()->profile()); | 1011 content::BrowserContext::GetBrowsingDataRemover(browser()->profile()); |
1012 remover->Remove(base::Time(), base::Time::Max(), | 1012 remover->Remove(base::Time(), base::Time::Max(), |
1013 BrowsingDataRemover::DATA_TYPE_CACHE, | 1013 content::BrowsingDataRemover::DATA_TYPE_CACHE, |
1014 BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB); | 1014 content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB); |
1015 ui_test_utils::NavigateToURL(browser(), test_url); | 1015 ui_test_utils::NavigateToURL(browser(), test_url); |
1016 EXPECT_TRUE(ProbeStaleCopyValue(false)); | 1016 EXPECT_TRUE(ProbeStaleCopyValue(false)); |
1017 EXPECT_FALSE(IsDisplayingText(browser(), GetShowSavedButtonLabel())); | 1017 EXPECT_FALSE(IsDisplayingText(browser(), GetShowSavedButtonLabel())); |
1018 EXPECT_EQ(0, link_doctor_interceptor()->num_requests()); | 1018 EXPECT_EQ(0, link_doctor_interceptor()->num_requests()); |
1019 } | 1019 } |
1020 | 1020 |
1021 // Check that the easter egg is present and initialised and is not disabled. | 1021 // Check that the easter egg is present and initialised and is not disabled. |
1022 IN_PROC_BROWSER_TEST_F(ErrorPageTest, CheckEasterEggIsNotDisabled) { | 1022 IN_PROC_BROWSER_TEST_F(ErrorPageTest, CheckEasterEggIsNotDisabled) { |
1023 ui_test_utils::NavigateToURL(browser(), | 1023 ui_test_utils::NavigateToURL(browser(), |
1024 URLRequestFailedJob::GetMockHttpUrl(net::ERR_INTERNET_DISCONNECTED)); | 1024 URLRequestFailedJob::GetMockHttpUrl(net::ERR_INTERNET_DISCONNECTED)); |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1272 // Confirm that loading the stale copy from the cache works. | 1272 // Confirm that loading the stale copy from the cache works. |
1273 content::TestNavigationObserver same_tab_observer( | 1273 content::TestNavigationObserver same_tab_observer( |
1274 browser()->tab_strip_model()->GetActiveWebContents(), 1); | 1274 browser()->tab_strip_model()->GetActiveWebContents(), 1); |
1275 ASSERT_TRUE(ReloadStaleCopyFromCache()); | 1275 ASSERT_TRUE(ReloadStaleCopyFromCache()); |
1276 same_tab_observer.Wait(); | 1276 same_tab_observer.Wait(); |
1277 EXPECT_EQ(base::ASCIIToUTF16("Nocache Test Page"), | 1277 EXPECT_EQ(base::ASCIIToUTF16("Nocache Test Page"), |
1278 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle()); | 1278 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle()); |
1279 | 1279 |
1280 // Clear the cache and reload the same URL; confirm the error page is told | 1280 // Clear the cache and reload the same URL; confirm the error page is told |
1281 // that there is no cached copy. | 1281 // that there is no cached copy. |
1282 BrowsingDataRemover* remover = | 1282 content::BrowsingDataRemover* remover = |
1283 BrowsingDataRemoverFactory::GetForBrowserContext(browser()->profile()); | 1283 content::BrowserContext::GetBrowsingDataRemover(browser()->profile()); |
1284 remover->Remove(base::Time(), base::Time::Max(), | 1284 remover->Remove(base::Time(), base::Time::Max(), |
1285 BrowsingDataRemover::DATA_TYPE_CACHE, | 1285 content::BrowsingDataRemover::DATA_TYPE_CACHE, |
1286 BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB); | 1286 content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB); |
1287 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( | 1287 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( |
1288 browser(), test_url, 2); | 1288 browser(), test_url, 2); |
1289 EXPECT_TRUE(ProbeStaleCopyValue(false)); | 1289 EXPECT_TRUE(ProbeStaleCopyValue(false)); |
1290 EXPECT_FALSE(IsDisplayingText(browser(), GetShowSavedButtonLabel())); | 1290 EXPECT_FALSE(IsDisplayingText(browser(), GetShowSavedButtonLabel())); |
1291 } | 1291 } |
1292 | 1292 |
1293 class ErrorPageOfflineTest : public ErrorPageTest { | 1293 class ErrorPageOfflineTest : public ErrorPageTest { |
1294 protected: | 1294 protected: |
1295 | 1295 |
1296 void SetUpInProcessBrowserTestFixture() override { | 1296 void SetUpInProcessBrowserTestFixture() override { |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1528 Http09WeirdPortEnabled) { | 1528 Http09WeirdPortEnabled) { |
1529 const char kHttp09Response[] = "JumboShrimp"; | 1529 const char kHttp09Response[] = "JumboShrimp"; |
1530 ASSERT_TRUE(embedded_test_server()->Start()); | 1530 ASSERT_TRUE(embedded_test_server()->Start()); |
1531 ui_test_utils::NavigateToURL( | 1531 ui_test_utils::NavigateToURL( |
1532 browser(), embedded_test_server()->GetURL(std::string("/echo-raw?") + | 1532 browser(), embedded_test_server()->GetURL(std::string("/echo-raw?") + |
1533 kHttp09Response)); | 1533 kHttp09Response)); |
1534 EXPECT_TRUE(IsDisplayingText(browser(), kHttp09Response)); | 1534 EXPECT_TRUE(IsDisplayingText(browser(), kHttp09Response)); |
1535 } | 1535 } |
1536 | 1536 |
1537 } // namespace | 1537 } // namespace |
OLD | NEW |