| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/html/parser/HTMLResourcePreloader.h" | 5 #include "core/html/parser/HTMLResourcePreloader.h" |
| 6 | 6 |
| 7 #include "core/html/parser/PreloadRequest.h" | 7 #include "core/html/parser/PreloadRequest.h" |
| 8 #include "core/testing/DummyPageHolder.h" | 8 #include "core/testing/DummyPageHolder.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 struct PreconnectTestCase { | 14 struct PreconnectTestCase { |
| 15 const char* baseURL; | 15 const char* baseURL; |
| 16 const char* url; | 16 const char* url; |
| 17 bool isCORS; | 17 bool isCORS; |
| 18 bool isHTTPS; | 18 bool isHTTPS; |
| 19 }; | 19 }; |
| 20 | 20 |
| 21 class PreloaderNetworkHintsMock : public NetworkHintsInterface { | 21 class PreloaderNetworkHintsMock : public NetworkHintsInterface { |
| 22 public: | 22 public: |
| 23 PreloaderNetworkHintsMock() | 23 PreloaderNetworkHintsMock() |
| 24 : m_didPreconnect(false) | 24 : m_didPreconnect(false) |
| 25 { | 25 { |
| 26 } | 26 } |
| 27 | 27 |
| 28 void dnsPrefetchHost(const String& host) const { } | 28 void dnsPrefetchHost(const KURL& host) const |
| 29 { |
| 30 } |
| 29 void preconnectHost(const KURL& host, const CrossOriginAttributeValue crossO
rigin) const override | 31 void preconnectHost(const KURL& host, const CrossOriginAttributeValue crossO
rigin) const override |
| 30 { | 32 { |
| 31 m_didPreconnect = true; | 33 m_didPreconnect = true; |
| 32 m_isHTTPS = host.protocolIs("https"); | 34 m_isHTTPS = host.protocolIs("https"); |
| 33 m_isCrossOrigin = (crossOrigin == CrossOriginAttributeAnonymous); | 35 m_isCrossOrigin = (crossOrigin == CrossOriginAttributeAnonymous); |
| 34 } | 36 } |
| 35 | 37 |
| 36 bool didPreconnect() { return m_didPreconnect; } | 38 bool didPreconnect() { return m_didPreconnect; } |
| 37 bool isHTTPS() { return m_isHTTPS; } | 39 bool isHTTPS() { return m_isHTTPS; } |
| 38 bool isCrossOrigin() { return m_isCrossOrigin; } | 40 bool isCrossOrigin() { return m_isCrossOrigin; } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 { "http://example.test", "//example.com", true, false }, | 89 { "http://example.test", "//example.com", true, false }, |
| 88 { "https://example.test", "//example.com", false, true }, | 90 { "https://example.test", "//example.com", false, true }, |
| 89 { "https://example.test", "//example.com", true, true }, | 91 { "https://example.test", "//example.com", true, true }, |
| 90 }; | 92 }; |
| 91 | 93 |
| 92 for (const auto& testCase : testCases) | 94 for (const auto& testCase : testCases) |
| 93 test(testCase); | 95 test(testCase); |
| 94 } | 96 } |
| 95 | 97 |
| 96 } // namespace blink | 98 } // namespace blink |
| OLD | NEW |