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