1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <script src=
"../../resources/js-test.js"></script>
7 <p id=
"description"></p>
8 <div id=
"console"></div>
10 description('Various tests for .willValidate property');
12 var parent
= document
.createElement('div');
13 document
.body
.appendChild(parent
);
15 debug('Existence of .willValidate');
16 parent
.innerHTML
= '<form>'
17 + '<input name="victim"/>'
18 + '<textarea name="victim"></textarea>'
19 + '<fieldset name="victim">Test</fieldset>'
20 + '<button name="victim">'
21 + '<select name="victim"></select>'
22 + '<output name="victim"></output>'
23 + '<object name="victim"></object>'
24 + '<keygen name="victim">'
26 var controls
= document
.getElementsByName('victim');
27 for (var i
= 0; i
< controls
.length
; i
++)
28 shouldBe('typeof controls[i].willValidate', '"boolean"');
31 debug('Form association');
32 parent
.innerHTML
= '<input name="test">';
33 var input
= document
.getElementsByTagName("input")[0];
34 shouldBeTrue('input.willValidate');
35 parent
.innerHTML
= '<form><input name="test"></form>';
36 input
= document
.getElementsByTagName("input")[0];
37 shouldBeTrue('input.willValidate');
40 debug('Control name');
41 parent
.innerHTML
= '<form><input></form>';
42 input
= document
.getElementsByTagName("input")[0];
43 shouldBeTrue('input.willValidate');
44 parent
.innerHTML
= '<form><input name="test"></form>';
45 input
= document
.getElementsByTagName("input")[0];
46 shouldBeTrue('input.willValidate');
49 debug('Disabled control');
50 parent
.innerHTML
= '<form><input name="test" disabled></form>';
51 input
= document
.getElementsByTagName("input")[0];
52 shouldBeFalse('input.willValidate');
55 debug('Read-only control');
56 parent
.innerHTML
= '<form><input name="test" readonly></form>';
57 input
= document
.getElementsByTagName("input")[0];
58 shouldBeFalse('input.willValidate');
62 parent
.innerHTML
= '<form><input name="test"></form>';
63 input
= document
.getElementsByTagName("input")[0];
64 shouldBeTrue('input.willValidate');
65 shouldBeFalse('input.type = "button"; input.willValidate');
66 shouldBeTrue('input.type = "submit"; input.willValidate');
67 shouldBeFalse('input.type = "hidden"; input.willValidate');
68 shouldBeFalse('input.type = "reset"; input.willValidate');
71 debug('Fieldset element');
72 parent
.innerHTML
= '<form><fieldset><p>Fieldset test</p></fieldtset></form>';
73 shouldBeFalse('document.getElementsByTagName("fieldset")[0].willValidate');
76 debug('Textarea element');
77 parent
.innerHTML
= '<form><textarea name="text"></textarea></form>';
78 shouldBeTrue('document.getElementsByTagName("textarea")[0].willValidate');
81 debug('Output element');
82 parent
.innerHTML
= '<form><output></output></form>';
83 shouldBeFalse('document.getElementsByTagName("output")[0].willValidate');
86 debug('Object element');
87 parent
.innerHTML
= '<form><object></object></form>';
88 shouldBeFalse('document.getElementsByTagName("object")[0].willValidate');
91 debug('Keygen element');
92 parent
.innerHTML
= '<form><keygen></form>';
93 shouldBeFalse('document.getElementsByTagName("keygen")[0].willValidate');