Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
10 <script type="application/javascript" 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">
38 </div>
39 <pre id="test">
40 <script type="application/javascript;version=1.8">
42 /** Test for Bug 635465 **/
43 function showSubmenu(event) {
44 var item = document.getElementById('item');
46 var width = item.offsetWidth; // IT WORKS IF YOU REMOVE THIS LINE
48 item.className='open';
49 }
51 function hideSubmenu(event) {
52 document.getElementById('item').className='';
53 }
55 SimpleTest.waitForExplicitFinish();
57 function executeTests() {
58 // First flush out layout of firsthover
59 ok($("firsthover").getBoundingClientRect().height > 0, true,
60 "Should have a nonzero height before hover");
62 // Now trigger a mouseover on firsthover
63 synthesizeMouseAtCenter($("firsthover"), { type: "mousemove" });
65 ok($("secondhover").getBoundingClientRect().height > 0, true,
66 "Should have a nonzero height for submenu after hover");
68 // Now determine where secondhover is hanging out
69 var rect = $("secondhover").getBoundingClientRect();
70 synthesizeMouseAtCenter($("secondhover"), { type: "mousemove" });
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" });
77 ok($("secondhover").getBoundingClientRect().height > 0, true,
78 "Should have a nonzero height for submenu after second hover");
80 // And check computed display of the menu
81 is(getComputedStyle($("menu"), "").display, "block", "Should have block display");
83 SimpleTest.finish();
84 }
86 SimpleTest.waitForFocus(executeTests);
87 </script>
88 </pre>
89 </body>
90 </html>