Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
1 <?xml version="1.0"?>
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
3 <?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
4 <?xml-stylesheet href="data:text/css, hbox { border: 1px solid red; } vbox { border: 1px solid green }" type="text/css"?>
5 <!--
6 XUL <splitter> collapsing tests
7 -->
8 <window title="XUL splitter collapsing tests"
9 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
10 orient="horizontal">
11 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"/>
12 <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"/>
14 <!-- test results are displayed in the html:body -->
15 <body xmlns="http://www.w3.org/1999/xhtml">
16 </body>
18 <!-- test code goes here -->
19 <script type="application/javascript"><![CDATA[
20 SimpleTest.waitForExplicitFinish();
22 function dragSplitter(offsetX, callback) {
23 var splitterWidth = splitter.boxObject.width;
24 synthesizeMouse(splitter, splitterWidth / 2, 2, {type: "mousedown"});
25 synthesizeMouse(splitter, splitterWidth / 2, 1, {type: "mousemove"});
26 SimpleTest.executeSoon(function() {
27 SimpleTest.is(splitter.getAttribute("state"), "dragging", "The splitter should be dragged");
28 synthesizeMouse(splitter, offsetX, 1, {type: "mousemove"});
29 synthesizeMouse(splitter, offsetX, 1, {type: "mouseup"});
30 SimpleTest.executeSoon(callback);
31 });
32 }
34 function shouldBeCollapsed(where) {
35 SimpleTest.is(splitter.getAttribute("state"), "collapsed", "The splitter should be collapsed");
36 SimpleTest.is(splitter.getAttribute("substate"), where, "The splitter should be collapsed " + where);
37 }
39 function shouldNotBeCollapsed() {
40 SimpleTest.is(splitter.getAttribute("state"), "", "The splitter should not be collapsed");
41 }
43 function runPass(rightCollapsed, leftCollapsed, callback) {
44 var containerWidth = container.boxObject.width;
45 var isRTL = getComputedStyle(splitter, null).direction == "rtl";
46 dragSplitter(containerWidth, function() {
47 if (rightCollapsed) {
48 shouldBeCollapsed(isRTL ? "before" : "after");
49 } else {
50 shouldNotBeCollapsed();
51 }
52 dragSplitter(-containerWidth * 2, function() {
53 if (leftCollapsed) {
54 shouldBeCollapsed(isRTL ? "after" : "before");
55 } else {
56 shouldNotBeCollapsed();
57 }
58 dragSplitter(containerWidth / 2, function() {
59 // the splitter should never be collapsed in the middle
60 shouldNotBeCollapsed();
61 callback();
62 });
63 });
64 });
65 }
67 var splitter, container;
68 function runLTRTests(callback) {
69 splitter = document.getElementById("ltr-splitter");
70 container = splitter.parentNode;
71 splitter.setAttribute("collapse", "before");
72 runPass(false, true, function() {
73 splitter.setAttribute("collapse", "after");
74 runPass(true, false, function() {
75 splitter.setAttribute("collapse", "both");
76 runPass(true, true, callback);
77 });
78 });
79 }
81 function runRTLTests(callback) {
82 splitter = document.getElementById("rtl-splitter");
83 container = splitter.parentNode;
84 splitter.setAttribute("collapse", "before");
85 runPass(true, false, function() {
86 splitter.setAttribute("collapse", "after");
87 runPass(false, true, function() {
88 splitter.setAttribute("collapse", "both");
89 runPass(true, true, callback);
90 });
91 });
92 }
94 function runTests() {
95 runLTRTests(function() {
96 runRTLTests(function() {
97 SimpleTest.finish();
98 });
99 });
100 }
102 addLoadEvent(function() {SimpleTest.executeSoon(runTests);});
103 ]]></script>
105 <hbox style="max-width: 200px; height: 300px; direction: ltr;">
106 <vbox style="width: 100px; height: 300px;" flex="1"/>
107 <splitter id="ltr-splitter"/>
108 <vbox style="width: 100px; height: 300px;" flex="1"/>
109 </hbox>
111 <hbox style="max-width: 200px; height: 300px; direction: rtl;">
112 <vbox style="width: 100px; height: 300px;" flex="1"/>
113 <splitter id="rtl-splitter"/>
114 <vbox style="width: 100px; height: 300px;" flex="1"/>
115 </hbox>
117 </window>