toolkit/content/tests/chrome/test_popup_recreate.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/content/tests/chrome/test_popup_recreate.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,78 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
     1.7 +
     1.8 +<window title="Popup Recreate Test"
     1.9 +  onload="setTimeout(init, 0)"
    1.10 +  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    1.11 +
    1.12 +  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>      
    1.13 +  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>      
    1.14 +
    1.15 +<!--
    1.16 +  This is a test for bug 388361.
    1.17 +
    1.18 +  This test checks that a menulist's popup is properly created and sized when
    1.19 +  the popup node is removed and another added in its place.
    1.20 +
    1.21 +  -->
    1.22 +
    1.23 +<script>
    1.24 +<![CDATA[
    1.25 +SimpleTest.waitForExplicitFinish();
    1.26 +
    1.27 +var gState = "before";
    1.28 +
    1.29 +function init()
    1.30 +{
    1.31 +  document.getElementById("menulist").open = true;
    1.32 +}
    1.33 +
    1.34 +function recreate()
    1.35 +{
    1.36 +  if (gState == "before") {
    1.37 +    var element = document.getElementById("menulist");
    1.38 +    while (element.hasChildNodes())
    1.39 +      element.removeChild(element.firstChild);
    1.40 +    element.appendItem("Cat");
    1.41 +    gState = "after";
    1.42 +    document.getElementById("menulist").open = true;
    1.43 +  }
    1.44 +  else {
    1.45 +    SimpleTest.finish();
    1.46 +  }
    1.47 +}
    1.48 +
    1.49 +function checkSize()
    1.50 +{
    1.51 +  var menulist = document.getElementById("menulist");
    1.52 +  var menurect = menulist.getBoundingClientRect();
    1.53 +  var popuprect = menulist.menupopup.getBoundingClientRect();
    1.54 +
    1.55 +  ok(Math.round(menurect.left) == Math.round(popuprect.left) &&
    1.56 +     Math.round(menurect.right) == Math.round(popuprect.right) &&
    1.57 +     Math.round(popuprect.right) - Math.round(popuprect.left) > 0,
    1.58 +     "height " + gState)
    1.59 +  document.getElementById("menulist").open = false;
    1.60 +}
    1.61 +]]>
    1.62 +</script>
    1.63 +
    1.64 +<hbox>
    1.65 +  <menulist id="menulist" onpopupshown="checkSize();" onpopuphidden="recreate();">
    1.66 +    <menupopup>
    1.67 +      <menuitem label="Cat"/>
    1.68 +    </menupopup>
    1.69 +  </menulist>
    1.70 +</hbox>
    1.71 +
    1.72 +<body xmlns="http://www.w3.org/1999/xhtml">
    1.73 +<p id="display">
    1.74 +</p>
    1.75 +<div id="content" style="display: none">
    1.76 +</div>
    1.77 +<pre id="test">
    1.78 +</pre>
    1.79 +</body>
    1.80 +
    1.81 +</window>

mercurial