1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/events/test/test_bug635465.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,90 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=635465 1.8 +--> 1.9 +<head> 1.10 + <meta charset="utf-8"> 1.11 + <title>Test for Bug 635465</title> 1.12 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.13 + <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script> 1.14 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.15 + <style type="text/css"> 1.16 + #item { 1.17 + position: relative; 1.18 + } 1.19 + .s-menu-section-submenu { 1.20 + position: absolute; 1.21 + display: none; 1.22 + } 1.23 + .open .s-menu-section-submenu { 1.24 + display: block; 1.25 + } 1.26 +</style> 1.27 +</head> 1.28 +<body> 1.29 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=635465">Mozilla Bug 635465</a> 1.30 +<div id="display"> 1.31 + <div class="item" id="item" 1.32 + onmouseover="showSubmenu(event)" onmouseout="hideSubmenu(event)"> 1.33 + <a href="#" id="firsthover">Hover me</a> 1.34 + <div class="s-menu-section-submenu" id="menu"> 1.35 + <a href="#" id="secondhover">Now hover me</a> 1.36 + </div> 1.37 + </div> 1.38 +</div> 1.39 +<div id="content" style="display: none"> 1.40 + 1.41 +</div> 1.42 +<pre id="test"> 1.43 +<script type="application/javascript;version=1.8"> 1.44 + 1.45 +/** Test for Bug 635465 **/ 1.46 +function showSubmenu(event) { 1.47 + var item = document.getElementById('item'); 1.48 + 1.49 + var width = item.offsetWidth; // IT WORKS IF YOU REMOVE THIS LINE 1.50 + 1.51 + item.className='open'; 1.52 +} 1.53 + 1.54 +function hideSubmenu(event) { 1.55 + document.getElementById('item').className=''; 1.56 +} 1.57 + 1.58 +SimpleTest.waitForExplicitFinish(); 1.59 + 1.60 +function executeTests() { 1.61 + // First flush out layout of firsthover 1.62 + ok($("firsthover").getBoundingClientRect().height > 0, true, 1.63 + "Should have a nonzero height before hover"); 1.64 + 1.65 + // Now trigger a mouseover on firsthover 1.66 + synthesizeMouseAtCenter($("firsthover"), { type: "mousemove" }); 1.67 + 1.68 + ok($("secondhover").getBoundingClientRect().height > 0, true, 1.69 + "Should have a nonzero height for submenu after hover"); 1.70 + 1.71 + // Now determine where secondhover is hanging out 1.72 + var rect = $("secondhover").getBoundingClientRect(); 1.73 + synthesizeMouseAtCenter($("secondhover"), { type: "mousemove" }); 1.74 + 1.75 + // And another mouseover one pixel to the right of where the center used to be 1.76 + synthesizeMouseAtPoint(rect.left + rect.width/2 + 1, 1.77 + rect.top + rect.height/2, 1.78 + { type: "mousemove" }); 1.79 + 1.80 + ok($("secondhover").getBoundingClientRect().height > 0, true, 1.81 + "Should have a nonzero height for submenu after second hover"); 1.82 + 1.83 + // And check computed display of the menu 1.84 + is(getComputedStyle($("menu"), "").display, "block", "Should have block display"); 1.85 + 1.86 + SimpleTest.finish(); 1.87 +} 1.88 + 1.89 +SimpleTest.waitForFocus(executeTests); 1.90 +</script> 1.91 +</pre> 1.92 +</body> 1.93 +</html>