| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/loader/PingLoader.h" | 5 #include "core/loader/PingLoader.h" |
| 6 | 6 |
| 7 #include "core/fetch/SubstituteData.h" | 7 #include "core/fetch/SubstituteData.h" |
| 8 #include "core/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
| 9 #include "core/loader/EmptyClients.h" | 9 #include "core/loader/EmptyClients.h" |
| 10 #include "core/loader/FrameLoader.h" | 10 #include "core/loader/FrameLoader.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 blink::testing::runPendingTasks(); | 52 blink::testing::runPendingTasks(); |
| 53 ASSERT_EQ(url.getString(), m_pageHolder->document().url().getString()); | 53 ASSERT_EQ(url.getString(), m_pageHolder->document().url().getString()); |
| 54 } | 54 } |
| 55 | 55 |
| 56 const ResourceRequest& pingAndGetRequest(const KURL& pingURL) { | 56 const ResourceRequest& pingAndGetRequest(const KURL& pingURL) { |
| 57 KURL destinationURL(ParsedURLString, "http://navigation.destination"); | 57 KURL destinationURL(ParsedURLString, "http://navigation.destination"); |
| 58 URLTestHelpers::registerMockedURLLoad(pingURL, "bar.html", "text/html"); | 58 URLTestHelpers::registerMockedURLLoad(pingURL, "bar.html", "text/html"); |
| 59 PingLoader::sendLinkAuditPing(&m_pageHolder->frame(), pingURL, | 59 PingLoader::sendLinkAuditPing(&m_pageHolder->frame(), pingURL, |
| 60 destinationURL); | 60 destinationURL); |
| 61 const ResourceRequest& pingRequest = m_client->pingRequest(); | 61 const ResourceRequest& pingRequest = m_client->pingRequest(); |
| 62 if (!pingRequest.isNull()) | 62 if (!pingRequest.isNull()) { |
| 63 EXPECT_EQ(destinationURL.getString(), | 63 EXPECT_EQ(destinationURL.getString(), |
| 64 pingRequest.httpHeaderField("Ping-To")); | 64 pingRequest.httpHeaderField("Ping-To")); |
| 65 } |
| 65 return pingRequest; | 66 return pingRequest; |
| 66 } | 67 } |
| 67 | 68 |
| 68 private: | 69 private: |
| 69 Persistent<PingFrameLoaderClient> m_client; | 70 Persistent<PingFrameLoaderClient> m_client; |
| 70 std::unique_ptr<DummyPageHolder> m_pageHolder; | 71 std::unique_ptr<DummyPageHolder> m_pageHolder; |
| 71 }; | 72 }; |
| 72 | 73 |
| 73 TEST_F(PingLoaderTest, HTTPSToHTTPS) { | 74 TEST_F(PingLoaderTest, HTTPSToHTTPS) { |
| 74 KURL pingURL(ParsedURLString, "https://localhost/bar.html"); | 75 KURL pingURL(ParsedURLString, "https://localhost/bar.html"); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 92 TEST_F(PingLoaderTest, NonHTTPPingTarget) { | 93 TEST_F(PingLoaderTest, NonHTTPPingTarget) { |
| 93 setDocumentURL(KURL(ParsedURLString, "http://127.0.0.1:8000/foo.html")); | 94 setDocumentURL(KURL(ParsedURLString, "http://127.0.0.1:8000/foo.html")); |
| 94 const ResourceRequest& pingRequest = | 95 const ResourceRequest& pingRequest = |
| 95 pingAndGetRequest(KURL(ParsedURLString, "ftp://localhost/bar.html")); | 96 pingAndGetRequest(KURL(ParsedURLString, "ftp://localhost/bar.html")); |
| 96 ASSERT_TRUE(pingRequest.isNull()); | 97 ASSERT_TRUE(pingRequest.isNull()); |
| 97 } | 98 } |
| 98 | 99 |
| 99 } // namespace | 100 } // namespace |
| 100 | 101 |
| 101 } // namespace blink | 102 } // namespace blink |
| OLD | NEW |