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> |
(...skipping 28 matching lines...) Expand all Loading... |
39 mutable bool m_didPreconnect; | 39 mutable bool m_didPreconnect; |
40 mutable bool m_isHTTPS; | 40 mutable bool m_isHTTPS; |
41 mutable bool m_isCrossOrigin; | 41 mutable bool m_isCrossOrigin; |
42 }; | 42 }; |
43 | 43 |
44 class HTMLResourcePreloaderTest : public testing::Test { | 44 class HTMLResourcePreloaderTest : public testing::Test { |
45 protected: | 45 protected: |
46 HTMLResourcePreloaderTest() : m_dummyPageHolder(DummyPageHolder::create()) {} | 46 HTMLResourcePreloaderTest() : m_dummyPageHolder(DummyPageHolder::create()) {} |
47 | 47 |
48 void test(PreconnectTestCase testCase) { | 48 void test(PreconnectTestCase testCase) { |
49 // TODO(yoav): Need a mock loader here to verify things are happenning beyon
d preconnect. | 49 // TODO(yoav): Need a mock loader here to verify things are happenning |
| 50 // beyond preconnect. |
50 PreloaderNetworkHintsMock networkHints; | 51 PreloaderNetworkHintsMock networkHints; |
51 std::unique_ptr<PreloadRequest> preloadRequest = PreloadRequest::create( | 52 std::unique_ptr<PreloadRequest> preloadRequest = PreloadRequest::create( |
52 String(), TextPosition(), testCase.url, | 53 String(), TextPosition(), testCase.url, |
53 KURL(ParsedURLStringTag(), testCase.baseURL), Resource::Image, | 54 KURL(ParsedURLStringTag(), testCase.baseURL), Resource::Image, |
54 ReferrerPolicy(), FetchRequest::ResourceWidth(), | 55 ReferrerPolicy(), FetchRequest::ResourceWidth(), |
55 ClientHintsPreferences(), PreloadRequest::RequestTypePreconnect); | 56 ClientHintsPreferences(), PreloadRequest::RequestTypePreconnect); |
56 if (testCase.isCORS) | 57 if (testCase.isCORS) |
57 preloadRequest->setCrossOrigin(CrossOriginAttributeAnonymous); | 58 preloadRequest->setCrossOrigin(CrossOriginAttributeAnonymous); |
58 HTMLResourcePreloader* preloader = | 59 HTMLResourcePreloader* preloader = |
59 HTMLResourcePreloader::create(m_dummyPageHolder->document()); | 60 HTMLResourcePreloader::create(m_dummyPageHolder->document()); |
(...skipping 17 matching lines...) Expand all Loading... |
77 {"http://example.test", "//example.com", true, false}, | 78 {"http://example.test", "//example.com", true, false}, |
78 {"https://example.test", "//example.com", false, true}, | 79 {"https://example.test", "//example.com", false, true}, |
79 {"https://example.test", "//example.com", true, true}, | 80 {"https://example.test", "//example.com", true, true}, |
80 }; | 81 }; |
81 | 82 |
82 for (const auto& testCase : testCases) | 83 for (const auto& testCase : testCases) |
83 test(testCase); | 84 test(testCase); |
84 } | 85 } |
85 | 86 |
86 } // namespace blink | 87 } // namespace blink |
OLD | NEW |