Commit 05faba13 authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

Make sure DRP is disabled when incognito

Creating an incognito window was crashing when DRP was enabled with
network service.

Bug: 721403
Change-Id: I7c97fec3e6dd4b15358c73eb442f441caa45f5af
Reviewed-on: https://chromium-review.googlesource.com/c/1305515Reviewed-by: default avatarrajendrant <rajendrant@chromium.org>
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603588}
parent 0fdad893
...@@ -4365,7 +4365,8 @@ ChromeContentBrowserClient::CreateURLLoaderThrottles( ...@@ -4365,7 +4365,8 @@ ChromeContentBrowserClient::CreateURLLoaderThrottles(
io_data = ProfileIOData::FromResourceContext(resource_context); io_data = ProfileIOData::FromResourceContext(resource_context);
} }
if (io_data && data_reduction_proxy::params::IsEnabledWithNetworkService()) { if (io_data && io_data->data_reduction_proxy_io_data() &&
data_reduction_proxy::params::IsEnabledWithNetworkService()) {
net::HttpRequestHeaders headers; net::HttpRequestHeaders headers;
data_reduction_proxy::DataReductionProxyRequestOptions* request_options = data_reduction_proxy::DataReductionProxyRequestOptions* request_options =
io_data->data_reduction_proxy_io_data()->request_options(); io_data->data_reduction_proxy_io_data()->request_options();
......
...@@ -150,10 +150,12 @@ class DataReductionProxyBrowsertestBase : public InProcessBrowserTest { ...@@ -150,10 +150,12 @@ class DataReductionProxyBrowsertestBase : public InProcessBrowserTest {
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
} }
std::string GetBody() { std::string GetBody() { return GetBody(browser()); }
std::string GetBody(Browser* browser) {
std::string body; std::string body;
EXPECT_TRUE(content::ExecuteScriptAndExtractString( EXPECT_TRUE(content::ExecuteScriptAndExtractString(
browser()->tab_strip_model()->GetActiveWebContents(), browser->tab_strip_model()->GetActiveWebContents(),
"window.domAutomationController.send(document.body.textContent);", "window.domAutomationController.send(document.body.textContent);",
&body)); &body));
return body; return body;
...@@ -245,6 +247,35 @@ IN_PROC_BROWSER_TEST_F(DataReductionProxyBrowsertest, ChromeProxyHeaderSet) { ...@@ -245,6 +247,35 @@ IN_PROC_BROWSER_TEST_F(DataReductionProxyBrowsertest, ChromeProxyHeaderSet) {
EXPECT_THAT(body, HasSubstr("pid=")); EXPECT_THAT(body, HasSubstr("pid="));
} }
IN_PROC_BROWSER_TEST_F(DataReductionProxyBrowsertest, DisabledOnIncognito) {
net::EmbeddedTestServer test_server;
test_server.RegisterRequestHandler(
base::BindRepeating(&BasicResponse, kDummyBody));
ASSERT_TRUE(test_server.Start());
Browser* incognito = CreateIncognitoBrowser();
ui_test_utils::NavigateToURL(
incognito, GetURLWithMockHost(test_server, "/echoheader?Chrome-Proxy"));
EXPECT_EQ(GetBody(incognito), kDummyBody);
// Make sure subresource doesn't use DRP either.
std::string script = R"((url => {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onload = () => domAutomationController.send(xhr.responseText);
xhr.send();
}))";
std::string result;
ASSERT_TRUE(ExecuteScriptAndExtractString(
incognito->tab_strip_model()->GetActiveWebContents(),
script + "('" +
GetURLWithMockHost(test_server, "/echoheader?Chrome-Proxy").spec() +
"')",
&result));
EXPECT_EQ(result, kDummyBody);
}
IN_PROC_BROWSER_TEST_F(DataReductionProxyBrowsertest, IN_PROC_BROWSER_TEST_F(DataReductionProxyBrowsertest,
ChromeProxyHeaderSetForSubresource) { ChromeProxyHeaderSetForSubresource) {
net::EmbeddedTestServer test_server; net::EmbeddedTestServer test_server;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment