PageRenderTime 23ms CodeModel.GetById 13ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

/toolkit/content/tests/widgets/test_contextmenu_nested.xul

http://github.com/zpao/v8monkey
Unknown | 134 lines | 120 code | 14 blank | 0 comment | 0 complexity | 01b24f9f215274121c77d83a89664fb9 MD5 | raw file
  1<?xml version="1.0"?>
  2<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
  3<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
  4
  5<window title="Nested Context Menu Tests"
  6        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  7
  8  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>      
  9  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>      
 10  <script type="application/javascript" src="popup_shared.js"></script>      
 11
 12<menupopup id="outercontext">
 13  <menuitem label="Context One"/>
 14  <menu id="outercontextmenu" label="Sub">
 15    <menupopup id="innercontext">
 16      <menuitem id="innercontextmenu" label="Sub Context One"/>
 17    </menupopup>
 18  </menu>
 19</menupopup>
 20
 21<menupopup id="outermain">
 22  <menuitem label="One"/>
 23  <menu id="outermenu" label="Sub">
 24    <menupopup id="innermain">
 25      <menuitem id="innermenu" label="Sub One" context="outercontext"/>
 26    </menupopup>
 27  </menu>
 28</menupopup>
 29
 30<button label="Check"/>
 31
 32<vbox id="popuparea" popup="outermain" width="20" height="20"/>
 33
 34<script type="application/javascript">
 35<![CDATA[
 36
 37SimpleTest.waitForExplicitFinish();
 38
 39var popupTests = [
 40{
 41  testname: "open outer popup",
 42  events: [ "popupshowing outermain", "popupshown outermain" ],
 43  test: function () synthesizeMouse($("popuparea"), 4, 4, {}),
 44  result: function (testname) {
 45    is($("outermain").triggerNode, $("popuparea"), testname);
 46    is(document.popupNode, $("popuparea"), testname + " document.popupNode");
 47  }
 48},
 49{
 50  testname: "open inner popup",
 51  events: [ "DOMMenuItemActive outermenu", "popupshowing innermain", "popupshown innermain" ],
 52  test: function () {
 53    synthesizeMouse($("outermenu"), 4, 4, { type: "mousemove" });
 54    synthesizeMouse($("outermenu"), 2, 2, { type: "mousemove" });
 55  },
 56  result: function (testname) {
 57    is($("outermain").triggerNode, $("popuparea"), testname + " outer");
 58    is($("innermain").triggerNode, $("popuparea"), testname + " inner");
 59    is($("outercontext").triggerNode, null, testname + " outer context");
 60    is(document.popupNode, $("popuparea"), testname + " document.popupNode");
 61  }
 62},
 63{
 64  testname: "open outer context",
 65  condition: function() { return (navigator.platform.indexOf("Mac") == -1); },
 66  events: [ "popupshowing outercontext", "popupshown outercontext" ],
 67  test: function () synthesizeMouse($("innermenu"), 4, 4, { type: "contextmenu", button: 2 }),
 68  result: function (testname) {
 69    is($("outermain").triggerNode, $("popuparea"), testname + " outer");
 70    is($("innermain").triggerNode, $("popuparea"), testname + " inner");
 71    is($("outercontext").triggerNode, $("innermenu"), testname + " outer context");
 72    is(document.popupNode, $("innermenu"), testname + " document.popupNode");
 73  }
 74},
 75{
 76  testname: "open inner context",
 77  condition: function() { return (navigator.platform.indexOf("Mac") == -1); },
 78  events: [ "DOMMenuItemActive outercontextmenu", "popupshowing innercontext", "popupshown innercontext" ],
 79  test: function () {
 80    synthesizeMouse($("outercontextmenu"), 4, 4, { type: "mousemove" });
 81    synthesizeMouse($("outercontextmenu"), 2, 2, { type: "mousemove" });
 82  },
 83  result: function (testname) {
 84    is($("outermain").triggerNode, $("popuparea"), testname + " outer");
 85    is($("innermain").triggerNode, $("popuparea"), testname + " inner");
 86    is($("outercontext").triggerNode, $("innermenu"), testname + " outer context");
 87    is($("innercontext").triggerNode, $("innermenu"), testname + " inner context");
 88    is(document.popupNode, $("innermenu"), testname + " document.popupNode");
 89  }
 90},
 91{
 92  testname: "close context",
 93  condition: function() { return (navigator.platform.indexOf("Mac") == -1); },
 94  events: [ "popuphiding innercontext", "popuphidden innercontext",
 95            "popuphiding outercontext", "popuphidden outercontext",
 96            "DOMMenuInactive innercontext",
 97            "DOMMenuItemInactive outercontextmenu", "DOMMenuItemInactive outercontextmenu",
 98            "DOMMenuInactive outercontext" ],
 99  test: function () $("outercontext").hidePopup(),
100  result: function (testname) {
101    is($("outermain").triggerNode, $("popuparea"), testname + " outer");
102    is($("innermain").triggerNode, $("popuparea"), testname + " inner");
103    is($("outercontext").triggerNode, null, testname + " outer context");
104    is($("innercontext").triggerNode, null, testname + " inner context");
105    is(document.popupNode, $("popuparea"), testname + " document.popupNode");
106  }
107},
108{
109  testname: "hide menus",
110  events: [ "popuphiding innermain", "popuphidden innermain",
111            "popuphiding outermain", "popuphidden outermain",
112            "DOMMenuInactive innermain",
113            "DOMMenuItemInactive outermenu", "DOMMenuItemInactive outermenu",
114            "DOMMenuInactive outermain" ],
115
116  test: function () $("outermain").hidePopup(),
117  result: function (testname) {
118    is($("outermain").triggerNode, null, testname + " outer");
119    is($("innermain").triggerNode, null, testname + " inner");
120    is($("outercontext").triggerNode, null, testname + " outer context");
121    is($("innercontext").triggerNode, null, testname + " inner context");
122    is(document.popupNode, null, testname + " document.popupNode");
123  }
124}
125];
126
127SimpleTest.waitForFocus(function runTest() startPopupTests(popupTests));
128
129]]>
130</script>
131
132<body xmlns="http://www.w3.org/1999/xhtml"><p id="display"/></body>
133
134</window>