toolkit/content/tests/chrome/test_popup_recreate.xul

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:d0f7b4a32764
1 <?xml version="1.0"?>
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
4
5 <window title="Popup Recreate Test"
6 onload="setTimeout(init, 0)"
7 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
8
9 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
11
12 <!--
13 This is a test for bug 388361.
14
15 This test checks that a menulist's popup is properly created and sized when
16 the popup node is removed and another added in its place.
17
18 -->
19
20 <script>
21 <![CDATA[
22 SimpleTest.waitForExplicitFinish();
23
24 var gState = "before";
25
26 function init()
27 {
28 document.getElementById("menulist").open = true;
29 }
30
31 function recreate()
32 {
33 if (gState == "before") {
34 var element = document.getElementById("menulist");
35 while (element.hasChildNodes())
36 element.removeChild(element.firstChild);
37 element.appendItem("Cat");
38 gState = "after";
39 document.getElementById("menulist").open = true;
40 }
41 else {
42 SimpleTest.finish();
43 }
44 }
45
46 function checkSize()
47 {
48 var menulist = document.getElementById("menulist");
49 var menurect = menulist.getBoundingClientRect();
50 var popuprect = menulist.menupopup.getBoundingClientRect();
51
52 ok(Math.round(menurect.left) == Math.round(popuprect.left) &&
53 Math.round(menurect.right) == Math.round(popuprect.right) &&
54 Math.round(popuprect.right) - Math.round(popuprect.left) > 0,
55 "height " + gState)
56 document.getElementById("menulist").open = false;
57 }
58 ]]>
59 </script>
60
61 <hbox>
62 <menulist id="menulist" onpopupshown="checkSize();" onpopuphidden="recreate();">
63 <menupopup>
64 <menuitem label="Cat"/>
65 </menupopup>
66 </menulist>
67 </hbox>
68
69 <body xmlns="http://www.w3.org/1999/xhtml">
70 <p id="display">
71 </p>
72 <div id="content" style="display: none">
73 </div>
74 <pre id="test">
75 </pre>
76 </body>
77
78 </window>

mercurial