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 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 struct PreconnectTestCase { | 13 struct PreconnectTestCase { |
14 const char* baseURL; | 14 const char* baseURL; |
15 const char* url; | 15 const char* url; |
16 bool isCORS; | 16 bool isCORS; |
17 bool isHTTPS; | 17 bool isHTTPS; |
18 }; | 18 }; |
19 | 19 |
20 class PreloaderNetworkHintsMock : public NetworkHintsInterface { | 20 class PreloaderNetworkHintsMock : public NetworkHintsInterface { |
21 public: | 21 public: |
22 PreloaderNetworkHintsMock() | 22 PreloaderNetworkHintsMock() |
23 : m_didPreconnect(false) | 23 : m_didPreconnect(false) |
24 { | 24 { |
25 } | 25 } |
26 | 26 |
27 void dnsPrefetchHost(const String& host) const { } | 27 void dnsPrefetchHost(const KURL& host) const { } |
28 void preconnectHost(const KURL& host, const CrossOriginAttributeValue crossO
rigin) const override | 28 void preconnectHost(const KURL& host, const CrossOriginAttributeValue crossO
rigin) const override |
29 { | 29 { |
30 m_didPreconnect = true; | 30 m_didPreconnect = true; |
31 m_isHTTPS = host.protocolIs("https"); | 31 m_isHTTPS = host.protocolIs("https"); |
32 m_isCrossOrigin = (crossOrigin == CrossOriginAttributeAnonymous); | 32 m_isCrossOrigin = (crossOrigin == CrossOriginAttributeAnonymous); |
33 } | 33 } |
34 | 34 |
35 bool didPreconnect() { return m_didPreconnect; } | 35 bool didPreconnect() { return m_didPreconnect; } |
36 bool isHTTPS() { return m_isHTTPS; } | 36 bool isHTTPS() { return m_isHTTPS; } |
37 bool isCrossOrigin() { return m_isCrossOrigin; } | 37 bool isCrossOrigin() { return m_isCrossOrigin; } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 { "http://example.test", "//example.com", true, false }, | 86 { "http://example.test", "//example.com", true, false }, |
87 { "https://example.test", "//example.com", false, true }, | 87 { "https://example.test", "//example.com", false, true }, |
88 { "https://example.test", "//example.com", true, true }, | 88 { "https://example.test", "//example.com", true, true }, |
89 }; | 89 }; |
90 | 90 |
91 for (const auto& testCase : testCases) | 91 for (const auto& testCase : testCases) |
92 test(testCase); | 92 test(testCase); |
93 } | 93 } |
94 | 94 |
95 } // namespace blink | 95 } // namespace blink |
OLD | NEW |