test_bug646157.html (2618B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=646157 5 --> 6 <head> 7 <title>Test for Bug 646157</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <script type="application/javascript" src="reflect.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 11 </head> 12 <body> 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=646157">Mozilla Bug 646157</a> 14 <p id="display"></p> 15 <div id="content"> 16 <label id="l1"/><input id="c1" type='checkbox'> 17 <label id="l2"/><input id="c2" type='checkbox'> 18 <label id="l3"/><input id="c3" type='checkbox'> 19 <label id="l4"/><input id="c4" type='checkbox'> 20 <label id="l5"/><input id="c5" type='checkbox'> 21 <label id="l6"/><input id="c6" type='checkbox'> 22 <label id="l7"/><input id="c7" type='checkbox'> 23 <label id="l8"/><input id="c8" type='checkbox'> 24 <label id="l9"/><input id="c9" type='checkbox'> 25 <label id="l10"/><input id="c10" type='checkbox'> 26 </div> 27 <pre id="test"> 28 <script type="application/javascript"> 29 /** Test for Bug 646157 */ 30 31 var expectedClicks = { 32 // [ Direct clicks, bubbled clicks, synthetic clicks] 33 l1: [0, 2, 1], 34 l2: [0, 2, 1], 35 l3: [0, 2, 1], 36 l4: [0, 2, 1], 37 l5: [0, 2, 1], 38 l6: [0, 2, 1], 39 l7: [0, 2, 1], 40 l8: [0, 2, 1], 41 l9: [0, 2, 1], 42 l10:[1, 2, 1], 43 c1: [0, 0, 0], 44 c2: [0, 0, 0], 45 c3: [0, 0, 0], 46 c4: [0, 0, 0], 47 c5: [0, 0, 0], 48 c6: [0, 0, 0], 49 c7: [0, 0, 0], 50 c8: [0, 0, 0], 51 c9: [0, 0, 0], 52 c10:[1, 1, 1] 53 }; 54 55 function clickhandler(e) { 56 if (!e.currentTarget.clickCount) 57 e.currentTarget.clickCount = 1; 58 else 59 e.currentTarget.clickCount++; 60 61 if (e.currentTarget === e.target) 62 e.currentTarget.directClickCount = 1; 63 64 if (e.target != document.getElementById("l10")) { 65 if (!e.currentTarget.synthClickCount) 66 e.currentTarget.synthClickCount = 1; 67 else 68 e.currentTarget.synthClickCount++; 69 } 70 } 71 72 for (var i = 1; i <= 10; i++) { 73 document.getElementById("l" + i).addEventListener('click', clickhandler); 74 document.getElementById("c" + i).addEventListener('click', clickhandler); 75 } 76 77 document.getElementById("l10").click(); 78 79 function check(thing) { 80 var expected = expectedClicks[thing.id]; 81 is(thing.directClickCount || 0, expected[0], "Wrong number of direct clicks"); 82 is(thing.clickCount || 0, expected[1], "Wrong number of clicks"); 83 is(thing.synthClickCount || 0, expected[2], "Wrong number of synthetic clicks"); 84 } 85 86 // Compare them all 87 for (var i = 1; i <= 10; i++) { 88 check(document.getElementById("l" + i)); 89 check(document.getElementById("c" + i)); 90 } 91 92 </script> 93 </pre> 94 </body> 95 </html>