summaryrefslogtreecommitdiffstats
path: root/layout/xul/test/test_titlebar_ctrl_click.xhtml
blob: d58bfa7eb7e4612e79e48815ce19e7cfae63a78b (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
<?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 the titlebar element
  -->
<window title="Titlebar" width="200" height="200"
        onload="setTimeout(test_titlebar_ctrl_click, 0);"
        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"/>

<titlebar id="titlebar">
  <label id="label" value="Titlebar"/>
</titlebar>

<!-- test code goes here -->
<script type="application/javascript"><![CDATA[

const { AppConstants } = SpecialPowers.Cu.import("resource://gre/modules/AppConstants.jsm", {});

SimpleTest.waitForExplicitFinish();

function test_titlebar_ctrl_click()
{
  let titlebar = document.getElementById("titlebar");
  let isCommandFired = false;

  titlebar.addEventListener("click", function(aEvent) {
    // Delay check for command event, because it is fired after click event.
    setTimeout(() => {
      is(isCommandFired, AppConstants.platform != "macosx",
         "Check if command event is fired");
      SimpleTest.finish();
    }, 0);
  });
  titlebar.addEventListener("command", function(aEvent) {
    isCommandFired = true;
    ok(aEvent.ctrlKey, "Check ctrlKey for command event");
    ok(!aEvent.shiftKey, "Check shiftKey for command event");
    ok(!aEvent.altKey, "Check altKey for command event");
    ok(!aEvent.metaKey, "Check metaKey for command event");
    is(aEvent.inputSource, MouseEvent.MOZ_SOURCE_MOUSE,
       "Check inputSource for command event");
  });
  synthesizeMouseAtCenter(titlebar, { ctrlKey: true });
}

]]>
</script>

</window>