blob: 0f79274af9278f5bbc3a718f7c1d77432bb40c55 [file] [log] [blame]
<!DOCTYPE html>
<body>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../resources/common-pseudo-classes.js"></script>
<div id="container">
<input type="week" value="1982-W25" id="enabled">
<input type="week" value="1982-W25" id="disabled" disabled>
<input type="week" value="1982-W25" min="1982-W10" step="2" id="invalid">
<input type="week" value="1982-W25" min="1982-W01" max="1982-W30" id="inrange">
<input type="week" value="ABC" min="1982-W01" max="1982-W30" id="badvalue">
<input type="week" value="1982-W25" min="1981-W01" max="1981-W12" id="outofrange">
<input type="week" value="1982-W25" readonly id="readonly">
<input type="week" value="1982-W25" required id="required">
</div>
<script>
description('Test if an input field matches to various pseudo classes');
var container = document.getElementById('container');
shouldBeTrue('matchedNodesContainId(container, ":enabled", "enabled")');
shouldBeTrue('matchedNodesContainId(container, ":valid", "enabled")');
shouldBeTrue('matchedNodesContainId(container, ":optional", "enabled")');
shouldBeTrue('matchedNodesContainId(container, ":read-write", "enabled")');
shouldBeTrue('matchedNodesContainId(container, ":disabled", "disabled")');
shouldBeTrue('matchedNodesContainId(container, ":invalid", "invalid")');
shouldBeTrue('matchedNodesContainId(container, ":in-range", "inrange")');
shouldBeTrue('matchedNodesContainId(container, ":in-range", "badvalue")');
shouldBeTrue('matchedNodesContainId(container, ":out-of-range", "outofrange")');
shouldBeTrue('matchedNodesContainId(container, ":read-only", "readonly")');
shouldBeTrue('matchedNodesContainId(container, ":required", "required")');
// Make the id=outofrange element in-range state.
document.getElementById('outofrange').value = '1981-W10';
shouldBeFalse('matchedNodesContainId(container, ":out-of-range", "outofrange")');
shouldBeTrue('matchedNodesContainId(container, ":in-range", "outofrange")');
// Make the id=inrange element out-of-range state.
document.getElementById('inrange').value = '1981-W10';
shouldBeFalse('matchedNodesContainId(container, ":in-range", "inrange")');
shouldBeTrue('matchedNodesContainId(container, ":out-of-range", "inrange")');
container.remove();
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>