toolkit/content/tests/chrome/test_menu_anchored.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"?>
     4 <!--
     5   Test for menus with the anchor attribute set
     6   -->
     7 <window title="Anchored Menus Test"
     8         align="start"
     9         onload="setTimeout(runTest, 0,'tb1');"
    10         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    11   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    12   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
    13   <script type="application/javascript" src="xul_selectcontrol.js"/>
    15 <hbox>
    17 <toolbarbutton id="tb1" type="menu-button" label="Open" anchor="dropmarker">
    18   <menupopup id="popup1"
    19              onpopupshown="checkPopup(this, document.getAnonymousElementByAttribute(this.parentNode, 'anonid', 'dropmarker'))"
    20              onpopuphidden="runTest('tb2')">
    21     <menuitem label="Item"/>
    22   </menupopup>
    23 </toolbarbutton>
    25 <toolbarbutton id="tb2" type="menu-button" label="Open" anchor="someanchor">
    26   <menupopup id="popup2" onpopupshown="checkPopup(this, $('someanchor'))" onpopuphidden="runTest('tb3')">
    27     <menuitem label="Item"/>
    28   </menupopup>
    29 </toolbarbutton>
    31 <toolbarbutton id="tb3" type="menu-button" label="Open" anchor="noexist">
    32   <menupopup id="popup3" onpopupshown="checkPopup(this, this.parentNode)" onpopuphidden="SimpleTest.finish()">
    33     <menuitem label="Item"/>
    34   </menupopup>
    35 </toolbarbutton>
    37 </hbox>
    39 <hbox pack="end" width="180">
    40   <button id="someanchor" label="Anchor"/>
    41 </hbox>
    43 <!-- test results are displayed in the html:body -->
    44 <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
    46 <script type="application/javascript"><![CDATA[
    48 function runTest(menuid)
    49 {
    50   let menu = $(menuid);
    51   let dropmarker = document.getAnonymousElementByAttribute(menu, "anonid", "dropmarker");
    53   synthesizeMouseAtCenter(dropmarker, { });
    54 }
    56 function isWithinHalfPixel(a, b)
    57 {
    58   return Math.abs(a - b) <= 0.5;
    59 }
    61 function checkPopup(popup, anchor)
    62 {
    63   let popupRect = popup.getBoundingClientRect();
    64   let anchorRect = anchor.getBoundingClientRect();
    66   ok(isWithinHalfPixel(popupRect.left, anchorRect.left), popup.id + " left");
    67   ok(isWithinHalfPixel(popupRect.top, anchorRect.bottom), popup.id + " top");
    69   popup.hidePopup();
    70 }
    72 SimpleTest.waitForExplicitFinish();
    74 ]]>
    75 </script>
    77 </window>

mercurial