3 <title>Implicit Form Submission
</title>
8 // match IE and FF unless specified otherwise.
10 [ "Single text input", "!text", "y" ],
11 [ "Single text input with submit disabled", "!text,-submit", "n" ],
12 [ "Multiple text inputs", "!text,text,text", "n" ],
13 [ "Multiple text inputs with submit", "!text,text,text,submit", "y" ],
14 [ "Multiple text inputs with submit disabled", "!text,text,text,-submit", "n" ],
15 [ "Multiple text inputs and multiple submits, first submit disabled", "!text,text,text,-submit,submit", "n" ], // match Gecko + spec, but not IE.
16 [ "Text input and text area, text input focused", "!text,textarea", "y" ],
17 [ "Text input and text area and a submit, text input focused", "!text,textarea,submit", "y" ],
18 [ "Text input and text area and a disabled submit, text input focused", "!text,textarea,-submit", "n" ], // match Gecko + spec, but not IE.
19 [ "Text input and checkbox, text input focused", "!text,checkbox", "y" ],
20 [ "Text input and radio, text input focused", "!text,radio", "y" ],
21 [ "Text input and text area, textarea focused", "text,!textarea", "n" ],
22 [ "Text input and checkbox, checkbox focused", "text,!checkbox", "n" ], // match IE, not FF.
23 [ "Text input and radio, radio focused", "text,!radio", "n" ], // match IE, not FF.
24 [ "Single radio", "!radio", "n" ], // match IE, not FF.
25 [ "Single checkbox", "!checkbox", "n" ],
26 [ "Single checkbox with a submit", "!checkbox,submit", "y" ],
27 [ "Single checkbox with a submit disabled", "!checkbox,-submit", "n" ],
28 [ "Single select", "!select", "n" ],
29 [ "Select with a submit", "!select,submit", "y" ], // match neither FF nor IE, instead follow logic.
30 [ "Select with a disabled submit", "!select,-submit", "n" ],
31 [ "Multi-line select with a submit", "!selectBox,submit", "y" ], // match neither FF nor IE, instead follow logic.
32 [ "Multi-line select with a disabled submit", "!selectBox,-submit", "n" ],
33 [ "Text field and single select, text focused", "!text,select", "y" ],
34 [ "Text field and single select, select focused", "text,!select", "n" ],
35 [ "Multiple text inputs with a button", "!text,text,button", "y"],
36 [ "Multiple text inputs with a disabled button", "!text,text,-button", "n"],
37 [ "Multiple text inputs with a hidden submit", "!text,text,?submit", "y"]
40 if (window
.testRunner
) {
41 testRunner
.dumpAsText();
42 testRunner
.waitUntilDone();
46 submissionReported
: false,
50 this.submissionReported
= true;
51 if (!window
.eventSender
)
54 testCompleted: function()
56 this.data
.push(this.submissionReported
? 'y' : 'n');
57 this.submissionReported
= false;
62 document
.getElementById("log").innerHTML
= allTests
.map(function(manifest
, i
)
64 return manifest
[0] + " should " + (manifest
[2] == 'n' ? "not" : "") + " submit: " + (this.data
[i
] == manifest
[2] ? "PASS" : "FAIL");
65 }, this).join("<br>");
69 function runNextTest()
72 if (currentTest
< allTests
.length
) {
76 document
.getElementById('arena').textContent
= '';
78 if (window
.testRunner
)
79 testRunner
.notifyDone();
82 function buildAndTestForm(arena
, inputs
, description
)
84 arena
.textContent
= '';
85 var form
= arena
.appendChild(document
.createElement("form"));
86 form
.addEventListener('submit', function(evt
) {
90 if (!window
.eventSender
)
91 form
.appendChild(document
.createElement("p")).innerHTML
= "Press Enter key";
92 inputs
.forEach(function(type
, i
)
96 type
= type
.substr(1);
100 if (type
[0] == '?') {
101 type
= type
.substr(1);
105 if (type
[0] == '-') {
106 type
= type
.substr(1);
110 if (type
== "textarea") {
111 control
= document
.createElement(type
);
112 } else if (type
== "select") {
113 control
= document
.createElement(type
);
114 control
.options
.add(new Option("a"));
115 } else if (type
== "selectBox") {
116 control
= document
.createElement("select");
118 control
.options
.add(new Option("a"));
119 } else if (type
== "button") {
120 control
= document
.createElement(type
);
121 control
.type
= "submit";
123 control
= document
.createElement("input");
126 control
.id
= focused
? "focused" : ("input" + i
);
127 control
.disabled
= !!disabled
;
129 control
.style
.display
= 'none';
130 form
.appendChild(control
);
132 var input
= document
.getElementById("focused");
135 if (window
.eventSender
) {
136 eventSender
.keyDown("\r", []);
137 results
.testCompleted();
139 var a
= document
.createElement("a");
140 a
.href
= "javascript:results.testCompleted();";
141 a
.innerText
= "Click if didn't submit";
142 arena
.appendChild(a
);
148 var manifest
= allTests
[currentTest
];
149 buildAndTestForm(document
.getElementById('arena'), manifest
[1].split(','), manifest
[0]);
154 <body onload=
"runTest()">
155 <p>Tests various combinations of form elements and how implicit submission works with them.
156 <div id=
"arena"></div>