blob: 48cb934efb2a934d9db1b059e877154a9781d8ea [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>
description('Various tests for .willValidate property');
var parent = document.createElement('div');
document.body.appendChild(parent);
debug('Existence of .willValidate');
parent.innerHTML = '<form>'
+ '<input name="victim"/>'
+ '<textarea name="victim"></textarea>'
+ '<fieldset name="victim">Test</fieldset>'
+ '<button name="victim">'
+ '<select name="victim"></select>'
+ '<output name="victim"></output>'
+ '<object name="victim"></object>'
+ '<keygen name="victim">'
+ '</form>';
var controls = document.getElementsByName('victim');
for (var i = 0; i < controls.length; i++) {
if (controls[i].localName != 'keygen')
shouldBe('typeof controls[i].willValidate', '"boolean"');
}
debug('');
debug('Form association');
parent.innerHTML = '<input name="test">';
var input = document.getElementsByTagName("input")[0];
shouldBeTrue('input.willValidate');
parent.innerHTML = '<form><input name="test"></form>';
input = document.getElementsByTagName("input")[0];
shouldBeTrue('input.willValidate');
debug('');
debug('Control name');
parent.innerHTML = '<form><input></form>';
input = document.getElementsByTagName("input")[0];
shouldBeTrue('input.willValidate');
parent.innerHTML = '<form><input name="test"></form>';
input = document.getElementsByTagName("input")[0];
shouldBeTrue('input.willValidate');
debug('');
debug('Disabled control');
parent.innerHTML = '<form><input name="test" disabled></form>';
input = document.getElementsByTagName("input")[0];
shouldBeFalse('input.willValidate');
debug('');
debug('Read-only control');
parent.innerHTML = '<form><input name="test" readonly></form>';
input = document.getElementsByTagName("input")[0];
shouldBeFalse('input.willValidate');
debug('');
debug('Input types');
parent.innerHTML = '<form><input name="test"></form>';
input = document.getElementsByTagName("input")[0];
shouldBeTrue('input.willValidate');
shouldBeFalse('input.type = "button"; input.willValidate');
shouldBeTrue('input.type = "submit"; input.willValidate');
shouldBeFalse('input.type = "hidden"; input.willValidate');
shouldBeFalse('input.type = "reset"; input.willValidate');
debug('');
debug('Fieldset element');
parent.innerHTML = '<form><fieldset><p>Fieldset test</p></fieldtset></form>';
shouldBeFalse('document.getElementsByTagName("fieldset")[0].willValidate');
debug('');
debug('Textarea element');
parent.innerHTML = '<form><textarea name="text"></textarea></form>';
shouldBeTrue('document.getElementsByTagName("textarea")[0].willValidate');
debug('');
debug('Output element');
parent.innerHTML = '<form><output></output></form>';
shouldBeFalse('document.getElementsByTagName("output")[0].willValidate');
debug('');
debug('Object element');
parent.innerHTML = '<form><object></object></form>';
shouldBeFalse('document.getElementsByTagName("object")[0].willValidate');
debug('');
debug('Keygen element');
parent.innerHTML = '<form><keygen></form>';
shouldBeUndefined('document.getElementsByTagName("keygen")[0].willValidate');
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>