Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate more focus tests with testdriver #10396

Merged
merged 1 commit into from
Apr 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion html/editing/focus/focus-01.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<input id="test">
<script>

//These tests can be automated once we have an uniform way to use webdriver.
var t1 = async_test("The keydown event must be targeted at the input element"),
t2 = async_test("The keypress event must be targeted at the input element"),
t3 = async_test("The keyup event must be targeted at the input element"),
Expand Down
1 change: 0 additions & 1 deletion html/editing/focus/focus-02.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<div id="log"></div>
<script>

//These tests can be automated once we have an uniform way to use webdriver.
var t1 = async_test("The keydown event must be targeted at the body element"),
t2 = async_test("The keypress event must be targeted at the body element"),
t3 = async_test("The keyup event must be targeted at the body element");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,15 @@
<meta assert="assert" content="Check if the tabindex attribute controls whether an element is supposed to be focusable">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<h2>Steps:</h2>
<ol>
<li>Press 'Tab' key in 10 seconds.</li>
</ol>
<h2>Expect results:</h2>
<p>PASS</p>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<div id="log"></div>
<form id="fm">
<input id="test1" tabindex="-1">
<input id="test2" tabindex="0">
</form>
<script>

//This test can be automated once we have an uniform way to use webdriver.
var t = async_test("The element with a negative tabindex must not be focused by press 'Tab' key");

setup({timeout: 10000});
Expand All @@ -41,4 +36,9 @@ <h2>Expect results:</h2>
});
}, true);

t.step(function () {
// TAB = '\ue004'
test_driver.send_keys(document.body, "\ue004");
});

</script>
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@
<meta charset="utf-8">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test fails due to #10398

<title>HTML Test: focus - the sequential focus navigation order</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#sequential-focus-navigation-and-the-tabindex-attribute">
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#sequential-focus-navigation">
<meta assert="flag" content="interact">
<meta assert="assert" content="Check the sequential focus navigation order">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<h2>Steps:</h2>
<ol>
<li>Press 'Tab' key at least 10 times in 20 seconds.(Long press the 'Tab' key will be better.)</li>
</ol>
<h2>Expect results:</h2>
<p>PASS</p>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<div id="log"></div>
<form id="fm">
<button id="btn0">tabindex(omitted)</button>
Expand All @@ -28,32 +24,41 @@ <h2>Expect results:</h2>
</form>
<script>

//This test can be automated once we have an uniform way to use webdriver.
var i = 0,
expectation = ["btn9", "btn6", "btn7", "btn8", "btn5", "btn0", "btn1", "btn2", "btn4"],
results = [],
t = async_test("The element with a zero tabindex must be focused by press 'Tab' key");
t = async_test("Elements with different tabindex must be focused sequentially when pressing 'Tab' keys");

setup(function () {
document.body.focus();
}, {timeout: 20000});



document.forms.fm.addEventListener("focus", function (evt) {
results.push(evt.target.id);
if (i >= 9) {
if (i >= 8) {
t.step(function () {
assert_array_equals(results, expectation);
});
t.done();
} else {
t.step(function () {
// TAB = '\ue004'
test_driver.send_keys(document.body, "\ue004");
});
}
i++;
}, true);

document.addEventListener("keydown", function (evt) {
if (evt.keyCode === 9) {
i += 1;
if (i === 10) {
t.done();
}
}
t.step(function () {
assert_equals(evt.keyCode, 9, "Please press 'Tab' key.");
});
}, true);

t.step(function () {
// TAB = '\ue004'
test_driver.send_keys(document.body, "\ue004");
});
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,14 @@
<meta assert="assert" content="Check if the tabindex attribute controls whether an element is supposed to be focusable">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<h2>Steps:</h2>
<ol>
<li>Press 'Tab' key in 10 seconds.</li>
</ol>
<h2>Expect results:</h2>
<p>PASS</p>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<div id="log"></div>
<form id="fm">
<input id="test" tabindex="1">
</form>
<script>

//This test can be automated once we have an uniform way to use webdriver.
var t = async_test("The element with a positive tabindex must be focused by press 'Tab' key");

setup({timeout: 10000});
Expand All @@ -40,4 +35,9 @@ <h2>Expect results:</h2>
});
}, true);

t.step(function () {
// TAB = '\ue004'
test_driver.send_keys(document.body, "\ue004");
});

</script>
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,15 @@
<meta assert="assert" content="Check if the tabindex attribute controls whether an element is supposed to be focusable">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
</head>
<h2>Steps:</h2>
<ol>
<li>Press 'Tab' key in 10 seconds.</li>
</ol>
<h2>Expect results:</h2>
<p>PASS</p>
<div id="log"></div>
<form id="fm">
<input id="test" tabindex="0">
</form>
<script>

//This test can be automated once we have an uniform way to use webdriver.
var t = async_test("The element with a zero tabindex must be focused by press 'Tab' key");

setup({timeout: 10000});
Expand All @@ -42,4 +37,9 @@ <h2>Expect results:</h2>
});
}, true);

t.step(function () {
// TAB = '\ue004'
test_driver.send_keys(document.body, "\ue004");
});

</script>