toolkit/content/tests/chrome/test_closemenu_attribute.xul

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 <?xml version="1.0"?>
     2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
     5 <window title="Menu closemenu Attribute Tests"
     6   onload="setTimeout(nextTest, 0);"
     7   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
     9   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>      
    10   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>      
    12 <button id="menu" type="menu" label="Menu" onpopuphidden="popupHidden(event)">
    13   <menupopup id="p1" onpopupshown="if (event.target == this) this.firstChild.open = true">
    14     <menu id="l1" label="One">
    15       <menupopup id="p2" onpopupshown="if (event.target == this) this.firstChild.open = true">
    16         <menu id="l2" label="Two">
    17           <menupopup id="p3" onpopupshown="executeMenuItem()">
    18             <menuitem id="l3" label="Three"/>
    19           </menupopup>
    20         </menu>
    21       </menupopup>
    22     </menu>
    23   </menupopup>
    24 </button>
    26 <script class="testbody" type="application/javascript">
    27 <![CDATA[
    29 SimpleTest.waitForExplicitFinish();
    31 var gExpectedId = "p3";
    32 var gMode = -1;
    33 var gModes = ["", "auto", "single", "none"];
    35 function nextTest()
    36 {
    37   gMode++;
    38   if (gModes[gMode] != "none")
    39     gExpectedId = "p3";
    41   if (gMode != 0)
    42     $("l3").setAttribute("closemenu", gModes[gMode]);
    43   if (gModes[gMode] == "none")
    44     $("l2").open = true;
    45   else
    46     $("menu").open = true;
    47 }
    49 function executeMenuItem()
    50 {
    51   synthesizeKey("VK_DOWN", { });
    52   synthesizeKey("VK_RETURN", { });
    53   // after a couple of seconds, end the test, as the 'none' closemenu value
    54   // should not hide any popups
    55   if (gModes[gMode] == "none")
    56     setTimeout(function() { $("menu").open = false; }, 2000);
    57 }
    59 function popupHidden(event)
    60 {
    61   if (gModes[gMode] == "none") {
    62     if (event.target.id == "p1")
    63       SimpleTest.finish()
    64     return;
    65   }
    67   is(event.target.id, gExpectedId,
    68      "Expected event " + gModes[gMode] + " " + gExpectedId);
    70   gExpectedId = "";
    71   if (event.target.id == "p3") {
    72     if (gModes[gMode] == "" || gModes[gMode] == "auto")
    73       gExpectedId = "p2";
    74   }
    75   else if (event.target.id == "p2") {
    76     if (gModes[gMode] == "" || gModes[gMode] == "auto")
    77       gExpectedId = "p1";
    78   }
    80   if (!gExpectedId)
    81     nextTest();
    82 }
    84 ]]>
    85 </script>
    87 <body xmlns="http://www.w3.org/1999/xhtml">
    88 <p id="display">
    89 </p>
    90 <div id="content" style="display: none">
    91 </div>
    92 <pre id="test">
    93 </pre>
    94 </body>
    96 </window>

mercurial