1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/content/tests/chrome/test_closemenu_attribute.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,96 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> 1.7 + 1.8 +<window title="Menu closemenu Attribute Tests" 1.9 + onload="setTimeout(nextTest, 0);" 1.10 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.11 + 1.12 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.13 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> 1.14 + 1.15 +<button id="menu" type="menu" label="Menu" onpopuphidden="popupHidden(event)"> 1.16 + <menupopup id="p1" onpopupshown="if (event.target == this) this.firstChild.open = true"> 1.17 + <menu id="l1" label="One"> 1.18 + <menupopup id="p2" onpopupshown="if (event.target == this) this.firstChild.open = true"> 1.19 + <menu id="l2" label="Two"> 1.20 + <menupopup id="p3" onpopupshown="executeMenuItem()"> 1.21 + <menuitem id="l3" label="Three"/> 1.22 + </menupopup> 1.23 + </menu> 1.24 + </menupopup> 1.25 + </menu> 1.26 + </menupopup> 1.27 +</button> 1.28 + 1.29 +<script class="testbody" type="application/javascript"> 1.30 +<![CDATA[ 1.31 + 1.32 +SimpleTest.waitForExplicitFinish(); 1.33 + 1.34 +var gExpectedId = "p3"; 1.35 +var gMode = -1; 1.36 +var gModes = ["", "auto", "single", "none"]; 1.37 + 1.38 +function nextTest() 1.39 +{ 1.40 + gMode++; 1.41 + if (gModes[gMode] != "none") 1.42 + gExpectedId = "p3"; 1.43 + 1.44 + if (gMode != 0) 1.45 + $("l3").setAttribute("closemenu", gModes[gMode]); 1.46 + if (gModes[gMode] == "none") 1.47 + $("l2").open = true; 1.48 + else 1.49 + $("menu").open = true; 1.50 +} 1.51 + 1.52 +function executeMenuItem() 1.53 +{ 1.54 + synthesizeKey("VK_DOWN", { }); 1.55 + synthesizeKey("VK_RETURN", { }); 1.56 + // after a couple of seconds, end the test, as the 'none' closemenu value 1.57 + // should not hide any popups 1.58 + if (gModes[gMode] == "none") 1.59 + setTimeout(function() { $("menu").open = false; }, 2000); 1.60 +} 1.61 + 1.62 +function popupHidden(event) 1.63 +{ 1.64 + if (gModes[gMode] == "none") { 1.65 + if (event.target.id == "p1") 1.66 + SimpleTest.finish() 1.67 + return; 1.68 + } 1.69 + 1.70 + is(event.target.id, gExpectedId, 1.71 + "Expected event " + gModes[gMode] + " " + gExpectedId); 1.72 + 1.73 + gExpectedId = ""; 1.74 + if (event.target.id == "p3") { 1.75 + if (gModes[gMode] == "" || gModes[gMode] == "auto") 1.76 + gExpectedId = "p2"; 1.77 + } 1.78 + else if (event.target.id == "p2") { 1.79 + if (gModes[gMode] == "" || gModes[gMode] == "auto") 1.80 + gExpectedId = "p1"; 1.81 + } 1.82 + 1.83 + if (!gExpectedId) 1.84 + nextTest(); 1.85 +} 1.86 + 1.87 +]]> 1.88 +</script> 1.89 + 1.90 +<body xmlns="http://www.w3.org/1999/xhtml"> 1.91 +<p id="display"> 1.92 +</p> 1.93 +<div id="content" style="display: none"> 1.94 +</div> 1.95 +<pre id="test"> 1.96 +</pre> 1.97 +</body> 1.98 + 1.99 +</window>