Chromium Code Reviews| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <deque> | 6 #include <deque> |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <unordered_map> | 9 #include <unordered_map> |
| 10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ref_counted_memory.h" | 17 #include "base/memory/ref_counted_memory.h" |
| 18 #include "base/memory/scoped_vector.h" | 18 #include "base/memory/scoped_vector.h" |
| 19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 20 #include "base/path_service.h" | 20 #include "base/path_service.h" |
| 21 #include "base/run_loop.h" | 21 #include "base/run_loop.h" |
| 22 #include "base/scoped_observer.h" | 22 #include "base/scoped_observer.h" |
| 23 #include "base/stl_util.h" | 23 #include "base/stl_util.h" |
| 24 #include "base/strings/string_split.h" | 24 #include "base/strings/string_split.h" |
| 25 #include "base/strings/string_util.h" | 25 #include "base/strings/string_util.h" |
| 26 #include "base/strings/stringprintf.h" | 26 #include "base/strings/stringprintf.h" |
| 27 #include "base/strings/utf_string_conversions.h" | 27 #include "base/strings/utf_string_conversions.h" |
| 28 #include "base/test/histogram_tester.h" | 28 #include "base/test/histogram_tester.h" |
| 29 #include "base/test/scoped_feature_list.h" | |
| 29 #include "base/test/test_timeouts.h" | 30 #include "base/test/test_timeouts.h" |
| 30 #include "base/values.h" | 31 #include "base/values.h" |
| 31 #include "build/build_config.h" | 32 #include "build/build_config.h" |
| 32 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 33 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 33 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 34 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 34 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 35 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
| 35 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" | 36 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" |
| 36 #include "chrome/browser/chrome_content_browser_client.h" | 37 #include "chrome/browser/chrome_content_browser_client.h" |
| 37 #include "chrome/browser/chrome_notification_types.h" | 38 #include "chrome/browser/chrome_notification_types.h" |
| 38 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 39 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 55 #include "chrome/browser/task_manager/mock_web_contents_task_manager.h" | 56 #include "chrome/browser/task_manager/mock_web_contents_task_manager.h" |
| 56 #include "chrome/browser/task_manager/providers/web_contents/web_contents_tags_m anager.h" | 57 #include "chrome/browser/task_manager/providers/web_contents/web_contents_tags_m anager.h" |
| 57 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" | 58 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" |
| 58 #include "chrome/browser/ui/browser.h" | 59 #include "chrome/browser/ui/browser.h" |
| 59 #include "chrome/browser/ui/browser_commands.h" | 60 #include "chrome/browser/ui/browser_commands.h" |
| 60 #include "chrome/browser/ui/browser_finder.h" | 61 #include "chrome/browser/ui/browser_finder.h" |
| 61 #include "chrome/browser/ui/browser_window.h" | 62 #include "chrome/browser/ui/browser_window.h" |
| 62 #include "chrome/browser/ui/location_bar/location_bar.h" | 63 #include "chrome/browser/ui/location_bar/location_bar.h" |
| 63 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 64 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 64 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 65 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
| 66 #include "chrome/common/chrome_features.h" | |
| 65 #include "chrome/common/chrome_paths.h" | 67 #include "chrome/common/chrome_paths.h" |
| 66 #include "chrome/common/chrome_switches.h" | 68 #include "chrome/common/chrome_switches.h" |
| 67 #include "chrome/grit/generated_resources.h" | 69 #include "chrome/grit/generated_resources.h" |
| 68 #include "chrome/test/base/ui_test_utils.h" | 70 #include "chrome/test/base/ui_test_utils.h" |
| 69 #include "components/content_settings/core/browser/host_content_settings_map.h" | 71 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 70 #include "components/favicon/content/content_favicon_driver.h" | 72 #include "components/favicon/content/content_favicon_driver.h" |
| 71 #include "components/favicon/core/favicon_driver_observer.h" | 73 #include "components/favicon/core/favicon_driver_observer.h" |
| 72 #include "components/omnibox/browser/omnibox_edit_model.h" | 74 #include "components/omnibox/browser/omnibox_edit_model.h" |
| 73 #include "components/omnibox/browser/omnibox_popup_model.h" | 75 #include "components/omnibox/browser/omnibox_popup_model.h" |
| 74 #include "components/omnibox/browser/omnibox_view.h" | 76 #include "components/omnibox/browser/omnibox_view.h" |
| 75 #include "components/safe_browsing_db/database_manager.h" | 77 #include "components/safe_browsing_db/database_manager.h" |
| 76 #include "components/safe_browsing_db/util.h" | 78 #include "components/safe_browsing_db/util.h" |
| 77 #include "components/variations/entropy_provider.h" | 79 #include "components/variations/entropy_provider.h" |
| 78 #include "components/variations/variations_associated_data.h" | 80 #include "components/variations/variations_associated_data.h" |
| 79 #include "content/public/browser/browser_message_filter.h" | 81 #include "content/public/browser/browser_message_filter.h" |
| 80 #include "content/public/browser/devtools_agent_host.h" | 82 #include "content/public/browser/devtools_agent_host.h" |
| 81 #include "content/public/browser/navigation_controller.h" | 83 #include "content/public/browser/navigation_controller.h" |
| 82 #include "content/public/browser/navigation_entry.h" | 84 #include "content/public/browser/navigation_entry.h" |
| 83 #include "content/public/browser/notification_service.h" | 85 #include "content/public/browser/notification_service.h" |
| 84 #include "content/public/browser/render_frame_host.h" | 86 #include "content/public/browser/render_frame_host.h" |
| 85 #include "content/public/browser/render_process_host.h" | 87 #include "content/public/browser/render_process_host.h" |
| 86 #include "content/public/browser/render_view_host.h" | 88 #include "content/public/browser/render_view_host.h" |
| 87 #include "content/public/browser/site_instance.h" | 89 #include "content/public/browser/site_instance.h" |
| 88 #include "content/public/browser/web_contents.h" | 90 #include "content/public/browser/web_contents.h" |
| 89 #include "content/public/browser/web_contents_observer.h" | 91 #include "content/public/browser/web_contents_observer.h" |
| 90 #include "content/public/common/content_switches.h" | 92 #include "content/public/common/content_switches.h" |
| 91 #include "content/public/common/resource_request_body.h" | 93 #include "content/public/common/resource_request_body.h" |
| 92 #include "content/public/common/url_constants.h" | 94 #include "content/public/common/url_constants.h" |
| 93 #include "content/public/test/browser_test_utils.h" | 95 #include "content/public/test/browser_test_utils.h" |
| 96 #include "content/public/test/ppapi_test_utils.h" | |
| 94 #include "content/public/test/test_navigation_observer.h" | 97 #include "content/public/test/test_navigation_observer.h" |
| 95 #include "content/public/test/test_utils.h" | 98 #include "content/public/test/test_utils.h" |
| 96 #include "extensions/common/constants.h" | 99 #include "extensions/common/constants.h" |
| 97 #include "extensions/common/extension_urls.h" | 100 #include "extensions/common/extension_urls.h" |
| 98 #include "extensions/common/manifest_handlers/mime_types_handler.h" | 101 #include "extensions/common/manifest_handlers/mime_types_handler.h" |
| 99 #include "extensions/common/switches.h" | 102 #include "extensions/common/switches.h" |
| 100 #include "extensions/test/result_catcher.h" | 103 #include "extensions/test/result_catcher.h" |
| 101 #include "net/base/escape.h" | 104 #include "net/base/escape.h" |
| 102 #include "net/cert/x509_certificate.h" | 105 #include "net/cert/x509_certificate.h" |
| 103 #include "net/dns/mock_host_resolver.h" | 106 #include "net/dns/mock_host_resolver.h" |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 597 : call_javascript_(true), | 600 : call_javascript_(true), |
| 598 check_load_events_(true), | 601 check_load_events_(true), |
| 599 loader_path_("/prerender/prerender_loader.html") {} | 602 loader_path_("/prerender/prerender_loader.html") {} |
| 600 | 603 |
| 601 ~PrerenderBrowserTest() override {} | 604 ~PrerenderBrowserTest() override {} |
| 602 | 605 |
| 603 void SetUpCommandLine(base::CommandLine* command_line) override { | 606 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 604 PrerenderInProcessBrowserTest::SetUpCommandLine(command_line); | 607 PrerenderInProcessBrowserTest::SetUpCommandLine(command_line); |
| 605 command_line->AppendSwitchASCII(switches::kPrerenderMode, | 608 command_line->AppendSwitchASCII(switches::kPrerenderMode, |
| 606 switches::kPrerenderModeSwitchValueEnabled); | 609 switches::kPrerenderModeSwitchValueEnabled); |
| 610 ASSERT_TRUE(ppapi::RegisterPowerSaverTestPlugin(command_line)); | |
| 607 } | 611 } |
| 608 | 612 |
| 609 void NavigateToDestURL() const { | 613 void NavigateToDestURL() const { |
| 610 NavigateToDestURLWithDisposition(WindowOpenDisposition::CURRENT_TAB, true); | 614 NavigateToDestURLWithDisposition(WindowOpenDisposition::CURRENT_TAB, true); |
| 611 } | 615 } |
| 612 | 616 |
| 613 // Opens the url in a new tab, with no opener. | 617 // Opens the url in a new tab, with no opener. |
| 614 void NavigateToDestURLWithDisposition( | 618 void NavigateToDestURLWithDisposition( |
| 615 WindowOpenDisposition disposition, | 619 WindowOpenDisposition disposition, |
| 616 bool expect_swap_to_succeed) const { | 620 bool expect_swap_to_succeed) const { |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1343 } | 1347 } |
| 1344 | 1348 |
| 1345 // Checks that plugins are not loaded while a page is being preloaded, but | 1349 // Checks that plugins are not loaded while a page is being preloaded, but |
| 1346 // are loaded when the page is displayed. | 1350 // are loaded when the page is displayed. |
| 1347 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDelayLoadPlugin) { | 1351 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDelayLoadPlugin) { |
| 1348 PrerenderTestURL("/prerender/prerender_plugin_delay_load.html", | 1352 PrerenderTestURL("/prerender/prerender_plugin_delay_load.html", |
| 1349 FINAL_STATUS_USED, 1); | 1353 FINAL_STATUS_USED, 1); |
| 1350 NavigateToDestURL(); | 1354 NavigateToDestURL(); |
| 1351 } | 1355 } |
| 1352 | 1356 |
| 1353 // For Content Setting DETECT, checks that plugins are not loaded while | 1357 // TODO(tommycli): Remove once we implement PPS on ALLOW. crbug.com/649814 |
|
xhwang
2016/09/26 23:44:51
What is PPS?
tommycli
2016/09/27 18:51:07
Done.
| |
| 1358 class PrerenderBrowserTestWithPluginPowerSaver : public PrerenderBrowserTest { | |
| 1359 public: | |
| 1360 PrerenderBrowserTestWithPluginPowerSaver() {} | |
| 1361 ~PrerenderBrowserTestWithPluginPowerSaver() override {} | |
| 1362 | |
| 1363 void SetUpInProcessBrowserTestFixture() override { | |
| 1364 PrerenderBrowserTest::SetUpInProcessBrowserTestFixture(); | |
| 1365 feature_list.InitAndDisableFeature(features::kPreferHtmlOverPlugins); | |
| 1366 } | |
| 1367 | |
| 1368 private: | |
| 1369 base::test::ScopedFeatureList feature_list; | |
| 1370 }; | |
| 1371 | |
| 1372 // For Plugin Power Saver, checks that plugins are not loaded while | |
| 1354 // a page is being preloaded, but are loaded when the page is displayed. | 1373 // a page is being preloaded, but are loaded when the page is displayed. |
| 1355 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderContentSettingDetect) { | 1374 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTestWithPluginPowerSaver, |
| 1375 PrerenderPluginPowerSaver) { | |
| 1356 HostContentSettingsMap* content_settings_map = | 1376 HostContentSettingsMap* content_settings_map = |
| 1357 HostContentSettingsMapFactory::GetForProfile( | 1377 HostContentSettingsMapFactory::GetForProfile( |
| 1358 current_browser()->profile()); | 1378 current_browser()->profile()); |
| 1359 content_settings_map->SetDefaultContentSetting( | 1379 content_settings_map->SetDefaultContentSetting( |
| 1360 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_DETECT_IMPORTANT_CONTENT); | 1380 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_DETECT_IMPORTANT_CONTENT); |
| 1361 | 1381 |
| 1362 PrerenderTestURL("/prerender/prerender_plugin_power_saver.html", | 1382 PrerenderTestURL("/prerender/prerender_plugin_power_saver.html", |
| 1363 FINAL_STATUS_USED, 1); | 1383 FINAL_STATUS_USED, 1); |
| 1364 | 1384 |
| 1365 DisableJavascriptCalls(); | 1385 DisableJavascriptCalls(); |
| (...skipping 1995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3361 browser()->tab_strip_model()->GetActiveWebContents(); | 3381 browser()->tab_strip_model()->GetActiveWebContents(); |
| 3362 bool display_test_result = false; | 3382 bool display_test_result = false; |
| 3363 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents, | 3383 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents, |
| 3364 "DidDisplayReallyPass()", | 3384 "DidDisplayReallyPass()", |
| 3365 &display_test_result)); | 3385 &display_test_result)); |
| 3366 ASSERT_TRUE(display_test_result); | 3386 ASSERT_TRUE(display_test_result); |
| 3367 } | 3387 } |
| 3368 #endif // !defined(DISABLE_NACL) | 3388 #endif // !defined(DISABLE_NACL) |
| 3369 | 3389 |
| 3370 } // namespace prerender | 3390 } // namespace prerender |
| OLD | NEW |