diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/core/css/properties/longhands/custom_property_test.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/core/css/properties/longhands/custom_property_test.cc | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/chromium/third_party/blink/renderer/core/css/properties/longhands/custom_property_test.cc b/chromium/third_party/blink/renderer/core/css/properties/longhands/custom_property_test.cc index 9819322441e..1b206d574c5 100644 --- a/chromium/third_party/blink/renderer/core/css/properties/longhands/custom_property_test.cc +++ b/chromium/third_party/blink/renderer/core/css/properties/longhands/custom_property_test.cc @@ -29,9 +29,13 @@ class CustomPropertyTest : public PageTestBase { UpdateAllLifecyclePhasesForTest(); } - const CSSValue* GetComputedValue(const CustomProperty& property) { + const ComputedStyle& GetComputedStyle() { Element* node = GetDocument().getElementById("target"); - return property.CSSValueFromComputedStyle(node->ComputedStyleRef(), + return node->ComputedStyleRef(); + } + + const CSSValue* GetComputedValue(const CustomProperty& property) { + return property.CSSValueFromComputedStyle(GetComputedStyle(), nullptr /* layout_object */, false /* allow_visited_style */); } @@ -82,6 +86,38 @@ TEST_F(CustomPropertyTest, GetPropertyNameAtomicString) { EXPECT_EQ(AtomicString("--x"), property.GetPropertyNameAtomicString()); } +TEST_F(CustomPropertyTest, ComputedValuesEqual) { + RegisterProperty(GetDocument(), "--y", "<length>", "100px", false); + + CustomProperty x("--x", GetDocument()); + CustomProperty y("--y", GetDocument()); + + SetElementWithStyle("--x:foo;--y:10px"); + auto style1 = ComputedStyle::Clone(GetComputedStyle()); + + SetElementWithStyle("--x:foo;--y:10px"); + auto style2 = ComputedStyle::Clone(GetComputedStyle()); + + SetElementWithStyle("--x:bar;--y:30px"); + auto style3 = ComputedStyle::Clone(GetComputedStyle()); + + ASSERT_TRUE(x.IsComputedValueComparable()); + EXPECT_TRUE(x.ComputedValuesEqual(*style1, *style1)); + EXPECT_TRUE(x.ComputedValuesEqual(*style2, *style2)); + EXPECT_TRUE(x.ComputedValuesEqual(*style1, *style2)); + EXPECT_TRUE(x.ComputedValuesEqual(*style2, *style1)); + EXPECT_FALSE(x.ComputedValuesEqual(*style1, *style3)); + EXPECT_FALSE(x.ComputedValuesEqual(*style2, *style3)); + + ASSERT_TRUE(y.IsComputedValueComparable()); + EXPECT_TRUE(y.ComputedValuesEqual(*style1, *style1)); + EXPECT_TRUE(y.ComputedValuesEqual(*style2, *style2)); + EXPECT_TRUE(y.ComputedValuesEqual(*style1, *style2)); + EXPECT_TRUE(y.ComputedValuesEqual(*style2, *style1)); + EXPECT_FALSE(y.ComputedValuesEqual(*style1, *style3)); + EXPECT_FALSE(y.ComputedValuesEqual(*style2, *style3)); +} + TEST_F(CustomPropertyTest, ComputedCSSValueUnregistered) { CustomProperty property("--x", GetDocument()); SetElementWithStyle("--x:foo"); |