Commit 8bd433c8 authored by Anders Hartvoll Ruud's avatar Anders Hartvoll Ruud Committed by Commit Bot

Copy 'name_' member during StyleRuleProperty::Copy

This was neglected, end therefore ends up as a null-string in the copy,
causing crashes.

Bug: 1134550
Change-Id: Ib2d5cf649e10d2d510417a43edd3189617092514
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2445470Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813218}
parent 0562928d
...@@ -332,6 +332,7 @@ StyleRuleProperty::StyleRuleProperty(const String& name, ...@@ -332,6 +332,7 @@ StyleRuleProperty::StyleRuleProperty(const String& name,
StyleRuleProperty::StyleRuleProperty(const StyleRuleProperty& property_rule) StyleRuleProperty::StyleRuleProperty(const StyleRuleProperty& property_rule)
: StyleRuleBase(property_rule), : StyleRuleBase(property_rule),
name_(property_rule.name_),
properties_(property_rule.properties_->MutableCopy()) {} properties_(property_rule.properties_->MutableCopy()) {}
StyleRuleProperty::~StyleRuleProperty() = default; StyleRuleProperty::~StyleRuleProperty() = default;
......
...@@ -188,7 +188,7 @@ class StyleRulePage : public StyleRuleBase { ...@@ -188,7 +188,7 @@ class StyleRulePage : public StyleRuleBase {
CSSSelectorList selector_list_; CSSSelectorList selector_list_;
}; };
class StyleRuleProperty : public StyleRuleBase { class CORE_EXPORT StyleRuleProperty : public StyleRuleBase {
public: public:
StyleRuleProperty(const String& name, CSSPropertyValueSet*); StyleRuleProperty(const String& name, CSSPropertyValueSet*);
StyleRuleProperty(const StyleRuleProperty&); StyleRuleProperty(const StyleRuleProperty&);
......
...@@ -77,4 +77,33 @@ TEST_F(StyleRuleTest, StyleRuleScrollTimelineCopy) { ...@@ -77,4 +77,33 @@ TEST_F(StyleRuleTest, StyleRuleScrollTimelineCopy) {
EXPECT_EQ(rule->GetTimeRange(), copy->GetTimeRange()); EXPECT_EQ(rule->GetTimeRange(), copy->GetTimeRange());
} }
TEST_F(StyleRuleTest, StyleRulePropertyCopy) {
ScopedCSSVariables2AtPropertyForTest scoped_feature(true);
auto* base_rule = css_test_helpers::ParseRule(GetDocument(), R"CSS(
@property --foo {
syntax: "<length>";
initial-value: 0px;
inherits: false;
}
)CSS");
ASSERT_TRUE(base_rule);
auto* base_copy = base_rule->Copy();
EXPECT_NE(base_rule, base_copy);
EXPECT_EQ(base_rule->GetType(), base_copy->GetType());
auto* rule = DynamicTo<StyleRuleProperty>(base_rule);
auto* copy = DynamicTo<StyleRuleProperty>(base_copy);
ASSERT_TRUE(rule);
ASSERT_TRUE(copy);
EXPECT_EQ(rule->GetName(), copy->GetName());
EXPECT_EQ(rule->GetSyntax(), copy->GetSyntax());
EXPECT_EQ(rule->Inherits(), copy->Inherits());
EXPECT_EQ(rule->GetInitialValue(), copy->GetInitialValue());
}
} // namespace blink } // namespace blink
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment