| Index: third_party/WebKit/Source/core/page/FocusControllerTest.cpp
|
| diff --git a/third_party/WebKit/Source/core/page/FocusControllerTest.cpp b/third_party/WebKit/Source/core/page/FocusControllerTest.cpp
|
| index 39e34485d462796eee492f7782014b7bf46ca9b0..9dd41204090144342b5d9c35fc45fa773cbb1e4b 100644
|
| --- a/third_party/WebKit/Source/core/page/FocusControllerTest.cpp
|
| +++ b/third_party/WebKit/Source/core/page/FocusControllerTest.cpp
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "core/page/FocusController.h"
|
|
|
| +#include "core/dom/shadow/ShadowRootInit.h"
|
| #include "core/html/HTMLElement.h"
|
| #include "core/testing/DummyPageHolder.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| @@ -32,4 +33,48 @@ TEST_F(FocusControllerTest, SetInitialFocus)
|
| EXPECT_EQ(input, document().focusedElement()) << "We should ignore sequential focus navigation starting point in setInitialFocus().";
|
| }
|
|
|
| +TEST_F(FocusControllerTest, DoNotCrash1)
|
| +{
|
| + document().body()->setInnerHTML(
|
| + "<div id='host'></div>This test is for crbug.com/609012<p id='target' tabindex='0'></p>",
|
| + ASSERT_NO_EXCEPTION);
|
| + // <div> with shadow root
|
| + Element* host = toElement(document().body()->firstChild());
|
| + ShadowRootInit init;
|
| + init.setMode("open");
|
| + host->attachShadow(ScriptState::forMainWorld(document().frame()), init, ASSERT_NO_EXCEPTION);
|
| + // "This test is for crbug.com/609012"
|
| + Node* text = host->nextSibling();
|
| + // <p>
|
| + Element* target = toElement(text->nextSibling());
|
| +
|
| + // Set sequential focus navigation point at text node.
|
| + document().setSequentialFocusNavigationStartingPoint(text);
|
| +
|
| + focusController().advanceFocus(WebFocusTypeForward);
|
| + EXPECT_EQ(target, document().focusedElement()) << "This should not hit assertion and finish properly.";
|
| +}
|
| +
|
| +TEST_F(FocusControllerTest, DoNotCrash2)
|
| +{
|
| + document().body()->setInnerHTML(
|
| + "<p id='target' tabindex='0'></p>This test is for crbug.com/609012<div id='host'></div>",
|
| + ASSERT_NO_EXCEPTION);
|
| + // <p>
|
| + Element* target = toElement(document().body()->firstChild());
|
| + // "This test is for crbug.com/609012"
|
| + Node* text = target->nextSibling();
|
| + // <div> with shadow root
|
| + Element* host = toElement(text->nextSibling());
|
| + ShadowRootInit init;
|
| + init.setMode("open");
|
| + host->attachShadow(ScriptState::forMainWorld(document().frame()), init, ASSERT_NO_EXCEPTION);
|
| +
|
| + // Set sequential focus navigation point at text node.
|
| + document().setSequentialFocusNavigationStartingPoint(text);
|
| +
|
| + focusController().advanceFocus(WebFocusTypeBackward);
|
| + EXPECT_EQ(target, document().focusedElement()) << "This should not hit assertion and finish properly.";
|
| +}
|
| +
|
| } // namespace blink
|
|
|