blob: d5904b4b5f13de71ccfaa37d131d3db35ee175be [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
var cb = document.createElement("input");
document.body.appendChild(cb);
cb.type = "checkbox";
description("This tests that clicking on indeterminate checkbox flips both checked/indeterminate states and calling preventDefault restores them.");
debug("Test if clicking on unchecked indeterminate checkbox flips both checked/indeterminate states");
cb.checked = false;
cb.indeterminate = true;
cb.click();
shouldBeTrue('cb.checked');
shouldBeFalse('cb.indeterminate');
debug("Test if clicking on checked indeterminate checkbox flips both checked/indeterminate states");
cb.checked = true;
cb.indeterminate = true;
cb.click();
shouldBeFalse('cb.checked');
shouldBeFalse('cb.indeterminate');
debug("Test if preventDefault restores the checked/indeterminate states");
cb.checked = false;
cb.indeterminate = true;
cb.onclick = function(e) {
shouldBeTrue('cb.checked');
shouldBeFalse('cb.indeterminate');
e.preventDefault();
};
cb.click();
shouldBeFalse('cb.checked');
shouldBeTrue('cb.indeterminate');
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>