2007-08-23 15:13:42 -07:00
|
|
|
<?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="Open panel from menuitem"
|
|
|
|
onload="setTimeout(runTests, 0);"
|
|
|
|
xmlns:html="http://www.w3.org/1999/xhtml"
|
|
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
|
|
|
|
|
|
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
|
|
|
|
|
|
|
<!--
|
|
|
|
This test does the following:
|
|
|
|
1. Opens the menu, causing the popupshown event to fire, which will call menuOpened.
|
|
|
|
2. Keyboard events are fired to cause the first item on the menu to be executed.
|
|
|
|
3. The command event handler for the first menuitem opens the panel.
|
|
|
|
4. As a menuitem was executed, the menu will roll up, hiding it.
|
|
|
|
5. The popuphidden event for the menu calls menuClosed which tests the popup states.
|
|
|
|
6. The panelOpened function tests the popup states again and hides the popup.
|
2009-01-20 09:46:55 -08:00
|
|
|
7. Once the panel's popuphidden event fires, tests are performed to see if
|
|
|
|
panels inside buttons and toolbarbuttons work. Each is opened and the closed.
|
2007-08-23 15:13:42 -07:00
|
|
|
-->
|
|
|
|
|
|
|
|
<menu id="menu" onpopupshown="menuOpened()" onpopuphidden="menuClosed();">
|
|
|
|
<menupopup>
|
|
|
|
<menuitem id="i1" label="One" oncommand="$('panel').openPopup($('menu'), 'after_start');"/>
|
|
|
|
<menuitem id="i2" label="Two"/>
|
|
|
|
</menupopup>
|
|
|
|
</menu>
|
|
|
|
|
2009-08-26 09:19:38 -07:00
|
|
|
<panel id="hiddenpanel" hidden="true"/>
|
|
|
|
|
2009-01-20 09:46:55 -08:00
|
|
|
<panel id="panel" onpopupshown="panelOpened()"
|
|
|
|
onpopuphidden="$('button').focus(); $('button').open = true">
|
2007-08-23 15:13:42 -07:00
|
|
|
<textbox/>
|
|
|
|
</panel>
|
|
|
|
|
2009-01-20 09:46:55 -08:00
|
|
|
<button id="button" type="panel" label="Button">
|
|
|
|
<panel onpopupshown="panelOnButtonOpened(this)"
|
|
|
|
onpopuphidden="$('tbutton').open = true;">
|
|
|
|
<button label="OK" oncommand="this.parentNode.parentNode.open = false"/>
|
|
|
|
</panel>
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<toolbarbutton id="tbutton" type="panel" label="Toolbarbutton">
|
|
|
|
<panel onpopupshown="panelOnToolbarbuttonOpened(this)"
|
|
|
|
onpopuphidden="SimpleTest.finish()">
|
|
|
|
<textbox/>
|
|
|
|
</panel>
|
|
|
|
</toolbarbutton>
|
|
|
|
|
2007-08-23 15:13:42 -07:00
|
|
|
<script class="testbody" type="application/javascript">
|
|
|
|
<![CDATA[
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
function runTests()
|
|
|
|
{
|
2009-08-26 09:19:38 -07:00
|
|
|
is($("hiddenpanel").state, "closed", "hidden popup is closed");
|
|
|
|
|
2007-08-23 15:13:42 -07:00
|
|
|
var menu = $("menu");
|
|
|
|
menu.open = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function menuOpened()
|
|
|
|
{
|
|
|
|
synthesizeKey("VK_DOWN", { });
|
|
|
|
synthesizeKey("VK_ENTER", { });
|
|
|
|
}
|
|
|
|
|
|
|
|
function menuClosed()
|
|
|
|
{
|
|
|
|
// the panel will be open at this point, but the popupshown event
|
|
|
|
// still needs to fire
|
2007-09-16 09:55:12 -07:00
|
|
|
is($("panel").state, "showing", "panel is open after menu hide");
|
2007-08-23 15:13:42 -07:00
|
|
|
is($("menu").firstChild.state, "closed", "menu is closed after menu hide");
|
|
|
|
}
|
|
|
|
|
|
|
|
function panelOpened()
|
|
|
|
{
|
|
|
|
is($("panel").state, "open", "panel is open");
|
|
|
|
is($("menu").firstChild.state, "closed", "menu is closed");
|
|
|
|
$("panel").hidePopup();
|
|
|
|
}
|
|
|
|
|
2009-01-20 09:46:55 -08:00
|
|
|
function panelOnButtonOpened(panel)
|
|
|
|
{
|
|
|
|
is(panel.state, 'open', 'button panel is open');
|
|
|
|
is(document.activeElement, document.documentElement, "focus blurred on panel from button open");
|
|
|
|
synthesizeKey("VK_DOWN", { });
|
|
|
|
is(document.activeElement, document.documentElement, "focus not modified on cursor down from button");
|
|
|
|
panel.firstChild.doCommand()
|
|
|
|
}
|
|
|
|
|
|
|
|
function panelOnToolbarbuttonOpened(panel)
|
|
|
|
{
|
|
|
|
is(panel.state, 'open', 'toolbarbutton panel is open');
|
|
|
|
is(document.activeElement, document.documentElement, "focus blurred on panel from toolbarbutton open");
|
|
|
|
panel.firstChild.focus();
|
|
|
|
synthesizeKey("VK_DOWN", { });
|
|
|
|
is(document.activeElement, panel.firstChild.inputField, "focus not modified on cursor down from toolbarbutton");
|
|
|
|
panel.parentNode.open = false;
|
|
|
|
}
|
|
|
|
|
2007-08-23 15:13:42 -07:00
|
|
|
]]>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
|
|
|
<p id="display">
|
|
|
|
</p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</window>
|