OLD | NEW |
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/loader/resource/CSSStyleSheetResource.h" | 5 #include "core/loader/resource/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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 ASSERT_TRUE(imageResource); | 72 ASSERT_TRUE(imageResource); |
73 memoryCache()->add(imageResource); | 73 memoryCache()->add(imageResource); |
74 ASSERT_TRUE(memoryCache()->contains(imageResource)); | 74 ASSERT_TRUE(memoryCache()->contains(imageResource)); |
75 | 75 |
76 CSSStyleSheetResource* cssResource = | 76 CSSStyleSheetResource* cssResource = |
77 CSSStyleSheetResource::createForTest(ResourceRequest(cssURL), "utf-8"); | 77 CSSStyleSheetResource::createForTest(ResourceRequest(cssURL), "utf-8"); |
78 cssResource->responseReceived( | 78 cssResource->responseReceived( |
79 ResourceResponse(cssURL, "style/css", 0, nullAtom, String()), nullptr); | 79 ResourceResponse(cssURL, "style/css", 0, nullAtom, String()), nullptr); |
80 cssResource->finish(); | 80 cssResource->finish(); |
81 | 81 |
82 CSSParserContext parserContext(HTMLStandardMode, nullptr); | 82 CSSParserContext* parserContext = new CSSParserContext(HTMLStandardMode); |
83 StyleSheetContents* contents = StyleSheetContents::create(parserContext); | 83 StyleSheetContents* contents = StyleSheetContents::create(parserContext); |
84 CSSStyleSheet* sheet = CSSStyleSheet::create(contents, document()); | 84 CSSStyleSheet* sheet = CSSStyleSheet::create(contents, document()); |
85 EXPECT_TRUE(sheet); | 85 EXPECT_TRUE(sheet); |
86 | 86 |
87 contents->checkLoaded(); | 87 contents->checkLoaded(); |
88 cssResource->saveParsedStyleSheet(contents); | 88 cssResource->saveParsedStyleSheet(contents); |
89 | 89 |
90 // Verify that the cache will have a mapping for |imageResource| at |url|. | 90 // Verify that the cache will have a mapping for |imageResource| at |url|. |
91 // The underlying |contents| for the stylesheet resource must have a | 91 // The underlying |contents| for the stylesheet resource must have a |
92 // matching reference status. | 92 // matching reference status. |
93 EXPECT_TRUE(memoryCache()->contains(imageResource)); | 93 EXPECT_TRUE(memoryCache()->contains(imageResource)); |
94 EXPECT_FALSE(memoryCache()->contains(cssResource)); | 94 EXPECT_FALSE(memoryCache()->contains(cssResource)); |
95 EXPECT_FALSE(contents->isReferencedFromResource()); | 95 EXPECT_FALSE(contents->isReferencedFromResource()); |
96 EXPECT_FALSE(cssResource->restoreParsedStyleSheet(parserContext)); | 96 EXPECT_FALSE(cssResource->restoreParsedStyleSheet(parserContext)); |
97 } | 97 } |
98 | 98 |
99 } // namespace | 99 } // namespace |
100 } // namespace blink | 100 } // namespace blink |
OLD | NEW |