2 <script src=
"../../resources/js-test.js"></script>
4 <p>Test for
<<a href=
"rdar://5483519">rdar://
5483519</a>> Pressing Enter on selected buttons should fire onclick
</p>
5 <div id=
"console"></div>
8 <form onsubmit=
"logEvent(event); return false">
9 <button type=
"button" onclick=
"logEvent(event)">button
type=
"button"</button>
10 <button type=
"submit" onclick=
"logEvent(event)">button
type=
"submit"</button>
11 <button type=
"reset" onclick=
"logEvent(event)">button
type=
"reset"</button>
12 <input type=
"checkbox" onclick=
"logEvent(event)" value=
"input type='checkbox'">
13 <input type=
"button" onclick=
"logEvent(event)" value=
"input type='button'">
14 <input type=
"submit" onclick=
"logEvent(event)" value=
"input type='submit'">
15 <input type=
"reset" onclick=
"logEvent(event)" value=
"input type='reset'">
17 <p>Outside a form:
</p>
18 <button type=
"button" onclick=
"logEvent(event)">button
type=
"button"</button>
19 <button type=
"submit" onclick=
"logEvent(event)">button
type=
"submit"</button>
20 <button type=
"reset" onclick=
"logEvent(event)">button
type=
"reset"</button>
21 <input type=
"checkbox" onclick=
"logEvent(event)" value=
"input type='checkbox'">
22 <input type=
"button" onclick=
"logEvent(event)" value=
"input type='button'">
23 <input type=
"submit" onclick=
"logEvent(event)" value=
"input type='submit'">
24 <input type=
"reset" onclick=
"logEvent(event)" value=
"input type='reset'">
27 function nodeIsChildOfForm(node
)
29 return node
.parentNode
&& node
.parentNode
.tagName
== 'FORM';
32 function targetDescription(node
)
34 return node
.nodeName
+ (node
.type
? ' type=' + node
.type
: '') + (nodeIsChildOfForm(node
) ? ' in form' : '');
37 function logEvent(event
)
39 debug(event
.type
+ ': ' + targetDescription(event
.target
));
42 var keys
= ['\r', ' '];
43 var keyNames
= ['Enter', 'U+0020'];
44 var tagNames
= ['button', 'input'];
49 debug('Sending ' + keyNames
[i
] + ' keypresses...');
51 for (var j
in tagNames
) {
52 var elements
= document
.getElementsByTagName(tagNames
[j
]);
54 debug('Looping over ' + elements
.length
+ ' ' + tagNames
[j
] + ' elements...');
56 for (var k
= 0; k
< elements
.length
; ++k
) {
58 eventSender
.keyDown(keys
[i
], []);
62 document
.querySelector('#container').remove();