Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/base64.h" | 8 #include "base/base64.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1644 EXPECT_TRUE(cookie->GetString("value", &value)); | 1644 EXPECT_TRUE(cookie->GetString("value", &value)); |
| 1645 EXPECT_EQ("polyglottal", value); | 1645 EXPECT_EQ("polyglottal", value); |
| 1646 found++; | 1646 found++; |
| 1647 } else { | 1647 } else { |
| 1648 FAIL(); | 1648 FAIL(); |
| 1649 } | 1649 } |
| 1650 } | 1650 } |
| 1651 EXPECT_EQ(2u, found); | 1651 EXPECT_EQ(2u, found); |
| 1652 } | 1652 } |
| 1653 | 1653 |
| 1654 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, SetNavigationReferrer) { | |
| 1655 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
| |
| 1656 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); | |
| 1657 Attach(); | |
| 1658 SendCommand("Network.enable", nullptr, false); | |
| 1659 SendCommand("Page.enable", nullptr, false); | |
| 1660 | |
| 1661 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); | |
| 1662 GURL test_url = | |
| 1663 embedded_test_server()->GetURL("/devtools/referrer/referrer.html"); | |
| 1664 GURL referrer_url("http://example.com"); | |
| 1665 params->SetString("url", test_url.spec()); | |
| 1666 params->SetString("referrer", referrer_url.spec()); | |
| 1667 SendCommand("Page.navigate", std::move(params), true); | |
| 1668 | |
| 1669 // We should see two resources being requested: firstly the main page (which | |
| 1670 // should use our custom referrer) and secondly the embedded image (whose | |
| 1671 // referrer should be the main page). | |
| 1672 std::string url; | |
| 1673 std::string referrer; | |
| 1674 base::DictionaryValue* request_params; | |
| 1675 base::DictionaryValue* request_headers; | |
| 1676 params = WaitForNotification("Network.requestWillBeSent", true); | |
| 1677 ASSERT_TRUE(params->GetDictionary("request", &request_params)); | |
| 1678 ASSERT_TRUE(request_params->GetDictionary("headers", &request_headers)); | |
| 1679 EXPECT_TRUE(request_params->GetString("url", &url)); | |
| 1680 EXPECT_TRUE(request_headers->GetString("Referer", &referrer)); | |
| 1681 EXPECT_EQ(test_url.spec(), url); | |
| 1682 EXPECT_EQ(referrer_url.spec(), referrer); | |
| 1683 | |
| 1684 params = WaitForNotification("Network.requestWillBeSent", true); | |
| 1685 GURL image_url = | |
| 1686 embedded_test_server()->GetURL("/devtools/referrer/image.png"); | |
| 1687 ASSERT_TRUE(params->GetDictionary("request", &request_params)); | |
| 1688 ASSERT_TRUE(request_params->GetDictionary("headers", &request_headers)); | |
| 1689 EXPECT_TRUE(request_params->GetString("url", &url)); | |
| 1690 EXPECT_TRUE(request_headers->GetString("Referer", &referrer)); | |
| 1691 EXPECT_EQ(image_url.spec(), url); | |
| 1692 EXPECT_EQ(test_url.spec(), referrer); | |
| 1693 } | |
| 1694 | |
| 1654 } // namespace content | 1695 } // namespace content |
| OLD | NEW |