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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/StyleSheetContents.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 5080f8e51a7f67c0c3de3c4a078f5516dfc8328f..c9b3a2649ae93917c5c34161809e8b0b67b1bf1d 100644
--- a/third_party/WebKit/Source/core/css/CSSStyleSheetResourceTest.cpp
+++ b/third_party/WebKit/Source/core/css/CSSStyleSheetResourceTest.cpp
@@ -118,5 +118,37 @@ TEST_F(CSSStyleSheetResourceTest, PruneCanCauseEviction)
memoryCache()->pruneAll();
}
+TEST_F(CSSStyleSheetResourceTest, DuplicateResourceNotCached)
+{
+ const char url[] = "https://localhost/style.css";
+ KURL imageURL(KURL(), url);
+ KURL cssURL(KURL(), url);
+
+ // Emulate using <img> to do async stylesheet preloads.
+
+ RefPtrWillBeRawPtr<Resource> imageResource = ImageResource::create(ResourceRequest(imageURL), nullptr);
+ ASSERT_TRUE(imageResource);
+ memoryCache()->add(imageResource.get());
+ ASSERT_TRUE(memoryCache()->contains(imageResource.get()));
+
+ RefPtrWillBeRawPtr<CSSStyleSheetResource> cssResource = CSSStyleSheetResource::createForTest(ResourceRequest(cssURL), "utf-8");
+ cssResource->responseReceived(ResourceResponse(cssURL, "style/css", 0, nullAtom, String()), nullptr);
+ cssResource->finish();
+
+ RefPtrWillBeRawPtr<StyleSheetContents> contents = StyleSheetContents::create(CSSParserContext(HTMLStandardMode, nullptr));
+ RefPtrWillBeRawPtr<CSSStyleSheet> sheet = CSSStyleSheet::create(contents, document());
+ EXPECT_TRUE(sheet);
+
+ contents->checkLoaded();
+ cssResource->saveParsedStyleSheet(contents);
+
+ // Verify that the cache will have a mapping for |imageResource| at |url|.
+ // The underlying |contents| for the stylesheet resource must have a
+ // matching cache status.
+ ASSERT_TRUE(memoryCache()->contains(imageResource.get()));
+ ASSERT_FALSE(memoryCache()->contains(cssResource.get()));
+ ASSERT_FALSE(contents->isInMemoryCache());
+}
+
} // namespace
} // namespace blink
« 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