1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/xul/test/test_resizer.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,94 @@ 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 <resizer> tests 1.9 +--> 1.10 +<window title="XUL resizer 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 + SimpleTest.ignoreAllUncaughtExceptions(); 1.23 + 1.24 + function openPopup() 1.25 + { 1.26 + document.getElementById("panel"). 1.27 + openPopupAtScreen(Math.round(window.mozInnerScreenX) + window.innerWidth - 130, 1.28 + Math.round(window.mozInnerScreenY) + window.innerHeight - 130); 1.29 + } 1.30 + 1.31 + var step = 0; 1.32 + function popupShown(event) 1.33 + { 1.34 + if (step == 0) { 1.35 + // check to make sure that the popup cannot be resized past the edges of 1.36 + // the content area 1.37 + var resizerrect = document.getElementById("resizer").getBoundingClientRect(); 1.38 + synthesizeMouse(document.documentElement, resizerrect.left + 5, resizerrect.top + 5, { type:"mousedown" }); 1.39 + synthesizeMouse(document.documentElement, resizerrect.left + 2000, resizerrect.top + 2000, { type:"mousemove" }); 1.40 + 1.41 + // allow a one pixel variance as rounding is always done to the inside 1.42 + // of a rectangle. 1.43 + var popuprect = document.getElementById("panel").getBoundingClientRect(); 1.44 + ok(Math.round(popuprect.right) == window.innerWidth || 1.45 + Math.round(popuprect.right) == window.innerWidth - 1, 1.46 + "resized to content edge width"); 1.47 + ok(Math.round(popuprect.bottom) == window.innerHeight || 1.48 + Math.round(popuprect.bottom) == window.innerHeight - 1, 1.49 + "resized to content edge height"); 1.50 + 1.51 + resizerrect = document.getElementById("resizer").getBoundingClientRect(); 1.52 + synthesizeMouse(document.documentElement, resizerrect.left + 5, resizerrect.top + 5, { type:"mouseup" }); 1.53 + } 1.54 + else { 1.55 + // the popup is opened twice. Make sure that for the second time, the 1.56 + // resized popup opens in the same direction as there should still be 1.57 + // room for it 1.58 + var popuprect = document.getElementById("panel").getBoundingClientRect(); 1.59 + is(Math.round(popuprect.left), window.innerWidth - 130, "reopen popup left"); 1.60 + is(Math.round(popuprect.top), window.innerHeight - 130, "reopen popup top"); 1.61 + } 1.62 + 1.63 + event.target.hidePopup(); 1.64 + } 1.65 + 1.66 + function doResizerWindowTests() { 1.67 + step++; 1.68 + if (step == 1) { 1.69 + openPopup(); 1.70 + return; 1.71 + } 1.72 + 1.73 + if (/Mac/.test(navigator.platform)) { 1.74 + window.open("window_resizer.xul", "_blank", "left=200,top=200,outerWidth=300,outerHeight=300,chrome"); 1.75 + } 1.76 + else { 1.77 + // Skip window_resizer.xul tests. 1.78 + todo(false, "We can't test GTK and Windows native drag resizing implementations."); 1.79 + // Run window_resizer_element.xul test only. 1.80 + lastResizerTest(); 1.81 + } 1.82 + } 1.83 + 1.84 + function lastResizerTest() 1.85 + { 1.86 + window.open("window_resizer_element.xul", "_blank", "left=200,top=200,outerWidth=300,outerHeight=300,chrome"); 1.87 + } 1.88 + 1.89 + SimpleTest.waitForFocus(openPopup); 1.90 + ]]></script> 1.91 + 1.92 +<panel id="panel" onpopupshown="popupShown(event)" onpopuphidden="doResizerWindowTests()"> 1.93 + <resizer id="resizer" dir="bottomend" width="16" height="16"/> 1.94 + <hbox width="50" height="50" flex="1"/> 1.95 +</panel> 1.96 + 1.97 +</window>