DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (5b81998bb7ab)

VCS Links

Line Code
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
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>

<window title="Nested Context Menu Tests"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
  <script type="application/javascript" src="popup_shared.js"></script>

<menupopup id="outercontext">
  <menuitem label="Context One"/>
  <menu id="outercontextmenu" label="Sub">
    <menupopup id="innercontext">
      <menuitem id="innercontextmenu" label="Sub Context One"/>
    </menupopup>
  </menu>
</menupopup>

<menupopup id="outermain">
  <menuitem label="One"/>
  <menu id="outermenu" label="Sub">
    <menupopup id="innermain">
      <menuitem id="innermenu" label="Sub One" context="outercontext"/>
    </menupopup>
  </menu>
</menupopup>

<button label="Check"/>

<vbox id="popuparea" popup="outermain" width="20" height="20"/>

<script type="application/javascript">
<![CDATA[

SimpleTest.waitForExplicitFinish();

var popupTests = [
{
  testname: "open outer popup",
  events: [ "popupshowing outermain", "popupshown outermain" ],
  test: function () synthesizeMouse($("popuparea"), 4, 4, {}),
  result: function (testname) {
    is($("outermain").triggerNode, $("popuparea"), testname);
    is(document.popupNode, $("popuparea"), testname + " document.popupNode");
  }
},
{
  testname: "open inner popup",
  events: [ "DOMMenuItemActive outermenu", "popupshowing innermain", "popupshown innermain" ],
  test: function () {
    synthesizeMouse($("outermenu"), 4, 4, { type: "mousemove" });
    synthesizeMouse($("outermenu"), 2, 2, { type: "mousemove" });
  },
  result: function (testname) {
    is($("outermain").triggerNode, $("popuparea"), testname + " outer");
    is($("innermain").triggerNode, $("popuparea"), testname + " inner");
    is($("outercontext").triggerNode, null, testname + " outer context");
    is(document.popupNode, $("popuparea"), testname + " document.popupNode");
  }
},
{
  testname: "open outer context",
  condition: function() { return (navigator.platform.indexOf("Mac") == -1); },
  events: [ "popupshowing outercontext", "popupshown outercontext" ],
  test: function () synthesizeMouse($("innermenu"), 4, 4, { type: "contextmenu", button: 2 }),
  result: function (testname) {
    is($("outermain").triggerNode, $("popuparea"), testname + " outer");
    is($("innermain").triggerNode, $("popuparea"), testname + " inner");
    is($("outercontext").triggerNode, $("innermenu"), testname + " outer context");
    is(document.popupNode, $("innermenu"), testname + " document.popupNode");
  }
},
{
  testname: "open inner context",
  condition: function() { return (navigator.platform.indexOf("Mac") == -1); },
  events: [ "DOMMenuItemActive outercontextmenu", "popupshowing innercontext", "popupshown innercontext" ],
  test: function () {
    synthesizeMouse($("outercontextmenu"), 4, 4, { type: "mousemove" });
    synthesizeMouse($("outercontextmenu"), 2, 2, { type: "mousemove" });
  },
  result: function (testname) {
    is($("outermain").triggerNode, $("popuparea"), testname + " outer");
    is($("innermain").triggerNode, $("popuparea"), testname + " inner");
    is($("outercontext").triggerNode, $("innermenu"), testname + " outer context");
    is($("innercontext").triggerNode, $("innermenu"), testname + " inner context");
    is(document.popupNode, $("innermenu"), testname + " document.popupNode");
  }
},
{
  testname: "close context",
  condition: function() { return (navigator.platform.indexOf("Mac") == -1); },
  events: [ "popuphiding innercontext", "popuphidden innercontext",
            "popuphiding outercontext", "popuphidden outercontext",
            "DOMMenuInactive innercontext",
            "DOMMenuItemInactive outercontextmenu", "DOMMenuItemInactive outercontextmenu",
            "DOMMenuInactive outercontext" ],
  test: function () $("outercontext").hidePopup(),
  result: function (testname) {
    is($("outermain").triggerNode, $("popuparea"), testname + " outer");
    is($("innermain").triggerNode, $("popuparea"), testname + " inner");
    is($("outercontext").triggerNode, null, testname + " outer context");
    is($("innercontext").triggerNode, null, testname + " inner context");
    is(document.popupNode, $("popuparea"), testname + " document.popupNode");
  }
},
{
  testname: "hide menus",
  events: [ "popuphiding innermain", "popuphidden innermain",
            "popuphiding outermain", "popuphidden outermain",
            "DOMMenuInactive innermain",
            "DOMMenuItemInactive outermenu", "DOMMenuItemInactive outermenu",
            "DOMMenuInactive outermain" ],

  test: function () $("outermain").hidePopup(),
  result: function (testname) {
    is($("outermain").triggerNode, null, testname + " outer");
    is($("innermain").triggerNode, null, testname + " inner");
    is($("outercontext").triggerNode, null, testname + " outer context");
    is($("innercontext").triggerNode, null, testname + " inner context");
    is(document.popupNode, null, testname + " document.popupNode");
  }
}
];

SimpleTest.waitForFocus(function runTest() startPopupTests(popupTests));

]]>
</script>

<body xmlns="http://www.w3.org/1999/xhtml"><p id="display"/></body>

</window>