Source code

Revision control

Copy as Markdown

Other Tools

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
<!--
XUL Widget Test for panels
-->
<window title="Titlebar" width="200" height="200"
<tree id="tree" seltype="single" width="100" height="100">
<treecols>
<treecol flex="1"/>
<treecol flex="1"/>
</treecols>
<treechildren id="treechildren">
<treeitem><treerow><treecell label="One"/><treecell label="Two"/></treerow></treeitem>
<treeitem><treerow><treecell label="One"/><treecell label="Two"/></treerow></treeitem>
<treeitem><treerow><treecell label="One"/><treecell label="Two"/></treerow></treeitem>
<treeitem><treerow><treecell label="One"/><treecell label="Two"/></treerow></treeitem>
<treeitem><treerow><treecell label="One"/><treecell label="Two"/></treerow></treeitem>
<treeitem><treerow><treecell label="One"/><treecell label="Two"/></treerow></treeitem>
</treechildren>
</tree>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
<!-- test code goes here -->
<script type="application/javascript"><![CDATA[
SimpleTest.waitForExplicitFinish();
var currentTest = null;
var i, waitSteps;
var my_debug = false;
function test_panels()
{
i = waitSteps = 0;
checkTreeCoords();
addEventListener("popupshown", popupShown, false);
addEventListener("popuphidden", nextTest, false);
return nextTest();
}
function nextTest()
{
ok(true,"popuphidden " + i)
if (i == tests.length) {
let details = {bubbles: true, cancelable: false};
document.dispatchEvent(new CustomEvent("TestsDone", details));
return i;
}
currentTest = tests[i];
var panel = createPanel(currentTest.attrs);
SimpleTest.waitForFocus(() => currentTest.test(panel));
return i;
}
function popupShown(event)
{
var panel = event.target;
if (waitSteps > 0 && navigator.platform.includes("Linux") &&
panel.screenY == 210) {
waitSteps--;
/* eslint-disable mozilla/no-arbitrary-setTimeout */
setTimeout(popupShown, 10, event);
return;
}
++i;
currentTest.result(currentTest.testname + " ", panel);
panel.hidePopup();
}
function createPanel(attrs)
{
var panel = document.createXULElement("panel");
for (var a in attrs) {
panel.setAttribute(a, attrs[a]);
}
var button = document.createXULElement("button");
panel.appendChild(button);
button.label = "OK";
button.setAttribute("style", "-moz-appearance: none; border: 0; margin: 0; height: 40px; width: 120px;");
panel.setAttribute("style", "-moz-appearance: none; border: 0; margin: 0;");
return document.documentElement.appendChild(panel);
}
function checkTreeCoords()
{
var tree = $("tree");
var treechildren = $("treechildren");
tree.currentIndex = 0;
tree.scrollToRow(0);
synthesizeMouse(treechildren, 10, tree.rowHeight + 2, { });
tree.scrollToRow(2);
synthesizeMouse(treechildren, 10, tree.rowHeight + 2, { });
}
var tests = [
{
testname: "normal panel",
attrs: { },
test(panel) {
panel.openPopupAtScreen(200, 210);
},
result(testname, panel) {
if (my_debug) alert(testname);
panel.getBoundingClientRect();
}
},
{
// only noautohide panels support titlebars, so one shouldn't be shown here
testname: "autohide panel with titlebar",
attrs: { titlebar: "normal" },
test(panel) {
panel.openPopupAtScreen(200, 210);
},
result(testname, panel) {
if (my_debug) alert(testname);
panel.getBoundingClientRect();
}
},
{
testname: "noautohide panel with titlebar",
attrs: { noautohide: true, titlebar: "normal" },
test(panel) {
waitSteps = 25;
panel.openPopupAtScreen(200, 210);
},
result(testname, panel) {
if (my_debug) alert(testname);
panel.getBoundingClientRect();
synthesizeMouse(panel, 10, 10, { type: "mousemove" });
var tree = $("tree");
tree.currentIndex = 0;
panel.appendChild(tree);
checkTreeCoords();
}
}
];
SimpleTest.waitForFocus(test_panels);
]]>
</script>
</window>