Chromium Code Reviews| Index: content/browser/devtools/protocol/devtools_protocol_browsertest.cc |
| diff --git a/content/browser/devtools/protocol/devtools_protocol_browsertest.cc b/content/browser/devtools/protocol/devtools_protocol_browsertest.cc |
| index de3761dff67071a6f498f99bacf3df1ddd2abc08..397893610f7237ee82d1098299f6aa7ea089a823 100644 |
| --- a/content/browser/devtools/protocol/devtools_protocol_browsertest.cc |
| +++ b/content/browser/devtools/protocol/devtools_protocol_browsertest.cc |
| @@ -1651,4 +1651,45 @@ IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, SetAndGetCookies) { |
| EXPECT_EQ(2u, found); |
| } |
| +IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, SetNavigationReferrer) { |
| + ASSERT_TRUE(embedded_test_server()->Start()); |
|
pfeldman
2017/02/21 18:47:30
Why not inspector protocol test?
Sami
2017/02/22 16:01:58
Done. (Although it ended up being a little involve
|
| + NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); |
| + Attach(); |
| + SendCommand("Network.enable", nullptr, false); |
| + SendCommand("Page.enable", nullptr, false); |
| + |
| + std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); |
| + GURL test_url = |
| + embedded_test_server()->GetURL("/devtools/referrer/referrer.html"); |
| + GURL referrer_url("http://example.com"); |
| + params->SetString("url", test_url.spec()); |
| + params->SetString("referrer", referrer_url.spec()); |
| + SendCommand("Page.navigate", std::move(params), true); |
| + |
| + // We should see two resources being requested: firstly the main page (which |
| + // should use our custom referrer) and secondly the embedded image (whose |
| + // referrer should be the main page). |
| + std::string url; |
| + std::string referrer; |
| + base::DictionaryValue* request_params; |
| + base::DictionaryValue* request_headers; |
| + params = WaitForNotification("Network.requestWillBeSent", true); |
| + ASSERT_TRUE(params->GetDictionary("request", &request_params)); |
| + ASSERT_TRUE(request_params->GetDictionary("headers", &request_headers)); |
| + EXPECT_TRUE(request_params->GetString("url", &url)); |
| + EXPECT_TRUE(request_headers->GetString("Referer", &referrer)); |
| + EXPECT_EQ(test_url.spec(), url); |
| + EXPECT_EQ(referrer_url.spec(), referrer); |
| + |
| + params = WaitForNotification("Network.requestWillBeSent", true); |
| + GURL image_url = |
| + embedded_test_server()->GetURL("/devtools/referrer/image.png"); |
| + ASSERT_TRUE(params->GetDictionary("request", &request_params)); |
| + ASSERT_TRUE(request_params->GetDictionary("headers", &request_headers)); |
| + EXPECT_TRUE(request_params->GetString("url", &url)); |
| + EXPECT_TRUE(request_headers->GetString("Referer", &referrer)); |
| + EXPECT_EQ(image_url.spec(), url); |
| + EXPECT_EQ(test_url.spec(), referrer); |
| +} |
| + |
| } // namespace content |