toolkit/content/tests/chrome/test_bug624329.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 type="text/css" href="chrome://global/skin"?>
     3 <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
     4 <!--
     5 https://bugzilla.mozilla.org/show_bug.cgi?id=624329
     6 -->
     7 <window title="Mozilla Bug 624329 context menu position"
     8         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
     9   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
    10   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
    12   <!-- test results are displayed in the html:body -->
    13   <body xmlns="http://www.w3.org/1999/xhtml"
    14         onload="openTestWindow()">
    15   <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=624329"
    16      target="_blank">Mozilla Bug 624329</a>
    17   </body>
    19   <!-- test code goes here -->
    20   <script type="application/javascript">
    21   <![CDATA[
    22   /** Test for Bug 624329 **/
    24 SimpleTest.waitForExplicitFinish();
    26 var win;
    27 var timeoutID;
    28 var menu;
    30 function openTestWindow() {
    31     win = open("bug624329_window.xul", "_blank", "width=300,resizable=yes,chrome");
    32     // Close our window if the test times out so that it doesn't interfere
    33     // with later tests.
    34     timeoutID = setTimeout(function () {
    35         ok(false, "Test timed out.");
    36         // Provide some time for a screenshot
    37         setTimeout(finish, 1000);
    38     }, 20000);
    39 }
    41 function listenOnce(event, callback) {
    42     win.addEventListener(event, function listener() {
    43         win.removeEventListener(event, listener, false);
    44         callback();
    45     }, false);
    46 }
    48 function childFocused() {
    49     // maximizing the window is a simple way to ensure that the menu is near
    50     // the right edge of the screen.
    52     listenOnce("resize", childResized);
    53     win.maximize();
    54 }
    56 function childResized() {
    57     const isOSXLion = navigator.userAgent.indexOf("Mac OS X 10.7") != -1;
    58     const isOSXMtnLion = navigator.userAgent.indexOf("Mac OS X 10.8") != -1;
    59     const isOSXMavericks = navigator.userAgent.indexOf("Mac OS X 10.9") != -1;
    60     if (isOSXLion || isOSXMtnLion || isOSXMavericks) {
    61         todo_is(win.windowState, win.STATE_MAXIMIZED,
    62                 "A resize before being maximized breaks this test on 10.7 and 10.8 and 10.9");
    63         finish();
    64         return;
    65     }
    67     is(win.windowState, win.STATE_MAXIMIZED,
    68        "window should be maximized");
    70     isnot(win.innerWidth, 300,
    71          "window inner width should have changed");
    73     openContextMenu();
    74 }
    76 function openContextMenu() {
    77     var mouseX = win.innerWidth - 10;
    78     var mouseY = 10;
    80     menu = win.document.getElementById("menu");
    81     var screenX = menu.boxObject.screenX;
    82     var screenY = menu.boxObject.screenY;
    83     var utils =
    84         win.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
    85             getInterface(Components.interfaces.nsIDOMWindowUtils);
    87     utils.sendMouseEvent("contextmenu", mouseX, mouseY, 2, 0, 0);
    89     var interval = setInterval(checkMoved, 200);
    90     function checkMoved() {
    91         if (menu.boxObject.screenX != screenX ||
    92             menu.boxObject.screenY != screenY) {
    93             clearInterval(interval);
    94             // Wait further to check that the window does not move again.
    95             setTimeout(checkPosition, 1000);
    96         }
    97     }
    99     function checkPosition() {
   100         var menubox = menu.boxObject;
   101         var winbox = win.document.documentElement.boxObject
   103         var x = menubox.screenX - winbox.screenX;
   104         var y = menubox.screenY - winbox.screenY;
   105         ok(y >= mouseY,
   106            "menu top " + y + " should be below click point " + mouseY);
   107         ok(y <= mouseY + 20,
   108            "menu top " + y + " should not be too far below click point " + mouseY);
   110         ok(x < mouseX,
   111            "menu left " + x + " should be left of click point " + mouseX);
   112         var right = x + menubox.width;
   113         ok(right > mouseX,
   114            "menu right " + right + " should be right of click point " + mouseX);
   116         clearTimeout(timeoutID);
   117         finish();
   118     }
   120 }
   122 function finish() {
   123     if (menu && navigator.platform.indexOf("Win") >= 0) {
   124         todo(false, "Should not have to hide popup before closing its window");
   125         // This avoids mochitest "Unable to restore focus" errors (bug 670053).
   126         menu.hidePopup();
   127     }
   128     win.close();
   129     SimpleTest.finish();
   130 }
   132   ]]>
   133   </script>
   134 </window>

mercurial