layout/xul/test/test_popupSizeTo.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/xul/test/test_popupSizeTo.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,55 @@
     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 +XUL Panel sizeTo tests
     1.9 +-->
    1.10 +<window title="XUL Panel sizeTo tests"
    1.11 +        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    1.12 +  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
    1.13 +  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
    1.14 +
    1.15 +  <!-- test results are displayed in the html:body -->
    1.16 +  <body xmlns="http://www.w3.org/1999/xhtml">
    1.17 +  </body>
    1.18 +
    1.19 +  <!-- test code goes here -->
    1.20 +  <script type="application/javascript"><![CDATA[
    1.21 +    SimpleTest.waitForExplicitFinish();
    1.22 +
    1.23 +    function openPopup()
    1.24 +    {
    1.25 +      document.getElementById("panel").
    1.26 +        openPopupAtScreen(Math.round(window.mozInnerScreenX) + window.innerWidth - 130,
    1.27 +                          Math.round(window.mozInnerScreenY) + window.innerHeight - 130);
    1.28 +    }
    1.29 +
    1.30 +    function sizeAndCheck(width, height) {
    1.31 +      var panel = document.getElementById("panel");
    1.32 +      panel.sizeTo(width, height);
    1.33 +      is(panel.getBoundingClientRect().width, width, "width is correct");
    1.34 +      is(panel.getBoundingClientRect().height, height, "height is correct");
    1.35 +
    1.36 +    }
    1.37 +    function popupShown(event)
    1.38 +    {
    1.39 +      var panel = document.getElementById("panel");
    1.40 +      var bcr = panel.getBoundingClientRect();
    1.41 +      // resize to 10px bigger in both dimensions.
    1.42 +      sizeAndCheck(bcr.width+10, bcr.height+10);
    1.43 +      // Same width, different height (based on *new* size from last sizeAndCheck)
    1.44 +      sizeAndCheck(bcr.width+10, bcr.height);
    1.45 +      // Same height, different width (also based on *new* size from last sizeAndCheck)
    1.46 +      sizeAndCheck(bcr.width, bcr.height);
    1.47 +      event.target.hidePopup();
    1.48 +    }
    1.49 +
    1.50 +    SimpleTest.waitForFocus(openPopup);
    1.51 +   ]]></script>
    1.52 +
    1.53 +<panel id="panel" onpopupshown="popupShown(event)" onpopuphidden="SimpleTest.finish()">
    1.54 +  <resizer id="resizer" dir="bottomend" width="16" height="16"/>
    1.55 +  <hbox width="50" height="50" flex="1"/>
    1.56 +</panel>
    1.57 +
    1.58 +</window>

mercurial