OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/page/FocusController.h" | 5 #include "core/page/FocusController.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include "bindings/core/v8/V8BindingForCore.h" | 8 #include "bindings/core/v8/V8BindingForCore.h" |
9 #include "core/dom/ShadowRootInit.h" | 9 #include "core/dom/ShadowRootInit.h" |
10 #include "core/html/HTMLElement.h" | 10 #include "core/html/HTMLElement.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 87 |
88 TEST_F(FocusControllerTest, SetActiveOnInactiveDocument) { | 88 TEST_F(FocusControllerTest, SetActiveOnInactiveDocument) { |
89 // Test for crbug.com/700334 | 89 // Test for crbug.com/700334 |
90 GetDocument().Shutdown(); | 90 GetDocument().Shutdown(); |
91 // Document::shutdown() detaches document from its frame, and thus | 91 // Document::shutdown() detaches document from its frame, and thus |
92 // document().page() becomes nullptr. | 92 // document().page() becomes nullptr. |
93 // Use DummyPageHolder's page to retrieve FocusController. | 93 // Use DummyPageHolder's page to retrieve FocusController. |
94 PageHolder()->GetPage().GetFocusController().SetActive(true); | 94 PageHolder()->GetPage().GetFocusController().SetActive(true); |
95 } | 95 } |
96 | 96 |
| 97 // This test is for crbug.com/733218 |
| 98 TEST_F(FocusControllerTest, SVGFocusableElementInForm) { |
| 99 GetDocument().body()->setInnerHTML( |
| 100 "<form>" |
| 101 "<input id='first'>" |
| 102 "<svg width='100px' height='100px' tabindex='0'>" |
| 103 "<circle cx='50' cy='50' r='30' />" |
| 104 "</svg>" |
| 105 "<input id='last'>" |
| 106 "</form>"); |
| 107 |
| 108 Element* form = ToElement(GetDocument().body()->firstChild()); |
| 109 Element* first = ToElement(form->firstChild()); |
| 110 Element* last = ToElement(form->lastChild()); |
| 111 |
| 112 Element* next = GetFocusController().NextFocusableElementInForm( |
| 113 first, kWebFocusTypeForward); |
| 114 EXPECT_EQ(next, last) |
| 115 << "SVG Element should be skipped even when focusable in form."; |
| 116 |
| 117 Element* prev = GetFocusController().NextFocusableElementInForm( |
| 118 next, kWebFocusTypeBackward); |
| 119 EXPECT_EQ(prev, first) |
| 120 << "SVG Element should be skipped even when focusable in form."; |
| 121 } |
| 122 |
97 } // namespace blink | 123 } // namespace blink |
OLD | NEW |