Commit dd548c2a authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Convert fast/overflow/scrollbar-click-retains-focus.html with testharness

This patch converts the layout test with W3C testharness to reduce usage
of deprecated js-test.js.

This patch is also a preparation for using Element.innerText for text
dump. As the layout tests adds float style to all <span>, without this
patch, innerText dump can be confusing.

Bug: 887148
Change-Id: Ia8cafbc996fe1f4ae66350b565b7611bb7ec35e5
Reviewed-on: https://chromium-review.googlesource.com/c/1318357
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605574}
parent b384248a
This tests clicking scrollbars, which should only move the focus if an ancestor is mouse focusable.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Focus should remain in the input
PASS document.activeElement.tagName is "INPUT"
Focus should move if ancestor is mouse focusable
PASS document.activeElement.tagName is "DIV"
PASS document.activeElement.tagName is "DIV"
Focus should move if ancestor is content editable
PASS document.activeElement.tagName is "SPAN"
PASS document.activeElement.tagName is "SPAN"
Form controls should move the focus
PASS document.activeElement.tagName is "TEXTAREA"
PASS document.activeElement.tagName is "SELECT"
Disabled form controls should not move the focus
PASS document.activeElement.tagName is "INPUT"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<script src="../../resources/js-test.js"></script>
<title>
This tests clicking scrollbars, which should only move the focus if an ancestor is mouse focusable.
</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<style>
/* Float everything so they fit inside the viewport for using eventSender to click */
......@@ -45,9 +50,6 @@
</select>
<script>
if (window.testRunner)
testRunner.dumpAsText();
function click(x, y)
{
if (window.eventSender) {
......@@ -69,51 +71,43 @@ function clickHorizontalScrollbar(type)
click(element.offsetLeft + 5, element.offsetTop + element.offsetHeight - 5);
}
function test(name, fn)
{
debug("<br>" + name);
fn();
}
description("This tests clicking scrollbars, which should only move the focus if an ancestor is mouse focusable.");
test("Focus should remain in the input", function() {
test(function() {
document.querySelector("input").focus();
clickVerticalScrollbar("section");
clickHorizontalScrollbar("section");
shouldBeEqualToString("document.activeElement.tagName", "INPUT");
});
assert_equals(document.activeElement.tagName, "INPUT");
}, "Focus should remain in the input");
test("Focus should move if ancestor is mouse focusable", function() {
test(function() {
document.querySelector("input").focus();
clickVerticalScrollbar("header");
shouldBeEqualToString("document.activeElement.tagName", "DIV");
assert_equals(document.activeElement.tagName, "DIV");
document.querySelector("input").focus();
clickHorizontalScrollbar("header");
shouldBeEqualToString("document.activeElement.tagName", "DIV");
});
assert_equals(document.activeElement.tagName, "DIV");
}, "Focus should move if ancestor is mouse focusable");
test("Focus should move if ancestor is content editable", function() {
test(function() {
document.querySelector("input").focus();
clickVerticalScrollbar("u");
shouldBeEqualToString("document.activeElement.tagName", "SPAN");
assert_equals(document.activeElement.tagName, "SPAN");
document.querySelector("input").focus();
clickHorizontalScrollbar("u");
shouldBeEqualToString("document.activeElement.tagName", "SPAN");
});
assert_equals(document.activeElement.tagName, "SPAN");
}, "Focus should move if ancestor is content editable");
test("Form controls should move the focus", function() {
test(function() {
clickVerticalScrollbar("textarea");
shouldBeEqualToString("document.activeElement.tagName", "TEXTAREA");
assert_equals(document.activeElement.tagName, "TEXTAREA");
clickVerticalScrollbar("select");
shouldBeEqualToString("document.activeElement.tagName", "SELECT");
});
assert_equals(document.activeElement.tagName, "SELECT");
}, "Form controls should move the focus");
test("Disabled form controls should not move the focus", function() {
test(function() {
document.querySelector("input").focus();
document.querySelector("select").disabled = true;
clickVerticalScrollbar("select");
shouldBeEqualToString("document.activeElement.tagName", "INPUT");
});
assert_equals(document.activeElement.tagName, "INPUT");
}, "Disabled form controls should not move the focus");
</script>
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