Commit 0d199fbc authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Make WebElementTest to use Element::AttachShadowRootInternal() and CreateV0ShadowRootForTesting()

This patch changes |FocusControllerTest| to use |AttachShadowRootInternal()|
and CreateV0ShadowRootForTesting() instead of |Element::attachShadow()| and
|Element::createShadowRoot()|to avoid using script only functions for
improving code health.

Change-Id: Id362106ff3f1b1f577da7ec3bce97e60b0b490f4
Reviewed-on: https://chromium-review.googlesource.com/1070011Reviewed-by: default avatarHayato Ito <hayato@chromium.org>
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560991}
parent e56fa687
...@@ -205,13 +205,12 @@ TEST_F(WebElementTest, ShadowRoot) { ...@@ -205,13 +205,12 @@ TEST_F(WebElementTest, ShadowRoot) {
EXPECT_TRUE(TestElement().ShadowRoot().IsNull()) EXPECT_TRUE(TestElement().ShadowRoot().IsNull())
<< "ShadowRoot() should not return a UA ShadowRoot."; << "ShadowRoot() should not return a UA ShadowRoot.";
auto* script_state = ToScriptStateForMainWorld(GetDocument().GetFrame());
{ {
InsertHTML("<div id=testElement></div>"); InsertHTML("<div id=testElement></div>");
EXPECT_TRUE(TestElement().ShadowRoot().IsNull()) EXPECT_TRUE(TestElement().ShadowRoot().IsNull())
<< "No ShadowRoot initially."; << "No ShadowRoot initially.";
auto* element = GetDocument().getElementById("testElement"); auto* element = GetDocument().getElementById("testElement");
element->createShadowRoot(script_state, ASSERT_NO_EXCEPTION); element->CreateV0ShadowRootForTesting();
EXPECT_FALSE(TestElement().ShadowRoot().IsNull()) EXPECT_FALSE(TestElement().ShadowRoot().IsNull())
<< "Should return V0 ShadowRoot."; << "Should return V0 ShadowRoot.";
} }
...@@ -221,9 +220,7 @@ TEST_F(WebElementTest, ShadowRoot) { ...@@ -221,9 +220,7 @@ TEST_F(WebElementTest, ShadowRoot) {
EXPECT_TRUE(TestElement().ShadowRoot().IsNull()) EXPECT_TRUE(TestElement().ShadowRoot().IsNull())
<< "No ShadowRoot initially."; << "No ShadowRoot initially.";
auto* element = GetDocument().getElementById("testElement"); auto* element = GetDocument().getElementById("testElement");
ShadowRootInit init; element->AttachShadowRootInternal(ShadowRootType::kOpen);
init.setMode("open");
element->attachShadow(script_state, init, ASSERT_NO_EXCEPTION);
EXPECT_FALSE(TestElement().ShadowRoot().IsNull()) EXPECT_FALSE(TestElement().ShadowRoot().IsNull())
<< "Should return V1 open ShadowRoot."; << "Should return V1 open ShadowRoot.";
} }
...@@ -233,9 +230,7 @@ TEST_F(WebElementTest, ShadowRoot) { ...@@ -233,9 +230,7 @@ TEST_F(WebElementTest, ShadowRoot) {
EXPECT_TRUE(TestElement().ShadowRoot().IsNull()) EXPECT_TRUE(TestElement().ShadowRoot().IsNull())
<< "No ShadowRoot initially."; << "No ShadowRoot initially.";
auto* element = GetDocument().getElementById("testElement"); auto* element = GetDocument().getElementById("testElement");
ShadowRootInit init; element->AttachShadowRootInternal(ShadowRootType::kClosed);
init.setMode("closed");
element->attachShadow(script_state, init, ASSERT_NO_EXCEPTION);
EXPECT_FALSE(TestElement().ShadowRoot().IsNull()) EXPECT_FALSE(TestElement().ShadowRoot().IsNull())
<< "Should return V1 closed ShadowRoot."; << "Should return V1 closed ShadowRoot.";
} }
......
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