layout/xul/test/test_popupSizeTo.xul

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     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 type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
    10   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
    12   <!-- test results are displayed in the html:body -->
    13   <body xmlns="http://www.w3.org/1999/xhtml">
    14   </body>
    16   <!-- test code goes here -->
    17   <script type="application/javascript"><![CDATA[
    18     SimpleTest.waitForExplicitFinish();
    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     }
    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");
    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     }
    47     SimpleTest.waitForFocus(openPopup);
    48    ]]></script>
    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>
    55 </window>

mercurial