Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / willvalidate.html
blob64305604d762ee29e75709a3e86f5c7e6d066909
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <p id="description"></p>
8 <div id="console"></div>
9 <script>
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">'
25 + '</form>';
26 var controls = document.getElementsByName('victim');
27 for (var i = 0; i < controls.length; i++)
28 shouldBe('typeof controls[i].willValidate', '"boolean"');
30 debug('');
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');
39 debug('');
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');
48 debug('');
49 debug('Disabled control');
50 parent.innerHTML = '<form><input name="test" disabled></form>';
51 input = document.getElementsByTagName("input")[0];
52 shouldBeFalse('input.willValidate');
54 debug('');
55 debug('Read-only control');
56 parent.innerHTML = '<form><input name="test" readonly></form>';
57 input = document.getElementsByTagName("input")[0];
58 shouldBeFalse('input.willValidate');
60 debug('');
61 debug('Input types');
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');
70 debug('');
71 debug('Fieldset element');
72 parent.innerHTML = '<form><fieldset><p>Fieldset test</p></fieldtset></form>';
73 shouldBeFalse('document.getElementsByTagName("fieldset")[0].willValidate');
75 debug('');
76 debug('Textarea element');
77 parent.innerHTML = '<form><textarea name="text"></textarea></form>';
78 shouldBeTrue('document.getElementsByTagName("textarea")[0].willValidate');
80 debug('');
81 debug('Output element');
82 parent.innerHTML = '<form><output></output></form>';
83 shouldBeFalse('document.getElementsByTagName("output")[0].willValidate');
85 debug('');
86 debug('Object element');
87 parent.innerHTML = '<form><object></object></form>';
88 shouldBeFalse('document.getElementsByTagName("object")[0].willValidate');
90 debug('');
91 debug('Keygen element');
92 parent.innerHTML = '<form><keygen></form>';
93 shouldBeFalse('document.getElementsByTagName("keygen")[0].willValidate');
94 </script>
95 </body>
96 </html>