summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/css/css_property_value_set_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/core/css/css_property_value_set_test.cc')
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_property_value_set_test.cc67
1 files changed, 67 insertions, 0 deletions
diff --git a/chromium/third_party/blink/renderer/core/css/css_property_value_set_test.cc b/chromium/third_party/blink/renderer/core/css/css_property_value_set_test.cc
new file mode 100644
index 00000000000..5c8e384b1f7
--- /dev/null
+++ b/chromium/third_party/blink/renderer/core/css/css_property_value_set_test.cc
@@ -0,0 +1,67 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "third_party/blink/renderer/core/css/css_property_value_set.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/blink/renderer/core/css/parser/css_parser.h"
+#include "third_party/blink/renderer/core/css/parser/css_parser_context.h"
+#include "third_party/blink/renderer/core/css/style_rule.h"
+#include "third_party/blink/renderer/core/css/style_sheet_contents.h"
+#include "third_party/blink/renderer/core/testing/page_test_base.h"
+
+namespace blink {
+
+class CSSPropertyValueSetTest : public PageTestBase {
+ public:
+ StyleRule* RuleAt(StyleSheetContents* sheet, wtf_size_t index) {
+ return ToStyleRule(sheet->ChildRules()[index]);
+ }
+};
+
+TEST_F(CSSPropertyValueSetTest, MergeAndOverrideOnConflictCustomProperty) {
+ CSSParserContext* context = CSSParserContext::Create(GetDocument());
+ StyleSheetContents* style_sheet = StyleSheetContents::Create(context);
+
+ String sheet_text = R"CSS(
+ #first {
+ color: red;
+ --x:foo;
+ --y:foo;
+ }
+ #second {
+ color: green;
+ --x:bar;
+ --y:bar;
+ }
+ )CSS";
+
+ CSSParser::ParseSheet(context, style_sheet, sheet_text,
+ CSSDeferPropertyParsing::kNo);
+ StyleRule* rule0 = RuleAt(style_sheet, 0);
+ StyleRule* rule1 = RuleAt(style_sheet, 1);
+ MutableCSSPropertyValueSet& set0 = rule0->MutableProperties();
+ MutableCSSPropertyValueSet& set1 = rule1->MutableProperties();
+
+ EXPECT_EQ(3u, set0.PropertyCount());
+ EXPECT_EQ("red", set0.GetPropertyValue(CSSPropertyColor));
+ EXPECT_EQ("foo", set0.GetPropertyValue(AtomicString("--x")));
+ EXPECT_EQ("foo", set0.GetPropertyValue(AtomicString("--y")));
+ EXPECT_EQ(3u, set1.PropertyCount());
+ EXPECT_EQ("green", set1.GetPropertyValue(CSSPropertyColor));
+ EXPECT_EQ("bar", set1.GetPropertyValue(AtomicString("--x")));
+ EXPECT_EQ("bar", set1.GetPropertyValue(AtomicString("--y")));
+
+ set0.MergeAndOverrideOnConflict(&set1);
+
+ EXPECT_EQ(3u, set0.PropertyCount());
+ EXPECT_EQ("green", set0.GetPropertyValue(CSSPropertyColor));
+ EXPECT_EQ("bar", set0.GetPropertyValue(AtomicString("--x")));
+ EXPECT_EQ("bar", set0.GetPropertyValue(AtomicString("--y")));
+ EXPECT_EQ(3u, set1.PropertyCount());
+ EXPECT_EQ("green", set1.GetPropertyValue(CSSPropertyColor));
+ EXPECT_EQ("bar", set1.GetPropertyValue(AtomicString("--x")));
+ EXPECT_EQ("bar", set1.GetPropertyValue(AtomicString("--y")));
+}
+
+} // namespace blink