forked from servo/servo
-
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.
Merge pull request servo#695 from deniak/disabled-elements
disabled elements cannot be focused
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
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,44 @@ | ||
<!DOCTYPE html> | ||
<meta charset=utf-8> | ||
<title>Disabled elements</title> | ||
<link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org"> | ||
<link rel=help href="http://www.whatwg.org/html/#disabled-elements"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<div id="log"></div> | ||
<button disabled>button</button> | ||
<input disabled> | ||
<select disabled> | ||
<optgroup label="options" disabled> | ||
<option value="option1" disabled>option1 | ||
<option value="option2">option2 | ||
</select> | ||
<textarea disabled>textarea</textarea> | ||
<fieldset disabled> | ||
<input type=radio name=c value=0 checked> | ||
<input type=radio name=c value=1> | ||
</fieldset> | ||
<a href="http://www.w3.org/" disabled>w3</a> | ||
<span tabindex=0 disabled>foobar</span> | ||
|
||
<script> | ||
test(function(){ | ||
assert_equals(document.activeElement, document.body); | ||
}, "The body element must be the active element if no element is focused"); | ||
|
||
["button", "input", "select", "optgroup", "option", "textarea", "input[type=radio]"].forEach(function(el) { | ||
test(function() { | ||
var element = document.querySelector(el); | ||
element.focus(); | ||
assert_equals(document.activeElement, document.body, "activeElement after focus on a disabled <" + el + "> remains unchanged"); | ||
}, "A disabled <" + el + "> should not be focusable"); | ||
}); | ||
|
||
["a", "span"].forEach(function(el) { | ||
test(function() { | ||
var element = document.querySelector(el); | ||
element.focus(); | ||
assert_equals(document.activeElement, element, "focus on a <" + el + "> with a disabled attribute should make it the activeElement"); | ||
}, "A disabled <" + el + "> should be focusable"); | ||
}); | ||
</script> |