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