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

Side by Side Diff: third_party/WebKit/Source/core/css/CSSStyleSheetResourceTest.cpp

Issue 1782473002: Check if stylesheet resource was cached before marking it as such. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix non-oilpan compilation Created 4 years, 9 months 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 | « no previous file | third_party/WebKit/Source/core/css/StyleSheetContents.cpp » ('j') | 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/fetch/CSSStyleSheetResource.h" 5 #include "core/fetch/CSSStyleSheetResource.h"
6 6
7 #include "core/css/CSSCrossfadeValue.h" 7 #include "core/css/CSSCrossfadeValue.h"
8 #include "core/css/CSSImageValue.h" 8 #include "core/css/CSSImageValue.h"
9 #include "core/css/CSSPrimitiveValue.h" 9 #include "core/css/CSSPrimitiveValue.h"
10 #include "core/css/CSSProperty.h" 10 #include "core/css/CSSProperty.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 for (size_t i = 0; i < imageResource->size() + 1; ++i) 111 for (size_t i = 0; i < imageResource->size() + 1; ++i)
112 memoryCache()->update(imageResource.get(), imageResource->size() , imageResource->size(), true); 112 memoryCache()->update(imageResource.get(), imageResource->size() , imageResource->size(), true);
113 } 113 }
114 ASSERT_TRUE(memoryCache()->isInSameLRUListForTest(cssResource.get(), ima geResource.get())); 114 ASSERT_TRUE(memoryCache()->isInSameLRUListForTest(cssResource.get(), ima geResource.get()));
115 } 115 }
116 Heap::collectAllGarbage(); 116 Heap::collectAllGarbage();
117 // This operation should not lead to crash! 117 // This operation should not lead to crash!
118 memoryCache()->pruneAll(); 118 memoryCache()->pruneAll();
119 } 119 }
120 120
121 TEST_F(CSSStyleSheetResourceTest, DuplicateResourceNotCached)
122 {
123 const char url[] = "https://localhost/style.css";
124 KURL imageURL(KURL(), url);
125 KURL cssURL(KURL(), url);
126
127 // Emulate using <img> to do async stylesheet preloads.
128
129 RefPtrWillBeRawPtr<Resource> imageResource = ImageResource::create(ResourceR equest(imageURL), nullptr);
130 ASSERT_TRUE(imageResource);
131 memoryCache()->add(imageResource.get());
132 ASSERT_TRUE(memoryCache()->contains(imageResource.get()));
133
134 RefPtrWillBeRawPtr<CSSStyleSheetResource> cssResource = CSSStyleSheetResourc e::createForTest(ResourceRequest(cssURL), "utf-8");
135 cssResource->responseReceived(ResourceResponse(cssURL, "style/css", 0, nullA tom, String()), nullptr);
136 cssResource->finish();
137
138 RefPtrWillBeRawPtr<StyleSheetContents> contents = StyleSheetContents::create (CSSParserContext(HTMLStandardMode, nullptr));
139 RefPtrWillBeRawPtr<CSSStyleSheet> sheet = CSSStyleSheet::create(contents, do cument());
140 EXPECT_TRUE(sheet);
141
142 contents->checkLoaded();
143 cssResource->saveParsedStyleSheet(contents);
144
145 // Verify that the cache will have a mapping for |imageResource| at |url|.
146 // The underlying |contents| for the stylesheet resource must have a
147 // matching cache status.
148 ASSERT_TRUE(memoryCache()->contains(imageResource.get()));
149 ASSERT_FALSE(memoryCache()->contains(cssResource.get()));
150 ASSERT_FALSE(contents->isInMemoryCache());
151 }
152
121 } // namespace 153 } // namespace
122 } // namespace blink 154 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/StyleSheetContents.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698