3 <script src=
"../../resources/js-test.js"></script>
6 /* Float everything so they fit inside the viewport for using eventSender to click */
7 section, footer, span, textarea, select { float: left; }
14 <section style=
"height: 100px; width: 100px; overflow: scroll;"></section>
17 <header style=
"height: 100px; width: 100px; overflow: scroll;"></header>
20 <span contenteditable
>
21 <u style=
"height: 100px; width: 100px; overflow: scroll; display: block;"></u>
48 if (window
.testRunner
)
49 testRunner
.dumpAsText();
53 if (window
.eventSender
) {
54 eventSender
.mouseMoveTo(x
, y
);
55 eventSender
.mouseDown();
56 eventSender
.mouseUp();
60 function clickVerticalScrollbar(type
)
62 var element
= document
.querySelector(type
);
63 click(element
.offsetLeft
+ element
.offsetWidth
- 5, element
.offsetTop
+ 5);
66 function clickHorizontalScrollbar(type
)
68 var element
= document
.querySelector(type
);
69 click(element
.offsetLeft
+ 5, element
.offsetTop
+ element
.offsetHeight
- 5);
72 function test(name
, fn
)
78 description("This tests clicking scrollbars, which should only move the focus if an ancestor is mouse focusable.");
80 test("Focus should remain in the input", function() {
81 document
.querySelector("input").focus();
82 clickVerticalScrollbar("section");
83 clickHorizontalScrollbar("section");
84 shouldBeEqualToString("document.activeElement.tagName", "INPUT");
87 test("Focus should move if ancestor is mouse focusable", function() {
88 document
.querySelector("input").focus();
89 clickVerticalScrollbar("header");
90 shouldBeEqualToString("document.activeElement.tagName", "DIV");
91 document
.querySelector("input").focus();
92 clickHorizontalScrollbar("header");
93 shouldBeEqualToString("document.activeElement.tagName", "DIV");
96 test("Focus should move if ancestor is content editable", function() {
97 document
.querySelector("input").focus();
98 clickVerticalScrollbar("u");
99 shouldBeEqualToString("document.activeElement.tagName", "SPAN");
100 document
.querySelector("input").focus();
101 clickHorizontalScrollbar("u");
102 shouldBeEqualToString("document.activeElement.tagName", "SPAN");
105 test("Form controls should move the focus", function() {
106 clickVerticalScrollbar("textarea");
107 shouldBeEqualToString("document.activeElement.tagName", "TEXTAREA");
108 clickVerticalScrollbar("select");
109 shouldBeEqualToString("document.activeElement.tagName", "SELECT");
112 test("Disabled form controls should not move the focus", function() {
113 document
.querySelector("input").focus();
114 document
.querySelector("select").disabled
= true;
115 clickVerticalScrollbar("select");
116 shouldBeEqualToString("document.activeElement.tagName", "INPUT");