test_bug583514.html (1802B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=583514 5 --> 6 <head> 7 <title>Test for Bug 583514</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 10 </head> 11 <body> 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=583514">Mozilla Bug 583514</a> 13 <p id="display"></p> 14 <div id="content"> 15 <input> 16 </div> 17 <pre id="test"> 18 <script type="application/javascript"> 19 20 /** Test for Bug 583514 */ 21 22 var gExpectDivClick = false; 23 var gExpectInputClick = false; 24 25 var div = document.getElementById('content'); 26 var input = document.getElementsByTagName('input')[0]; 27 28 div.addEventListener('click', function() { 29 ok(gExpectDivClick, "click event received on div and expected status was: " + 30 gExpectDivClick); 31 }); 32 33 input.addEventListener('click', function() { 34 ok(gExpectInputClick, "click event received on input and expected status was: " + 35 gExpectInputClick); 36 }); 37 38 SimpleTest.waitForExplicitFinish(); 39 40 SimpleTest.waitForFocus(function() { 41 var body = document.body; 42 43 body.addEventListener('click', function(aEvent) { 44 if (aEvent.target == input) { 45 body.removeEventListener('click', arguments.callee); 46 } 47 48 ok(true, "click event received on body"); 49 50 SimpleTest.executeSoon(function() { 51 isnot(document.activeElement, input, "input shouldn't have been focused"); 52 isnot(document.activeElement, div, "div shouldn't have been focused"); 53 54 if (aEvent.target == input) { 55 SimpleTest.finish(); 56 } else { 57 gExpectDivClick = true; 58 gExpectInputClick = true; 59 input.click(); 60 } 61 }); 62 }); 63 64 gExpectDivClick = true; 65 div.click(); 66 }); 67 68 </script> 69 </pre> 70 </body> 71 </html>