OLD | NEW |
---|---|
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 To test manually, click on all the form elements (except the textbox) and the de tails/summary | 2 To test manually, click on all the form elements (except the textbox) and the de tails/summary |
3 element. The anchor shouldn't be activated (i.e. you shouldn't see any "anchor a ctivated" messages). | 3 element. The anchor shouldn't be activated (i.e. you shouldn't see any "anchor a ctivated" messages). |
4 <a href="javascript:anchorActivated()"> | 4 <a href="javascript:anchorActivated()"> |
5 <form action="javascript:formSubmitted()"> | 5 <form action="javascript:formSubmitted()"> |
6 <input type=text> | 6 <input type=text> |
7 <input type=submit> | 7 <input type=submit> |
8 <input type=image> | 8 <input src="resources/abe.png" type=image> |
9 <button>button</button> | 9 <button>button</button> |
10 <input type=reset> | 10 <input type=reset> |
11 <button type=reset>button reset</button> | 11 <button type=reset>button reset</button> |
12 <input type=checkbox> | 12 <input type=checkbox> |
13 <input type=radio> | 13 <input type=radio> |
14 <input type=file> | 14 <input type=file> |
15 </form> | 15 </form> |
16 <details><summary>summary</summary>details</details> | 16 <details><summary>summary</summary>details</details> |
17 </a> | 17 </a> |
18 | 18 |
19 <pre> | 19 <pre> |
20 | 20 |
21 </pre> | 21 </pre> |
22 | 22 |
23 <script> | 23 <script> |
24 if (window.testRunner) | 24 if (window.testRunner) |
25 testRunner.dumpAsText(); | 25 testRunner.dumpAsText(); |
26 | 26 |
27 function log(message) { document.querySelector("pre").innerHTML += message + "\n "; } | 27 function log(message) { document.querySelector("pre").innerHTML += message + "\n "; } |
28 function formSubmitted() { log("form submitted\n"); } | 28 function formSubmitted() { log("form submitted\n"); } |
29 function anchorActivated() { log("anchor activated\n"); } | 29 function anchorActivated() { log("anchor activated\n"); } |
30 | 30 |
31 document.forms[0].children[0].value = "blah"; | 31 document.forms[0].children[0].value = "blah"; |
32 | 32 |
33 for (var i=0; i < document.forms[0].children.length; i++) { | 33 document.querySelector("input[type=image]").addEventListener("load", function() { |
hayato
2015/09/30 08:12:09
The diff is difficult to read. It just wraps the e
| |
34 var element = document.forms[0].children[i]; | 34 for (var i=0; i < document.forms[0].children.length; i++) { |
35 var element = document.forms[0].children[i]; | |
35 | 36 |
36 element.addEventListener("click", function () { | 37 element.addEventListener("click", function () { |
37 log("Activated " + this + " type=" + this.type); | 38 log("Activated " + this + " type=" + this.type); |
38 }, false); | 39 }, false); |
39 | 40 |
40 if (!window.eventSender) | 41 if (!window.eventSender) |
41 continue; | 42 continue; |
42 | 43 |
43 if (element.type == "text") { | 44 if (element.type == "text") { |
45 log("Focusing " + element + " type=" + element.type + " and pressing enter"); | |
46 element.focus(); | |
47 eventSender.keyDown("\n"); | |
48 continue; | |
49 } | |
50 | |
51 eventSender.mouseMoveTo(element.offsetLeft + element.clientWidth / 2, el ement.offsetTop + element.clientHeight / 2); | |
52 eventSender.mouseDown(); | |
53 eventSender.mouseUp(); | |
54 | |
55 if (element.type == "radio" || element.type == "checkbox") | |
56 continue; | |
57 | |
44 log("Focusing " + element + " type=" + element.type + " and pressing ent er"); | 58 log("Focusing " + element + " type=" + element.type + " and pressing ent er"); |
45 element.focus(); | 59 element.focus(); |
46 eventSender.keyDown("\n"); | 60 eventSender.keyDown("\n"); |
47 continue; | |
48 } | 61 } |
49 | 62 |
50 eventSender.mouseMoveTo(element.offsetLeft + element.clientWidth / 2, elemen t.offsetTop + element.clientHeight / 2); | 63 if (window.eventSender) { |
51 eventSender.mouseDown(); | 64 var details = document.querySelector("details"); |
52 eventSender.mouseUp(); | 65 eventSender.mouseMoveTo(details.offsetLeft + details.clientWidth / 2, de tails.offsetTop + details.clientHeight / 2); |
66 eventSender.mouseDown(); | |
67 eventSender.mouseUp(); | |
68 log("\nThe details element was " + (details.open ? "" : "not ") + "opene d"); | |
69 } | |
53 | 70 |
54 if (element.type == "radio" || element.type == "checkbox") | 71 if (window.testRunner) |
55 continue; | 72 document.querySelector("a").style.display = "none"; |
56 | 73 }); |
57 log("Focusing " + element + " type=" + element.type + " and pressing enter") ; | |
58 element.focus(); | |
59 eventSender.keyDown("\n"); | |
60 } | |
61 | |
62 if (window.eventSender) { | |
63 var details = document.querySelector("details"); | |
64 eventSender.mouseMoveTo(details.offsetLeft + details.clientWidth / 2, detail s.offsetTop + details.clientHeight / 2); | |
65 eventSender.mouseDown(); | |
66 eventSender.mouseUp(); | |
67 log("\nThe details element was " + (details.open ? "" : "not ") + "opened"); | |
68 } | |
69 | |
70 if (window.testRunner) | |
71 document.querySelector("a").style.display = "none"; | |
72 </script> | 74 </script> |
OLD | NEW |