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

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

Issue 2720933003: Removed FrameHost::useCounter() (Closed)
Patch Set: Created 3 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/parser/CSSParserContext.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/css/CSSStyleSheet.h" 5 #include "core/css/CSSStyleSheet.h"
6 #include "core/css/StyleRule.h" 6 #include "core/css/StyleRule.h"
7 #include "core/css/StyleSheetContents.h" 7 #include "core/css/StyleSheetContents.h"
8 #include "core/css/parser/CSSLazyParsingState.h" 8 #include "core/css/parser/CSSLazyParsingState.h"
9 #include "core/css/parser/CSSParser.h" 9 #include "core/css/parser/CSSParser.h"
10 #include "core/css/parser/CSSParserContext.h" 10 #include "core/css/parser/CSSParserContext.h"
11 #include "core/frame/FrameHost.h" 11 #include "core/page/Page.h"
12 #include "core/testing/DummyPageHolder.h" 12 #include "core/testing/DummyPageHolder.h"
13 #include "platform/heap/Heap.h" 13 #include "platform/heap/Heap.h"
14 #include "platform/testing/HistogramTester.h" 14 #include "platform/testing/HistogramTester.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "wtf/text/WTFString.h" 16 #include "wtf/text/WTFString.h"
17 17
18 namespace blink { 18 namespace blink {
19 19
20 class CSSLazyParsingTest : public testing::Test { 20 class CSSLazyParsingTest : public testing::Test {
21 public: 21 public:
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 true /* lazy parse */); 132 true /* lazy parse */);
133 133
134 // Parse the first property set with the first document as owner. 134 // Parse the first property set with the first document as owner.
135 StyleRule* rule = ruleAt(m_cachedContents, 0); 135 StyleRule* rule = ruleAt(m_cachedContents, 0);
136 EXPECT_FALSE(hasParsedProperties(rule)); 136 EXPECT_FALSE(hasParsedProperties(rule));
137 rule->properties(); 137 rule->properties();
138 EXPECT_TRUE(hasParsedProperties(rule)); 138 EXPECT_TRUE(hasParsedProperties(rule));
139 139
140 EXPECT_EQ(&dummyHolder->document(), 140 EXPECT_EQ(&dummyHolder->document(),
141 m_cachedContents->singleOwnerDocument()); 141 m_cachedContents->singleOwnerDocument());
142 UseCounter& useCounter1 = dummyHolder->document().frameHost()->useCounter(); 142 UseCounter& useCounter1 = dummyHolder->document().page()->useCounter();
143 EXPECT_TRUE(useCounter1.isCounted(CSSPropertyBackgroundColor)); 143 EXPECT_TRUE(useCounter1.isCounted(CSSPropertyBackgroundColor));
144 EXPECT_FALSE(useCounter1.isCounted(CSSPropertyColor)); 144 EXPECT_FALSE(useCounter1.isCounted(CSSPropertyColor));
145 145
146 // Change owner document. 146 // Change owner document.
147 m_cachedContents->unregisterClient(sheet); 147 m_cachedContents->unregisterClient(sheet);
148 dummyHolder.reset(); 148 dummyHolder.reset();
149 } 149 }
150 // Ensure no stack references to oilpan objects. 150 // Ensure no stack references to oilpan objects.
151 ThreadState::current()->collectAllGarbage(); 151 ThreadState::current()->collectAllGarbage();
152 152
153 std::unique_ptr<DummyPageHolder> dummyHolder2 = 153 std::unique_ptr<DummyPageHolder> dummyHolder2 =
154 DummyPageHolder::create(IntSize(500, 500)); 154 DummyPageHolder::create(IntSize(500, 500));
155 CSSStyleSheet* sheet2 = 155 CSSStyleSheet* sheet2 =
156 CSSStyleSheet::create(m_cachedContents, dummyHolder2->document()); 156 CSSStyleSheet::create(m_cachedContents, dummyHolder2->document());
157 157
158 EXPECT_EQ(&dummyHolder2->document(), m_cachedContents->singleOwnerDocument()); 158 EXPECT_EQ(&dummyHolder2->document(), m_cachedContents->singleOwnerDocument());
159 159
160 // Parse the second property set with the second document as owner. 160 // Parse the second property set with the second document as owner.
161 StyleRule* rule2 = ruleAt(m_cachedContents, 1); 161 StyleRule* rule2 = ruleAt(m_cachedContents, 1);
162 EXPECT_FALSE(hasParsedProperties(rule2)); 162 EXPECT_FALSE(hasParsedProperties(rule2));
163 rule2->properties(); 163 rule2->properties();
164 EXPECT_TRUE(hasParsedProperties(rule2)); 164 EXPECT_TRUE(hasParsedProperties(rule2));
165 165
166 UseCounter& useCounter2 = dummyHolder2->document().frameHost()->useCounter(); 166 UseCounter& useCounter2 = dummyHolder2->document().page()->useCounter();
167 EXPECT_TRUE(sheet2); 167 EXPECT_TRUE(sheet2);
168 EXPECT_TRUE(useCounter2.isCounted(CSSPropertyColor)); 168 EXPECT_TRUE(useCounter2.isCounted(CSSPropertyColor));
169 EXPECT_FALSE(useCounter2.isCounted(CSSPropertyBackgroundColor)); 169 EXPECT_FALSE(useCounter2.isCounted(CSSPropertyBackgroundColor));
170 } 170 }
171 171
172 TEST_F(CSSLazyParsingTest, SimpleRuleUsagePercent) { 172 TEST_F(CSSLazyParsingTest, SimpleRuleUsagePercent) {
173 CSSParserContext* context = CSSParserContext::create(HTMLStandardMode); 173 CSSParserContext* context = CSSParserContext::create(HTMLStandardMode);
174 StyleSheetContents* styleSheet = StyleSheetContents::create(context); 174 StyleSheetContents* styleSheet = StyleSheetContents::create(context);
175 175
176 std::string usageMetric = "Style.LazyUsage.Percent"; 176 std::string usageMetric = "Style.LazyUsage.Percent";
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 m_histogramTester.expectBucketCount(usageMetric, 227 m_histogramTester.expectBucketCount(usageMetric,
228 CSSLazyParsingState::UsageGt90, 1); 228 CSSLazyParsingState::UsageGt90, 1);
229 m_histogramTester.expectBucketCount(usageMetric, 229 m_histogramTester.expectBucketCount(usageMetric,
230 CSSLazyParsingState::UsageAll, 1); 230 CSSLazyParsingState::UsageAll, 1);
231 231
232 m_histogramTester.expectTotalCount(totalRulesFullUsageMetric, 1); 232 m_histogramTester.expectTotalCount(totalRulesFullUsageMetric, 1);
233 m_histogramTester.expectUniqueSample(totalRulesFullUsageMetric, 5, 1); 233 m_histogramTester.expectUniqueSample(totalRulesFullUsageMetric, 5, 1);
234 } 234 }
235 235
236 } // namespace blink 236 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/parser/CSSParserContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698