Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(616)

Unified Diff: third_party/WebKit/Source/core/page/FocusControllerTest.cpp

Issue 1954023002: Move asserts in FocusNavigationController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: readding assert Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/page/FocusController.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « third_party/WebKit/Source/core/page/FocusController.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698