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

Unified Diff: third_party/WebKit/Source/core/css/CSSStyleSheetResourceTest.cpp

Issue 2411243004: [WeakMemoryCache] Remove LRU lists, prune order control and live/dead distinction (Closed)
Patch Set: Reflect yhirano's comment Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/fetch/CSSStyleSheetResource.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/CSSStyleSheetResourceTest.cpp
diff --git a/third_party/WebKit/Source/core/css/CSSStyleSheetResourceTest.cpp b/third_party/WebKit/Source/core/css/CSSStyleSheetResourceTest.cpp
index f7e301823ac473fdc39d3d2a39e63e63d21743a2..2a7d38c6b5c34fd1ab969ca695461caf1152af3b 100644
--- a/third_party/WebKit/Source/core/css/CSSStyleSheetResourceTest.cpp
+++ b/third_party/WebKit/Source/core/css/CSSStyleSheetResourceTest.cpp
@@ -60,73 +60,6 @@ class CSSStyleSheetResourceTest : public ::testing::Test {
std::unique_ptr<DummyPageHolder> m_page;
};
-TEST_F(CSSStyleSheetResourceTest, PruneCanCauseEviction) {
- {
- // We need this scope to remove all references.
- KURL imageURL(KURL(), "https://localhost/image");
- KURL cssURL(KURL(), "https://localhost/style.css");
-
- // We need to disable loading because we manually give a response to
- // the image resource.
- document().fetcher()->setAutoLoadImages(false);
-
- CSSStyleSheetResource* cssResource =
- CSSStyleSheetResource::createForTest(ResourceRequest(cssURL), "utf-8");
- memoryCache()->add(cssResource);
- cssResource->responseReceived(
- ResourceResponse(cssURL, "style/css", 0, nullAtom, String()), nullptr);
- cssResource->finish();
-
- StyleSheetContents* contents =
- StyleSheetContents::create(CSSParserContext(HTMLStandardMode, nullptr));
- CSSStyleSheet* sheet = CSSStyleSheet::create(contents, document());
- EXPECT_TRUE(sheet);
- CSSCrossfadeValue* crossfade = CSSCrossfadeValue::create(
- CSSImageValue::create(String("image"), imageURL),
- CSSImageValue::create(String("image"), imageURL),
- CSSPrimitiveValue::create(1.0, CSSPrimitiveValue::UnitType::Number));
- Vector<std::unique_ptr<CSSParserSelector>> selectors;
- selectors.append(makeUnique<CSSParserSelector>());
- selectors[0]->setMatch(CSSSelector::Id);
- selectors[0]->setValue("foo");
- CSSProperty property(CSSPropertyBackground, *crossfade);
- contents->parserAppendRule(StyleRule::create(
- CSSSelectorList::adoptSelectorVector(selectors),
- ImmutableStylePropertySet::create(&property, 1, HTMLStandardMode)));
-
- crossfade->loadSubimages(document());
- Resource* imageResource = memoryCache()->resourceForURL(
- imageURL, MemoryCache::defaultCacheIdentifier());
- ASSERT_TRUE(imageResource);
- ResourceResponse imageResponse;
- imageResponse.setURL(imageURL);
- imageResponse.setHTTPHeaderField("cache-control", "no-store");
- imageResource->responseReceived(imageResponse, nullptr);
-
- contents->checkLoaded();
- cssResource->saveParsedStyleSheet(contents);
-
- memoryCache()->update(cssResource, cssResource->size(), cssResource->size(),
- false);
- memoryCache()->update(imageResource, imageResource->size(),
- imageResource->size(), false);
- if (!memoryCache()->isInSameLRUListForTest(cssResource, imageResource)) {
- // We assume that the LRU list is determined by |size / accessCount|.
- for (size_t i = 0; i < cssResource->size() + 1; ++i)
- memoryCache()->update(cssResource, cssResource->size(),
- cssResource->size(), true);
- for (size_t i = 0; i < imageResource->size() + 1; ++i)
- memoryCache()->update(imageResource, imageResource->size(),
- imageResource->size(), true);
- }
- ASSERT_TRUE(
- memoryCache()->isInSameLRUListForTest(cssResource, imageResource));
- }
- ThreadState::current()->collectAllGarbage();
- // This operation should not lead to crash!
- memoryCache()->pruneAll();
-}
-
TEST_F(CSSStyleSheetResourceTest, DuplicateResourceNotCached) {
const char url[] = "https://localhost/style.css";
KURL imageURL(KURL(), url);
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/fetch/CSSStyleSheetResource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698