toolkit/content/tests/chrome/test_popuphidden.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/content/tests/chrome/test_popuphidden.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,74 @@
     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="Hidden Popup Test"
     1.9 +        onload="setTimeout(runTests, 0, $('popup'));"
    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 +
    1.14 +<menupopup id="popup" hidden="true" onpopupshown="ok(true, 'popupshown'); this.hidePopup()"
    1.15 +                                    onpopuphidden="$('popup-hideonshow').openPopup(null, 'after_start')">
    1.16 +  <menuitem id="i1" label="One"/>
    1.17 +  <menuitem id="i2" label="Two"/>
    1.18 +</menupopup>
    1.19 +
    1.20 +<menupopup id="popup-hideonshow" onpopupshowing="hidePopupWhileShowing(this)"
    1.21 +                                 onpopupshown="ok(false, 'popupshown when hidden')">
    1.22 +  <menuitem id="i1" label="One"/>
    1.23 +  <menuitem id="i2" label="Two"/>
    1.24 +</menupopup>
    1.25 +
    1.26 +<button id="button" type="menu" label="Menu" onDOMAttrModified="checkEndTest(event)">
    1.27 +  <menupopup id="popupinbutton" hidden="true"
    1.28 +             onpopupshown="ok(true, 'popupshown'); ok($('button').open, 'open'); this.hidden = true;">
    1.29 +    <menuitem id="i1" label="One"/>
    1.30 +    <menuitem id="i2" label="Two"/>
    1.31 +  </menupopup>
    1.32 +</button>
    1.33 +
    1.34 +<script class="testbody" type="application/javascript">
    1.35 +<![CDATA[
    1.36 +
    1.37 +SimpleTest.waitForExplicitFinish();
    1.38 +
    1.39 +function runTests(popup)
    1.40 +{
    1.41 +  popup.hidden = false;
    1.42 +  popup.openPopup(null, "after_start");
    1.43 +}
    1.44 +
    1.45 +function hidePopupWhileShowing(popup)
    1.46 +{
    1.47 +  popup.hidden = true;
    1.48 +  popup.clientWidth; // flush layout
    1.49 +  is(popup.state, 'closed', 'popupshowing hidden');
    1.50 +  SimpleTest.executeSoon(function () runTests($('popupinbutton')));
    1.51 +}
    1.52 +
    1.53 +function checkEndTest(event)
    1.54 +{
    1.55 +  var button = $("button");
    1.56 +  if (event.originalTarget != button || event.attrName != 'open' || event.attrChange != event.REMOVAL)
    1.57 +    return;
    1.58 +
    1.59 +  ok($("popupinbutton").hidden, "popup hidden");
    1.60 +  is($("popupinbutton").state, "closed", "popup state");
    1.61 +  ok(!button.open, "not open after hidden");
    1.62 +  SimpleTest.finish();
    1.63 +}
    1.64 +
    1.65 +]]>
    1.66 +</script>
    1.67 +
    1.68 +<body xmlns="http://www.w3.org/1999/xhtml">
    1.69 +<p id="display">
    1.70 +</p>
    1.71 +<div id="content" style="display: none">
    1.72 +</div>
    1.73 +<pre id="test">
    1.74 +</pre>
    1.75 +</body>
    1.76 +
    1.77 +</window>

mercurial