test_resizer.xul 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. XUL <resizer> tests
  6. -->
  7. <window title="XUL resizer tests"
  8. xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  9. <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
  10. <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
  11. <!-- test results are displayed in the html:body -->
  12. <body xmlns="http://www.w3.org/1999/xhtml">
  13. </body>
  14. <!-- test code goes here -->
  15. <script type="application/javascript"><![CDATA[
  16. SimpleTest.waitForExplicitFinish();
  17. SimpleTest.ignoreAllUncaughtExceptions();
  18. function openPopup()
  19. {
  20. document.getElementById("panel").
  21. openPopupAtScreen(Math.round(window.mozInnerScreenX) + window.innerWidth - 130,
  22. Math.round(window.mozInnerScreenY) + window.innerHeight - 130);
  23. }
  24. var step = 0;
  25. function popupShown(event)
  26. {
  27. if (step == 0) {
  28. // check to make sure that the popup cannot be resized past the edges of
  29. // the content area
  30. var resizerrect = document.getElementById("resizer").getBoundingClientRect();
  31. synthesizeMouse(document.documentElement, resizerrect.left + 5, resizerrect.top + 5, { type:"mousedown" });
  32. synthesizeMouse(document.documentElement, resizerrect.left + 2000, resizerrect.top + 2000, { type:"mousemove" });
  33. // allow a one pixel variance as rounding is always done to the inside
  34. // of a rectangle.
  35. var popuprect = document.getElementById("panel").getBoundingClientRect();
  36. ok(Math.round(popuprect.right) == window.innerWidth ||
  37. Math.round(popuprect.right) == window.innerWidth - 1,
  38. "resized to content edge width");
  39. ok(Math.round(popuprect.bottom) == window.innerHeight ||
  40. Math.round(popuprect.bottom) == window.innerHeight - 1,
  41. "resized to content edge height");
  42. resizerrect = document.getElementById("resizer").getBoundingClientRect();
  43. synthesizeMouse(document.documentElement, resizerrect.left + 5, resizerrect.top + 5, { type:"mouseup" });
  44. }
  45. else {
  46. // the popup is opened twice. Make sure that for the second time, the
  47. // resized popup opens in the same direction as there should still be
  48. // room for it
  49. var popuprect = document.getElementById("panel").getBoundingClientRect();
  50. is(Math.round(popuprect.left), window.innerWidth - 130, "reopen popup left");
  51. is(Math.round(popuprect.top), window.innerHeight - 130, "reopen popup top");
  52. }
  53. event.target.hidePopup();
  54. }
  55. function doResizerWindowTests() {
  56. step++;
  57. if (step == 1) {
  58. openPopup();
  59. return;
  60. }
  61. if (/Mac/.test(navigator.platform)) {
  62. window.open("window_resizer.xul", "_blank", "left=200,top=200,outerWidth=300,outerHeight=300,chrome");
  63. }
  64. else {
  65. // Skip window_resizer.xul tests.
  66. todo(false, "We can't test GTK and Windows native drag resizing implementations.");
  67. // Run window_resizer_element.xul test only.
  68. lastResizerTest();
  69. }
  70. }
  71. function lastResizerTest()
  72. {
  73. window.open("window_resizer_element.xul", "_blank", "left=200,top=200,outerWidth=300,outerHeight=300,chrome");
  74. }
  75. SimpleTest.waitForFocus(openPopup);
  76. ]]></script>
  77. <panel id="panel" onpopupshown="popupShown(event)" onpopuphidden="doResizerWindowTests()">
  78. <resizer id="resizer" dir="bottomend" width="16" height="16"/>
  79. <hbox width="50" height="50" flex="1"/>
  80. </panel>
  81. </window>