tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_popupSizeTo.xhtml (2065B)


      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 Panel sizeTo tests
      6 -->
      7 <window title="XUL Panel sizeTo tests"
      8        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
      9  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
     10  <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
     11 
     12  <!-- test results are displayed in the html:body -->
     13  <body xmlns="http://www.w3.org/1999/xhtml">
     14  </body>
     15 
     16  <!-- test code goes here -->
     17  <script type="application/javascript"><![CDATA[
     18    SimpleTest.waitForExplicitFinish();
     19 
     20    function openPopup()
     21    {
     22      document.getElementById("panel").
     23        openPopupAtScreen(Math.round(window.mozInnerScreenX) + window.innerWidth - 130,
     24                          Math.round(window.mozInnerScreenY) + window.innerHeight - 130);
     25    }
     26 
     27    function sizeAndCheck(width, height) {
     28      var panel = document.getElementById("panel");
     29      panel.sizeTo(width, height);
     30      is(panel.getBoundingClientRect().width, width, "width is correct");
     31      is(panel.getBoundingClientRect().height, height, "height is correct");
     32 
     33    }
     34    function popupShown(event)
     35    {
     36      var panel = document.getElementById("panel");
     37      var bcr = panel.getBoundingClientRect();
     38      // resize to 10px bigger in both dimensions.
     39      sizeAndCheck(bcr.width+10, bcr.height+10);
     40      // Same width, different height (based on *new* size from last sizeAndCheck)
     41      sizeAndCheck(bcr.width+10, bcr.height);
     42      // Same height, different width (also based on *new* size from last sizeAndCheck)
     43      sizeAndCheck(bcr.width, bcr.height);
     44      event.target.hidePopup();
     45    }
     46 
     47    SimpleTest.waitForFocus(openPopup);
     48   ]]></script>
     49 
     50 <panel id="panel" onpopupshown="popupShown(event)" onpopuphidden="SimpleTest.finish()">
     51  <resizer id="resizer" dir="bottomend" width="16" height="16"/>
     52  <hbox width="50" height="50" flex="1"/>
     53 </panel>
     54 
     55 </window>