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

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

Issue 2785103004: Added available bit to m_selectorIndex. (Closed)
Patch Set: Prefer unit test. Created 3 years, 8 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 | « third_party/WebKit/Source/core/css/RuleSet.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014, Google Inc. All rights reserved. 2 * Copyright (c) 2014, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 13 matching lines...) Expand all
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
27 * OF THE POSSIBILITY OF SUCH DAMAGE. 27 * OF THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30 #include "core/css/RuleSet.h" 30 #include "core/css/RuleSet.h"
31 31
32 #include "core/css/CSSTestHelper.h" 32 #include "core/css/CSSTestHelper.h"
33 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
34 #include "wtf/text/StringBuilder.h"
34 35
35 namespace blink { 36 namespace blink {
36 37
37 TEST(RuleSetTest, findBestRuleSetAndAdd_CustomPseudoElements) { 38 TEST(RuleSetTest, findBestRuleSetAndAdd_CustomPseudoElements) {
38 CSSTestHelper helper; 39 CSSTestHelper helper;
39 40
40 helper.addCSSRules("summary::-webkit-details-marker { }"); 41 helper.addCSSRules("summary::-webkit-details-marker { }");
41 RuleSet& ruleSet = helper.ruleSet(); 42 RuleSet& ruleSet = helper.ruleSet();
42 AtomicString str("-webkit-details-marker"); 43 AtomicString str("-webkit-details-marker");
43 const TerminatedArray<RuleData>* rules = 44 const TerminatedArray<RuleData>* rules =
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 189
189 TEST(RuleSetTest, findBestRuleSetAndAdd_HostContextAndClass) { 190 TEST(RuleSetTest, findBestRuleSetAndAdd_HostContextAndClass) {
190 CSSTestHelper helper; 191 CSSTestHelper helper;
191 192
192 helper.addCSSRules(".foo:host-context(*) { }"); 193 helper.addCSSRules(".foo:host-context(*) { }");
193 RuleSet& ruleSet = helper.ruleSet(); 194 RuleSet& ruleSet = helper.ruleSet();
194 const HeapVector<RuleData>* rules = ruleSet.shadowHostRules(); 195 const HeapVector<RuleData>* rules = ruleSet.shadowHostRules();
195 ASSERT_EQ(0u, rules->size()); 196 ASSERT_EQ(0u, rules->size());
196 } 197 }
197 198
199 TEST(RuleSetTest, SelectorIndexLimit) {
200 StringBuilder builder;
201
202 for (unsigned i = 0; i < 16383; i++)
203 builder.append("div,");
204
205 builder.append("b,span {}");
206
207 CSSTestHelper helper;
208 helper.addCSSRules(builder.toString().ascii().data());
209 const RuleSet& ruleSet = helper.ruleSet();
210 const HeapTerminatedArray<RuleData>* rules = ruleSet.tagRules("b");
211 ASSERT_EQ(1u, rules->size());
212 EXPECT_EQ("b", rules->at(0).selector().tagQName().localName());
213 EXPECT_FALSE(ruleSet.tagRules("span"));
214 }
215
198 } // namespace blink 216 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/RuleSet.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698