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

HTML: WPT for tabIndex #17657

Merged
merged 6 commits into from
Aug 15, 2019
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: tabIndex getter return value</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<input>
<input type="hidden">
<button>button</button>
<button disabled>button</button>
<button hidden>button</button>
<a>a</a>
<a href="#">a</a>
<textarea></textarea>
<select></select>
<iframe width="10" height="10"></iframe>
<span></span>
<div></div>
<div id="hostDelegatesFocus"></div>
<div id="hostNonDelegatesFocus"></div>
<script>
hostDelegatesFocus.attachShadow({ mode: "open", delegatesFocus: true });
annevk marked this conversation as resolved.
Show resolved Hide resolved
hostNonDelegatesFocus.attachShadow({ mode: "open", delegatesFocus: false });

const defaultList = [
["input", 0],
["input[type='hidden']", 0],
["button", 0],
["button[disabled]", 0],
["button[hidden]", 0],
["a", 0],
["a[href]", 0],
["textarea", 0],
["select", 0],
["iframe", 0],
["span", -1],
["div", -1],
["#hostDelegatesFocus", -1],
["#hostNonDelegatesFocus", -1],
];

const tabIndexValue = [-1, 0, 1];

for (entry of defaultList) {
annevk marked this conversation as resolved.
Show resolved Hide resolved
let element = document.querySelector(entry[0]);
annevk marked this conversation as resolved.
Show resolved Hide resolved
test(() => {
assert_equals(element.tabIndex, entry[1]);
}, entry[0] + ".tabIndex should return " + entry[1] + " by default");

for (setValue of tabIndexValue ) {
annevk marked this conversation as resolved.
Show resolved Hide resolved
test(() => {
element.setAttribute("tabindex", setValue);
assert_equals(element.tabIndex, setValue);
}, entry[0] + ".tabIndex should return " + setValue + " when set to " + setValue);
}
}
</script>
</body>