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

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

Issue 1941733002: Don't cache parsed stylesheet if it wasn't added to the memory cache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/fetch/CSSStyleSheetResource.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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 127
128 Resource* imageResource = ImageResource::create(ResourceRequest(imageURL)); 128 Resource* imageResource = ImageResource::create(ResourceRequest(imageURL));
129 ASSERT_TRUE(imageResource); 129 ASSERT_TRUE(imageResource);
130 memoryCache()->add(imageResource); 130 memoryCache()->add(imageResource);
131 ASSERT_TRUE(memoryCache()->contains(imageResource)); 131 ASSERT_TRUE(memoryCache()->contains(imageResource));
132 132
133 CSSStyleSheetResource* cssResource = CSSStyleSheetResource::createForTest(Re sourceRequest(cssURL), "utf-8"); 133 CSSStyleSheetResource* cssResource = CSSStyleSheetResource::createForTest(Re sourceRequest(cssURL), "utf-8");
134 cssResource->responseReceived(ResourceResponse(cssURL, "style/css", 0, nullA tom, String()), nullptr); 134 cssResource->responseReceived(ResourceResponse(cssURL, "style/css", 0, nullA tom, String()), nullptr);
135 cssResource->finish(); 135 cssResource->finish();
136 136
137 StyleSheetContents* contents = StyleSheetContents::create(CSSParserContext(H TMLStandardMode, nullptr)); 137 CSSParserContext parserContext(HTMLStandardMode, nullptr);
138 StyleSheetContents* contents = StyleSheetContents::create(parserContext);
138 CSSStyleSheet* sheet = CSSStyleSheet::create(contents, document()); 139 CSSStyleSheet* sheet = CSSStyleSheet::create(contents, document());
139 EXPECT_TRUE(sheet); 140 EXPECT_TRUE(sheet);
140 141
141 contents->checkLoaded(); 142 contents->checkLoaded();
142 cssResource->saveParsedStyleSheet(contents); 143 cssResource->saveParsedStyleSheet(contents);
143 144
144 // Verify that the cache will have a mapping for |imageResource| at |url|. 145 // Verify that the cache will have a mapping for |imageResource| at |url|.
145 // The underlying |contents| for the stylesheet resource must have a 146 // The underlying |contents| for the stylesheet resource must have a
146 // matching cache status. 147 // matching cache status.
147 ASSERT_TRUE(memoryCache()->contains(imageResource)); 148 EXPECT_TRUE(memoryCache()->contains(imageResource));
148 ASSERT_FALSE(memoryCache()->contains(cssResource)); 149 EXPECT_FALSE(memoryCache()->contains(cssResource));
149 ASSERT_FALSE(contents->isInMemoryCache()); 150 EXPECT_FALSE(contents->isInMemoryCache());
151 EXPECT_FALSE(cssResource->restoreParsedStyleSheet(parserContext));
150 } 152 }
151 153
152 } // namespace 154 } // namespace
153 } // namespace blink 155 } // namespace blink
OLDNEW
« 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