test_bug635465.html (2609B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=635465 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 635465</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <script src="/tests/SimpleTest/EventUtils.js"></script> 11 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 12 <style type="text/css"> 13 #item { 14 position: relative; 15 } 16 .s-menu-section-submenu { 17 position: absolute; 18 display: none; 19 } 20 .open .s-menu-section-submenu { 21 display: block; 22 } 23 </style> 24 </head> 25 <body> 26 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=635465">Mozilla Bug 635465</a> 27 <div id="display"> 28 <div class="item" id="item" 29 onmouseover="showSubmenu(event)" onmouseout="hideSubmenu(event)"> 30 <a href="#" id="firsthover">Hover me</a> 31 <div class="s-menu-section-submenu" id="menu"> 32 <a href="#" id="secondhover">Now hover me</a> 33 </div> 34 </div> 35 </div> 36 <div id="content" style="display: none"> 37 38 </div> 39 <pre id="test"> 40 <script type="application/javascript"> 41 42 /** Test for Bug 635465 */ 43 function showSubmenu(event) { 44 var item = document.getElementById('item'); 45 46 var width = item.offsetWidth; // IT WORKS IF YOU REMOVE THIS LINE 47 48 item.className='open'; 49 } 50 51 function hideSubmenu(event) { 52 document.getElementById('item').className=''; 53 } 54 55 SimpleTest.waitForExplicitFinish(); 56 57 function executeTests() { 58 // First flush out layout of firsthover 59 ok($("firsthover").getBoundingClientRect().height > 0, 60 "Should have a nonzero height before hover"); 61 62 // Now trigger a mouseover on firsthover 63 synthesizeMouseAtCenter($("firsthover"), { type: "mousemove" }); 64 65 ok($("secondhover").getBoundingClientRect().height > 0, 66 "Should have a nonzero height for submenu after hover"); 67 68 // Now determine where secondhover is hanging out 69 var rect = $("secondhover").getBoundingClientRect(); 70 synthesizeMouseAtCenter($("secondhover"), { type: "mousemove" }); 71 72 // And another mouseover one pixel to the right of where the center used to be 73 synthesizeMouseAtPoint(rect.left + rect.width/2 + 1, 74 rect.top + rect.height/2, 75 { type: "mousemove" }); 76 77 ok($("secondhover").getBoundingClientRect().height > 0, 78 "Should have a nonzero height for submenu after second hover"); 79 80 // And check computed display of the menu 81 is(getComputedStyle($("menu"), "").display, "block", "Should have block display"); 82 83 SimpleTest.finish(); 84 } 85 86 SimpleTest.waitForFocus(executeTests); 87 </script> 88 </pre> 89 </body> 90 </html>