summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/general/browser_tab_dragdrop2_frame1.xhtml
blob: d64f37c2896e06eab766b81c60f311f7880e3d4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?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"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
  <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>

<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>