forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HTML: WPT for tabIndex (web-platform-tests#17657)
* HTML: WPT for tabIndex
- Loading branch information
1 parent
dd496df
commit c8ba37f
Showing
1 changed file
with
74 additions
and
0 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
...raction/focus/sequential-focus-navigation-and-the-tabindex-attribute/tabindex-getter.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<!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> | ||
<svg><a>svg a</a></svg> | ||
<svg><a>svg a</a></svg> | ||
<link id="nohref"> | ||
<textarea></textarea> | ||
<select><optgroup><option>option</option></optgroup></select> | ||
<select multiple></select> | ||
<iframe width="10" height="10"></iframe> | ||
<embed width="10" height="10"></embed> | ||
<object width="10" height="10"></object> | ||
<span></span> | ||
<div></div> | ||
<details><summary>summary</summary><summary id="secondsummary">second summary</summary>details</details> | ||
<div id="hostDelegatesFocus"></div> | ||
<div id="hostNonDelegatesFocus"></div> | ||
<script> | ||
document.getElementById("hostDelegatesFocus").attachShadow({ mode: "open", delegatesFocus: true }); | ||
document.getElementById("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], | ||
["svg a", 0], | ||
["textarea", 0], | ||
["select", 0], | ||
["select[multiple]", 0], | ||
["option", -1], | ||
["optgroup", -1], | ||
["iframe", 0], | ||
["embed", -1], | ||
["object", 0], | ||
["span", -1], | ||
["div", -1], | ||
["link#nohref", -1], | ||
["link[href]", -1], | ||
["details", -1], | ||
["summary", 0], | ||
["summary#secondsummary", -1], | ||
["#hostDelegatesFocus", -1], | ||
["#hostNonDelegatesFocus", -1], | ||
]; | ||
const tabIndexValue = [-1, 0, 1]; | ||
for (const entry of defaultList) { | ||
const element = document.querySelector(entry[0]); | ||
test(() => { | ||
assert_equals(element.tabIndex, entry[1]); | ||
}, entry[0] + ".tabIndex should return " + entry[1] + " by default"); | ||
for (const setValue of tabIndexValue ) { | ||
test(() => { | ||
element.setAttribute("tabindex", setValue); | ||
assert_equals(element.tabIndex, setValue); | ||
}, entry[0] + ".tabIndex should return " + setValue + " when set to " + setValue); | ||
} | ||
} | ||
</script> | ||
</body> | ||
|