layout/xul/test/test_resizer.xul

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

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

mercurial