/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. <window title="Popup Recreate Test"
  5. onload="setTimeout(init, 0)"
  6. xmlns:html="http://www.w3.org/1999/xhtml"
  7. xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  8. <title>Popup Recreate Test</title>
  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. This is a test for bug 388361.
  13. This test checks that a menulist's popup is properly created and sized when
  14. the popup node is removed and another added in its place.
  15. -->
  16. <script>
  17. <![CDATA[
  18. SimpleTest.waitForExplicitFinish();
  19. var gState = "before";
  20. function init()
  21. {
  22. document.getElementById("menulist").open = true;
  23. }
  24. function recreate()
  25. {
  26. if (gState == "before") {
  27. var element = document.getElementById("menulist");
  28. while (element.hasChildNodes())
  29. element.removeChild(element.firstChild);
  30. element.appendItem("Cat");
  31. gState = "after";
  32. document.getElementById("menulist").open = true;
  33. }
  34. else {
  35. SimpleTest.finish();
  36. }
  37. }
  38. function checkSize()
  39. {
  40. var menulist = document.getElementById("menulist");
  41. var menurect = menulist.getBoundingClientRect();
  42. var popuprect = menulist.menupopup.getBoundingClientRect();
  43. ok(Math.round(menurect.left) == Math.round(popuprect.left) &&
  44. Math.round(menurect.right) == Math.round(popuprect.right) &&
  45. Math.round(popuprect.right) - Math.round(popuprect.left) > 0,
  46. "height " + gState)
  47. document.getElementById("menulist").open = false;
  48. }
  49. ]]>
  50. </script>
  51. <hbox>
  52. <menulist id="menulist" onpopupshown="checkSize();" onpopuphidden="recreate();">
  53. <menupopup>
  54. <menuitem label="Cat"/>
  55. </menupopup>
  56. </menulist>
  57. </hbox>
  58. <body xmlns="http://www.w3.org/1999/xhtml">
  59. <p id="display">
  60. </p>
  61. <div id="content" style="display: none">
  62. </div>
  63. <pre id="test">
  64. </pre>
  65. </body>
  66. </window>