browser/base/content/test/general/browser_tab_dragdrop2_frame1.xul

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:9512febc0e29
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 Widget Test for panels
6 -->
7 <window title="Titlebar" width="200" height="200"
8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
9 <script type="application/javascript"
10 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
11 <script type="application/javascript"
12 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
13
14 <tree id="tree" seltype="single" width="100" height="100">
15 <treecols>
16 <treecol flex="1"/>
17 <treecol flex="1"/>
18 </treecols>
19 <treechildren id="treechildren">
20 <treeitem><treerow><treecell label="One"/><treecell label="Two"/></treerow></treeitem>
21 <treeitem><treerow><treecell label="One"/><treecell label="Two"/></treerow></treeitem>
22 <treeitem><treerow><treecell label="One"/><treecell label="Two"/></treerow></treeitem>
23 <treeitem><treerow><treecell label="One"/><treecell label="Two"/></treerow></treeitem>
24 <treeitem><treerow><treecell label="One"/><treecell label="Two"/></treerow></treeitem>
25 <treeitem><treerow><treecell label="One"/><treecell label="Two"/></treerow></treeitem>
26 </treechildren>
27 </tree>
28
29
30 <!-- test results are displayed in the html:body -->
31 <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
32
33 <!-- test code goes here -->
34 <script type="application/javascript"><![CDATA[
35
36 SimpleTest.waitForExplicitFinish();
37
38 var currentTest = null;
39
40 var i = 0;
41 var my_debug = false;
42 function test_panels()
43 {
44 checkTreeCoords();
45
46 addEventListener("popupshown", popupShown, false);
47 addEventListener("popuphidden", nextTest, false);
48 return nextTest();
49 }
50
51 function nextTest()
52 {
53 ok(true,"popuphidden " + i)
54 if (i == tests.length) {
55 return i;
56 }
57
58 currentTest = tests[i];
59 var panel = createPanel(currentTest.attrs);
60 currentTest.test(panel);
61 return i;
62 }
63
64 var waitSteps = 0;
65 function popupShown(event)
66 {
67 var panel = event.target;
68 if (waitSteps > 0 && navigator.platform.indexOf("Linux") >= 0 &&
69 panel.boxObject.screenY == 210) {
70 waitSteps--;
71 setTimeout(popupShown, 10, event);
72 return;
73 }
74 ++i;
75
76 currentTest.result(currentTest.testname + " ", panel);
77 panel.hidePopup();
78 }
79
80 function createPanel(attrs)
81 {
82 var panel = document.createElement("panel");
83 for (var a in attrs) {
84 panel.setAttribute(a, attrs[a]);
85 }
86
87 var button = document.createElement("button");
88 panel.appendChild(button);
89 button.label = "OK";
90 button.width = 120;
91 button.height = 40;
92 button.setAttribute("style", "-moz-appearance: none; border: 0; margin: 0;");
93 panel.setAttribute("style", "-moz-appearance: none; border: 0; margin: 0;");
94 return document.documentElement.appendChild(panel);
95 }
96
97 function checkTreeCoords()
98 {
99 var tree = $("tree");
100 var treechildren = $("treechildren");
101 tree.currentIndex = 0;
102 tree.treeBoxObject.scrollToRow(0);
103 synthesizeMouse(treechildren, 10, tree.treeBoxObject.rowHeight + 2, { });
104
105 tree.treeBoxObject.scrollToRow(2);
106 synthesizeMouse(treechildren, 10, tree.treeBoxObject.rowHeight + 2, { });
107 }
108
109 var tests = [
110 {
111 testname: "normal panel",
112 attrs: { },
113 test: function(panel) {
114 panel.openPopupAtScreen(200, 210);
115 },
116 result: function(testname, panel) {
117 if (my_debug) alert(testname);
118 var panelrect = panel.getBoundingClientRect();
119 }
120 },
121 {
122 // only noautohide panels support titlebars, so one shouldn't be shown here
123 testname: "autohide panel with titlebar",
124 attrs: { titlebar: "normal" },
125 test: function(panel) {
126 panel.openPopupAtScreen(200, 210);
127 },
128 result: function(testname, panel) {
129 if (my_debug) alert(testname);
130 var panelrect = panel.getBoundingClientRect();
131 }
132 },
133 {
134 testname: "noautohide panel with titlebar",
135 attrs: { noautohide: true, titlebar: "normal" },
136 test: function(panel) {
137 waitSteps = 25;
138 panel.openPopupAtScreen(200, 210);
139 },
140 result: function(testname, panel) {
141 if (my_debug) alert(testname);
142 var panelrect = panel.getBoundingClientRect();
143
144 var gotMouseEvent = false;
145 function mouseMoved(event)
146 {
147 gotMouseEvent = true;
148 }
149
150 panel.addEventListener("mousemove", mouseMoved, true);
151 synthesizeMouse(panel, 10, 10, { type: "mousemove" });
152 panel.removeEventListener("mousemove", mouseMoved, true);
153
154 var tree = $("tree");
155 tree.currentIndex = 0;
156 panel.appendChild(tree);
157 checkTreeCoords();
158 }
159 }
160 ];
161
162 SimpleTest.waitForFocus(test_panels);
163
164 ]]>
165 </script>
166
167 </window>

mercurial