3 <script src=
"../../resources/js-test.js"></script>
6 <input type=
"checkbox" id=
"checkbox-btn1" onclick=
"doClickAction(event)" onchange=
"doChangeAction(event)"/>
7 <input type=
"checkbox" id=
"checkbox-btn2" onclick=
"doClickAction(event); event.preventDefault()" onchange=
"doChangeAction(event)"/>
8 <input type=
"checkbox" id=
"checkbox-btn3" onclick=
"this.value = this.checked;" onchange=
"message = 'changed';"/>
9 <input type=
"radio" id=
"radio-btn1" onclick=
"doClickAction(event)" onchange=
"doChangeAction(event)"/>
10 <input type=
"radio" id=
"radio-btn2" onclick=
"doClickAction(event); event.preventDefault()" onchange=
"doChangeAction(event)"/>
11 <input type=
"radio" id=
"radio-btn3" onclick=
"this.value = this.checked;" onchange=
"message = 'changed';"/>
13 description('Tests the order of onclick and onchange');
16 function doClickAction(e
)
18 shouldBeEqualToString('message', '');
22 function doChangeAction(e
)
24 shouldBeEqualToString('message', 'clicked');
28 var checkbox1
= document
.getElementById('checkbox-btn1');
29 var checkbox2
= document
.getElementById('checkbox-btn2');
30 var checkbox3
= document
.getElementById('checkbox-btn3');
31 var radio1
= document
.getElementById('radio-btn1');
32 var radio2
= document
.getElementById('radio-btn2');
33 var radio3
= document
.getElementById('radio-btn3');
35 debug('Tests for checkboxes:');
38 shouldBeEqualToString('message', 'changed');
39 shouldBeTrue('checkbox1.checked');
43 shouldBeEqualToString('message', 'changed');
44 shouldBeFalse('checkbox1.checked');
48 shouldBeEqualToString('message', 'clicked');
49 shouldBeFalse('checkbox2.checked');
52 checkbox1
.checked
= false;
54 eventSender
.keyDown(' ');
55 shouldBeEqualToString('message', 'changed');
56 shouldBeTrue('checkbox1.checked');
60 eventSender
.keyDown(' ');
61 shouldBeEqualToString('message', 'changed');
62 shouldBeFalse('checkbox1.checked');
65 checkbox2
.checked
= false;
67 eventSender
.keyDown(' ');
68 shouldBeEqualToString('message', 'clicked');
69 shouldBeFalse('checkbox2.checked');
71 debug('Updating |value| in click handler:');
74 shouldBeEqualToString('message', 'changed');
77 debug('Tests for radio buttons:');
80 shouldBeEqualToString('message', 'changed');
81 shouldBeTrue('radio1.checked');
85 shouldBeEqualToString('message', 'clicked');
86 shouldBeTrue('radio1.checked');
90 shouldBeEqualToString('message', 'clicked');
91 shouldBeFalse('radio2.checked');
94 radio1
.checked
= false;
96 eventSender
.keyDown(' ');
97 shouldBeEqualToString('message', 'changed');
98 shouldBeTrue('radio1.checked');
102 eventSender
.keyDown(' ');
103 shouldBeEqualToString('message', '');
104 shouldBeTrue('radio1.checked');
107 radio2
.checked
= false;
109 eventSender
.keyDown(' ');
110 shouldBeEqualToString('message', 'clicked');
111 shouldBeFalse('radio2.checked');
113 debug('Updating |value| in click handler:');
116 shouldBeEqualToString('message', 'changed');