PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/toolkit/content/tests/chrome/test_popup_recreate.xul

http://github.com/zpao/v8monkey
Unknown | 80 lines | 66 code | 14 blank | 0 comment | 0 complexity | 3722521e6d7805cac317ded2b81c26c2 MD5 | raw file
 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:html="http://www.w3.org/1999/xhtml"
 8  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 9
10  <title>Popup Recreate Test</title>
11  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>      
12  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>      
13
14<!--
15  This is a test for bug 388361.
16
17  This test checks that a menulist's popup is properly created and sized when
18  the popup node is removed and another added in its place.
19
20  -->
21
22<script>
23<![CDATA[
24SimpleTest.waitForExplicitFinish();
25
26var gState = "before";
27
28function init()
29{
30  document.getElementById("menulist").open = true;
31}
32
33function recreate()
34{
35  if (gState == "before") {
36    var element = document.getElementById("menulist");
37    while (element.hasChildNodes())
38      element.removeChild(element.firstChild);
39    element.appendItem("Cat");
40    gState = "after";
41    document.getElementById("menulist").open = true;
42  }
43  else {
44    SimpleTest.finish();
45  }
46}
47
48function checkSize()
49{
50  var menulist = document.getElementById("menulist");
51  var menurect = menulist.getBoundingClientRect();
52  var popuprect = menulist.menupopup.getBoundingClientRect();
53
54  ok(Math.round(menurect.left) == Math.round(popuprect.left) &&
55     Math.round(menurect.right) == Math.round(popuprect.right) &&
56     Math.round(popuprect.right) - Math.round(popuprect.left) > 0,
57     "height " + gState)
58  document.getElementById("menulist").open = false;
59}
60]]>
61</script>
62
63<hbox>
64  <menulist id="menulist" onpopupshown="checkSize();" onpopuphidden="recreate();">
65    <menupopup>
66      <menuitem label="Cat"/>
67    </menupopup>
68  </menulist>
69</hbox>
70
71<body xmlns="http://www.w3.org/1999/xhtml">
72<p id="display">
73</p>
74<div id="content" style="display: none">
75</div>
76<pre id="test">
77</pre>
78</body>
79
80</window>