blob: ae1e6f742bb8cc2ed7d9cb5f9bbbc241a9912e5d [file] [log] [blame]
// Copyright 2016 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 "core/editing/EditingStyle.h"
#include "core/css/StylePropertySet.h"
#include "core/dom/Document.h"
#include "core/editing/EditingTestBase.h"
#include "core/html/HTMLBodyElement.h"
#include "core/html/HTMLDivElement.h"
#include "core/html/HTMLHeadElement.h"
#include "core/html/HTMLHtmlElement.h"
namespace blink {
class EditingStyleTest : public EditingTestBase {};
TEST_F(EditingStyleTest, mergeInlineStyleOfElement) {
SetBodyContent(
"<span id=s1 style='--A:var(---B)'>1</span>"
"<span id=s2 style='float:var(--C)'>2</span>");
UpdateAllLifecyclePhases();
EditingStyle* editing_style =
EditingStyle::Create(ToHTMLElement(GetDocument().getElementById("s2")));
editing_style->MergeInlineStyleOfElement(
ToHTMLElement(GetDocument().getElementById("s1")),
EditingStyle::kOverrideValues);
EXPECT_FALSE(editing_style->Style()->HasProperty(CSSPropertyFloat))
<< "Don't merge a property with unresolved value";
EXPECT_EQ("var(---B)",
editing_style->Style()->GetPropertyValue(AtomicString("--A")))
<< "Keep unresolved value on merging style";
}
} // namespace blink