Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(616)

Side by Side Diff: third_party/WebKit/Source/core/html/parser/CSSPreloadScannerTest.cpp

Issue 2544583003: Ensure CSS scanner does not mark preloads as referenced (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/html/parser/CSSPreloadScanner.h" 5 #include "core/html/parser/CSSPreloadScanner.h"
6 6
7 #include "core/fetch/FetchContext.h" 7 #include "core/fetch/FetchContext.h"
8 #include "core/fetch/Resource.h" 8 #include "core/fetch/Resource.h"
9 #include "core/fetch/ResourceFetcher.h" 9 #include "core/fetch/ResourceFetcher.h"
10 #include "core/frame/Settings.h" 10 #include "core/frame/Settings.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 CSSStyleSheetResource* resource = 51 CSSStyleSheetResource* resource =
52 CSSStyleSheetResource::createForTest(ResourceRequest(url), "utf-8"); 52 CSSStyleSheetResource::createForTest(ResourceRequest(url), "utf-8");
53 resource->setStatus(Resource::Pending); 53 resource->setStatus(Resource::Pending);
54 54
55 PreloadSuppressingCSSPreloaderResourceClient* resourceClient = 55 PreloadSuppressingCSSPreloaderResourceClient* resourceClient =
56 new PreloadSuppressingCSSPreloaderResourceClient(resource, preloader); 56 new PreloadSuppressingCSSPreloaderResourceClient(resource, preloader);
57 57
58 const char* data = "@import url('http://127.0.0.1/preload.css');"; 58 const char* data = "@import url('http://127.0.0.1/preload.css');";
59 resource->appendData(data, strlen(data)); 59 resource->appendData(data, strlen(data));
60 60
61 EXPECT_EQ(Resource::PreloadNotReferenced, resource->getPreloadResult());
61 EXPECT_EQ(1u, resourceClient->m_preloads.size()); 62 EXPECT_EQ(1u, resourceClient->m_preloads.size());
62 EXPECT_EQ("http://127.0.0.1/preload.css", 63 EXPECT_EQ("http://127.0.0.1/preload.css",
63 resourceClient->m_preloads.front()->resourceURL()); 64 resourceClient->m_preloads.front()->resourceURL());
64 } 65 }
65 66
66 // Regression test for crbug.com/608310 where the client is destroyed but was 67 // Regression test for crbug.com/608310 where the client is destroyed but was
67 // not removed from the resource's client list. 68 // not removed from the resource's client list.
68 TEST_F(CSSPreloadScannerTest, DestroyClientBeforeDataSent) { 69 TEST_F(CSSPreloadScannerTest, DestroyClientBeforeDataSent) {
69 std::unique_ptr<DummyPageHolder> dummyPageHolder = 70 std::unique_ptr<DummyPageHolder> dummyPageHolder =
70 DummyPageHolder::create(IntSize(500, 500)); 71 DummyPageHolder::create(IntSize(500, 500));
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 137
137 const char* data = "@import url('http://127.0.0.1/preload.css');"; 138 const char* data = "@import url('http://127.0.0.1/preload.css');";
138 resource->appendData(data, strlen(data)); 139 resource->appendData(data, strlen(data));
139 140
140 EXPECT_EQ(1u, resourceClient->m_preloads.size()); 141 EXPECT_EQ(1u, resourceClient->m_preloads.size());
141 EXPECT_EQ("http://127.0.0.1/preload.css", 142 EXPECT_EQ("http://127.0.0.1/preload.css",
142 resourceClient->m_preloads.front()->resourceURL()); 143 resourceClient->m_preloads.front()->resourceURL());
143 } 144 }
144 145
145 } // namespace blink 146 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698