Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / input-image-submit.html
blobfe4eb5ff49fe0b5a875be4084c0d825f2f88cb74
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <body onload="startTests()">
8 <form action="input-image-submit.html" method=GET id=form>
9 <input type=hidden name=state id=state value=step1>
10 <input type=image name=image id=image src=resources/apple.gif value=value>
11 </form>
13 <div id="console"></div>
14 <script>
15 function notifyDone() {
16 if (window.testRunner)
17 testRunner.notifyDone();
20 function failAndDone(message) {
21 testFailed(message);
22 notifyDone();
25 function handleSubmit() {
26 if (state.value == 'to-text-on-submit') {
27 image.type = 'text';
28 } else if (state.value == 'to-image-on-submit') {
29 image.type = 'image';
30 } else if (state.value == 'remove-input-on-submit') {
31 image.parentNode.removeChild(image);
32 image = null;
33 // Try to clear the reference count of the element.
34 gc();
38 function handleClick() {
39 if (state.value == 'to-image-on-click') {
40 image.type = 'image'
44 if (window.testRunner)
45 testRunner.waitUntilDone();
47 var state = document.getElementById('state');
48 var image = document.getElementById('image');
49 image.addEventListener('click', handleClick, false);
50 var form = document.getElementById('form');
51 form.addEventListener('submit', handleSubmit, false);
53 function startTests() {
54 var x = image.offsetLeft + 7;
55 var y = image.offsetTop + 11;
56 var clickEvent = document.createEvent('MouseEvent');
57 clickEvent.initMouseEvent('click', true, false, document.defaultView, 1, x, y, x, y, false, false, false, false, 0, document);
58 var enterEvent = document.createEvent('TextEvent');
59 enterEvent.initTextEvent("textInput", true, true, document.defaultView, "\n");
60 var query = window.location.search;
62 if (query.indexOf('state=') == -1) {
63 // Step 1a: Normal submission by mouse click with type=image
64 state.value = 'normal';
65 image.dispatchEvent(clickEvent);
66 } else if (query.indexOf('state=normal') != -1) {
67 // Should have image.x=7&image.y=11&image=value.
68 if (query.indexOf('image.x=7&image.y=11&image=value') == -1) {
69 failAndDone('Normal submission failed: ' + query);
70 return;
73 // Step 1b: Submission by element.click() method with type=image
74 state.value = 'click-method';
75 image.click();
76 } else if (query.indexOf('state=click-method') != -1) {
77 if (query.indexOf('image.x=0&image.y=0&image=value') == -1) {
78 failAndDone('Click method failed: ' + query);
79 return;
82 // Step 1c: Submission by keyboard activation with type=image
83 state.value = 'keyboard';
84 if (window.eventSender) {
85 image.focus();
86 eventSender.keyDown(' ');
87 } else {
88 failAndDone('This test requires eventSender');
89 return;
91 } else if (query.indexOf('state=keyboard') != -1) {
92 if (query.indexOf('image.x=0&image.y=0&image=value') == -1) {
93 failAndDone('Activating with keyboard failed: ' + query);
94 return;
97 // Step 2: Change the type to text on 'submit' event
98 state.value = 'to-text-on-submit';
99 image.dispatchEvent(clickEvent);
100 } else if (query.indexOf('state=to-text-on-submit') != -1) {
101 // Should have only image=value.
102 if (query.indexOf('image=value') == -1) {
103 failAndDone('Changing to text on submit failed: ' + query);
104 return;
107 // Step 3: Change the type to image on 'submit' event
108 state.value = 'to-image-on-submit';
109 image.type = 'text';
110 image.focus();
111 image.dispatchEvent(enterEvent);
112 } else if (query.indexOf('state=to-image-on-submit') != -1) {
113 // Should have image.x and image.y, but their values are 0.
114 if (query.indexOf('image.x=0&image.y=0&image=value') == -1) {
115 failAndDone('Changing to image on submit failed: ' + query);
116 return;
119 // Step 4: Change the type to image on 'click' event
120 state.value = 'to-image-on-click';
121 image.type = 'text';
122 image.dispatchEvent(clickEvent);
123 } else if (query.indexOf('state=to-image-on-click') != -1) {
124 // Same as the normal submission.
125 if (query.indexOf('image.x=7&image.y=11&image=value') == -1) {
126 failAndDone('Changing to image on click failed: ' + query);
127 return;
130 // Step 5: Removed the image button on 'submit' event
131 state.value = 'remove-input-on-submit';
132 image.dispatchEvent(clickEvent);
133 } else if (query.indexOf('state=remove-input-on-submit') != -1) {
134 // Should have nothing about image.
135 if (query.indexOf('image.x=') != -1 || query.indexOf('image=value') != -1)
136 testFailed('Removing the input on submit failed: ' + query);
137 else
138 testPassed('All tests passed.');
139 notifyDone();
142 </script>
143 </body>
144 </html>