OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE HTML> |
| 2 |
| 3 <script src="../../resources/js-test.js"></script> |
| 4 |
| 5 <body> |
| 6 <input type="checkbox" id="checkbox-btn1" onclick="doClickAction(event)" onchang
e="doChangeAction(event)"/> |
| 7 <input type="checkbox" id="checkbox-btn2" onclick="doClickAction(event); event.p
reventDefault()" onchange="doChangeAction(event)"/> |
| 8 <input type="radio" id="radio-btn1" onclick="doClickAction(event)" onchange="doC
hangeAction(event)"/> |
| 9 <input type="radio" id="radio-btn2" onclick="doClickAction(event); event.prevent
Default()" onchange="doChangeAction(event)"/> |
| 10 <script> |
| 11 description('Tests the order of onclick and onchange'); |
| 12 var message = ''; |
| 13 |
| 14 function doClickAction(e) |
| 15 { |
| 16 shouldBeEqualToString('message', ''); |
| 17 message = 'clicked'; |
| 18 } |
| 19 |
| 20 function doChangeAction(e) |
| 21 { |
| 22 shouldBeEqualToString('message', 'clicked'); |
| 23 message = 'checked'; |
| 24 } |
| 25 |
| 26 var checkbox1 = document.getElementById('checkbox-btn1'); |
| 27 var checkbox2 = document.getElementById('checkbox-btn2'); |
| 28 var radio1 = document.getElementById('radio-btn1'); |
| 29 var radio2 = document.getElementById('radio-btn2'); |
| 30 |
| 31 message = ''; |
| 32 checkbox1.click(); |
| 33 shouldBeEqualToString('message', 'checked'); |
| 34 shouldBeTrue('checkbox1.checked'); |
| 35 |
| 36 message = ''; |
| 37 checkbox2.click(); |
| 38 shouldBeEqualToString('message', 'clicked'); |
| 39 shouldBeFalse('checkbox2.checked'); |
| 40 |
| 41 message = ''; |
| 42 checkbox1.checked = false; |
| 43 checkbox1.focus(); |
| 44 eventSender.keyDown(' '); |
| 45 shouldBeEqualToString('message', 'checked'); |
| 46 shouldBeTrue('checkbox1.checked'); |
| 47 |
| 48 message = ''; |
| 49 checkbox2.checked = false; |
| 50 checkbox2.focus(); |
| 51 eventSender.keyDown(' '); |
| 52 shouldBeEqualToString('message', 'clicked'); |
| 53 shouldBeFalse('checkbox2.checked'); |
| 54 |
| 55 message = ''; |
| 56 radio1.click(); |
| 57 shouldBeEqualToString('message', 'checked'); |
| 58 shouldBeTrue('radio1.checked'); |
| 59 |
| 60 message = ''; |
| 61 radio2.click(); |
| 62 shouldBeEqualToString('message', 'clicked'); |
| 63 shouldBeFalse('radio2.checked'); |
| 64 |
| 65 message = ''; |
| 66 radio1.checked = false; |
| 67 radio1.focus(); |
| 68 eventSender.keyDown(' '); |
| 69 shouldBeEqualToString('message', 'checked'); |
| 70 shouldBeTrue('radio1.checked'); |
| 71 |
| 72 message = ''; |
| 73 radio2.checked = false; |
| 74 radio2.focus(); |
| 75 eventSender.keyDown(' '); |
| 76 shouldBeEqualToString('message', 'clicked'); |
| 77 shouldBeFalse('radio2.checked'); |
| 78 |
| 79 </script> |
| 80 </body> |
OLD | NEW |