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

Side by Side Diff: chrome/browser/prerender/prerender_browsertest.cc

Issue 1114623002: Plugin Power Saver: Make PPS work well with prerendered pages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 unified diff | Download patch
OLDNEW
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 <deque> 5 #include <deque>
6 #include <vector> 6 #include <vector>
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/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 #include "net/cert/x509_certificate.h" 96 #include "net/cert/x509_certificate.h"
97 #include "net/dns/mock_host_resolver.h" 97 #include "net/dns/mock_host_resolver.h"
98 #include "net/ssl/client_cert_store.h" 98 #include "net/ssl/client_cert_store.h"
99 #include "net/ssl/ssl_cert_request_info.h" 99 #include "net/ssl/ssl_cert_request_info.h"
100 #include "net/test/url_request/url_request_mock_http_job.h" 100 #include "net/test/url_request/url_request_mock_http_job.h"
101 #include "net/url_request/url_request_context.h" 101 #include "net/url_request/url_request_context.h"
102 #include "net/url_request/url_request_context_getter.h" 102 #include "net/url_request/url_request_context_getter.h"
103 #include "net/url_request/url_request_filter.h" 103 #include "net/url_request/url_request_filter.h"
104 #include "net/url_request/url_request_interceptor.h" 104 #include "net/url_request/url_request_interceptor.h"
105 #include "net/url_request/url_request_job.h" 105 #include "net/url_request/url_request_job.h"
106 #include "ppapi/shared_impl/ppapi_switches.h"
106 #include "ui/base/l10n/l10n_util.h" 107 #include "ui/base/l10n/l10n_util.h"
107 #include "url/gurl.h" 108 #include "url/gurl.h"
108 109
109 using chrome_browser_net::NetworkPredictionOptions; 110 using chrome_browser_net::NetworkPredictionOptions;
110 using content::BrowserThread; 111 using content::BrowserThread;
111 using content::DevToolsAgentHost; 112 using content::DevToolsAgentHost;
112 using content::NavigationController; 113 using content::NavigationController;
113 using content::OpenURLParams; 114 using content::OpenURLParams;
114 using content::Referrer; 115 using content::Referrer;
115 using content::RenderFrameHost; 116 using content::RenderFrameHost;
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 1102
1102 void TearDownInProcessBrowserTestFixture() override { 1103 void TearDownInProcessBrowserTestFixture() override {
1103 #if defined(FULL_SAFE_BROWSING) 1104 #if defined(FULL_SAFE_BROWSING)
1104 SafeBrowsingService::RegisterFactory(NULL); 1105 SafeBrowsingService::RegisterFactory(NULL);
1105 #endif 1106 #endif
1106 } 1107 }
1107 1108
1108 void SetUpCommandLine(base::CommandLine* command_line) override { 1109 void SetUpCommandLine(base::CommandLine* command_line) override {
1109 command_line->AppendSwitchASCII(switches::kPrerenderMode, 1110 command_line->AppendSwitchASCII(switches::kPrerenderMode,
1110 switches::kPrerenderModeSwitchValueEnabled); 1111 switches::kPrerenderModeSwitchValueEnabled);
1111 ASSERT_TRUE(ppapi::RegisterTestPlugin(command_line)); 1112 command_line->AppendSwitch(switches::kEnablePepperTesting);
1113
1114 ASSERT_TRUE(ppapi::RegisterPowerSaverTestPlugin(command_line));
1112 } 1115 }
1113 1116
1114 void SetUpOnMainThread() override { 1117 void SetUpOnMainThread() override {
1115 current_browser()->profile()->GetPrefs()->SetBoolean( 1118 current_browser()->profile()->GetPrefs()->SetBoolean(
1116 prefs::kPromptForDownload, false); 1119 prefs::kPromptForDownload, false);
1117 IncreasePrerenderMemory(); 1120 IncreasePrerenderMemory();
1118 if (autostart_test_server_) 1121 if (autostart_test_server_)
1119 ASSERT_TRUE(test_server()->Start()); 1122 ASSERT_TRUE(test_server()->Start());
1120 ChromeResourceDispatcherHostDelegate:: 1123 ChromeResourceDispatcherHostDelegate::
1121 SetExternalProtocolHandlerDelegateForTesting( 1124 SetExternalProtocolHandlerDelegateForTesting(
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
1961 // Javascript alert is called. 1964 // Javascript alert is called.
1962 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderAlertAfterOnload) { 1965 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderAlertAfterOnload) {
1963 PrerenderTestURL("files/prerender/prerender_alert_after_onload.html", 1966 PrerenderTestURL("files/prerender/prerender_alert_after_onload.html",
1964 FINAL_STATUS_JAVASCRIPT_ALERT, 1967 FINAL_STATUS_JAVASCRIPT_ALERT,
1965 1); 1968 1);
1966 } 1969 }
1967 1970
1968 // Checks that plugins are not loaded while a page is being preloaded, but 1971 // Checks that plugins are not loaded while a page is being preloaded, but
1969 // are loaded when the page is displayed. 1972 // are loaded when the page is displayed.
1970 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDelayLoadPlugin) { 1973 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDelayLoadPlugin) {
1971 PrerenderTestURL("files/prerender/plugin_delay_load.html", FINAL_STATUS_USED, 1974 PrerenderTestURL("files/prerender/prerender_plugin_delay_load.html",
1972 1); 1975 FINAL_STATUS_USED, 1);
1973 NavigateToDestURL(); 1976 NavigateToDestURL();
1974 } 1977 }
1975 1978
1976 // For Content Setting DETECT, checks that plugins are not loaded while 1979 // For Content Setting DETECT, checks that plugins are not loaded while
1977 // a page is being preloaded, but are loaded when the page is displayed. 1980 // a page is being preloaded, but are loaded when the page is displayed.
1978 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderContentSettingDetect) { 1981 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderContentSettingDetect) {
1979 HostContentSettingsMap* content_settings_map = 1982 HostContentSettingsMap* content_settings_map =
1980 current_browser()->profile()->GetHostContentSettingsMap(); 1983 current_browser()->profile()->GetHostContentSettingsMap();
1981 content_settings_map->SetDefaultContentSetting( 1984 content_settings_map->SetDefaultContentSetting(
1982 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_DETECT_IMPORTANT_CONTENT); 1985 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_DETECT_IMPORTANT_CONTENT);
1983 1986
1984 PrerenderTestURL("files/prerender/plugin_delay_load.html", FINAL_STATUS_USED, 1987 PrerenderTestURL("files/prerender/prerender_plugin_power_saver.html",
1985 1); 1988 FINAL_STATUS_USED, 1);
1989
1990 DisableJavascriptCalls();
1986 NavigateToDestURL(); 1991 NavigateToDestURL();
1992 bool second_placeholder_present = false;
1993 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
1994 GetActiveWebContents(), "AwaitPluginPrerollAndPlaceholder();",
1995 &second_placeholder_present));
1996 EXPECT_TRUE(second_placeholder_present);
1987 } 1997 }
1988 1998
1989 // For Content Setting BLOCK, checks that plugins are never loaded. 1999 // For Content Setting BLOCK, checks that plugins are never loaded.
1990 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderContentSettingBlock) { 2000 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderContentSettingBlock) {
1991 HostContentSettingsMap* content_settings_map = 2001 HostContentSettingsMap* content_settings_map =
1992 current_browser()->profile()->GetHostContentSettingsMap(); 2002 current_browser()->profile()->GetHostContentSettingsMap();
1993 content_settings_map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, 2003 content_settings_map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS,
1994 CONTENT_SETTING_BLOCK); 2004 CONTENT_SETTING_BLOCK);
1995 2005
1996 PrerenderTestURL("files/prerender/plugin_never_load.html", FINAL_STATUS_USED, 2006 PrerenderTestURL("files/prerender/prerender_plugin_never_load.html",
1997 1); 2007 FINAL_STATUS_USED, 1);
1998 NavigateToDestURL(); 2008 NavigateToDestURL();
1999 } 2009 }
2000 2010
2001 // Checks that we don't load a NaCl plugin when NaCl is disabled. 2011 // Checks that we don't load a NaCl plugin when NaCl is disabled.
2002 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderNaClPluginDisabled) { 2012 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderNaClPluginDisabled) {
2003 PrerenderTestURL("files/prerender/prerender_plugin_nacl_disabled.html", 2013 PrerenderTestURL("files/prerender/prerender_plugin_nacl_disabled.html",
2004 FINAL_STATUS_USED, 2014 FINAL_STATUS_USED,
2005 1); 2015 1);
2006 NavigateToDestURL(); 2016 NavigateToDestURL();
2007 2017
(...skipping 2045 matching lines...) Expand 10 before | Expand all | Expand 10 after
4053 browser()->tab_strip_model()->GetActiveWebContents(); 4063 browser()->tab_strip_model()->GetActiveWebContents();
4054 bool display_test_result = false; 4064 bool display_test_result = false;
4055 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents, 4065 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents,
4056 "DidDisplayReallyPass()", 4066 "DidDisplayReallyPass()",
4057 &display_test_result)); 4067 &display_test_result));
4058 ASSERT_TRUE(display_test_result); 4068 ASSERT_TRUE(display_test_result);
4059 } 4069 }
4060 #endif // !defined(DISABLE_NACL) 4070 #endif // !defined(DISABLE_NACL)
4061 4071
4062 } // namespace prerender 4072 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/plugins/plugin_power_saver_browsertest.cc ('k') | chrome/renderer/chrome_content_renderer_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698