Skip to content

Commit

Permalink
Merge pull request servo#695 from deniak/disabled-elements
Browse files Browse the repository at this point in the history
disabled elements cannot be focused
  • Loading branch information
zcorpan committed Feb 28, 2014
2 parents fdc1fc1 + f71255a commit da035d9
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions html/semantics/disabled-elements/disabledElement.html
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>

0 comments on commit da035d9

Please # to comment.