toolkit/content/tests/chrome/window_cursorsnap_dialog.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 <dialog title="Cursor snapping test" id="dialog"
     4   width="600" height="600"
     5   onload="onload();"
     6   onunload="onunload();"
     7   buttons="accept,cancel"
     8   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    10 <script class="testbody" type="application/javascript">
    11 <![CDATA[
    13 function ok(aCondition, aMessage)
    14 {
    15   window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage);
    16 }
    18 function is(aLeft, aRight, aMessage)
    19 {
    20   window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage);
    21 }
    23 function isnot(aLeft, aRight, aMessage)
    24 {
    25   window.opener.wrappedJSObject.SimpleTest.isnot(aLeft, aRight, aMessage);
    26 }
    28 function canRetryTest()
    29 {
    30   return window.opener.wrappedJSObject.canRetryTest();
    31 }
    33 function getTimeoutTime()
    34 {
    35   return window.opener.wrappedJSObject.getTimeoutTime();
    36 }
    38 var gTimer;
    39 var gRetry;
    41 function finishByTimeout()
    42 {
    43   var button = document.getElementById("dialog").getButton("accept");
    44   if (button.disabled)
    45     ok(true, "cursor is NOT snapped to the disabled button (dialog)");
    46   else if (button.hidden)
    47     ok(true, "cursor is NOT snapped to the hidden button (dialog)");
    48   else {
    49     if (!canRetryTest()) {
    50       ok(false, "cursor is NOT snapped to the default button (dialog)");
    51     } else {
    52       // otherwise, this may be unexpected timeout, we should retry the test.
    53       gRetry = true;
    54     }
    55   }
    56   finish();
    57 }
    59 function finish()
    60 {
    61   window.close();
    62 }
    64 function onMouseMove(aEvent)
    65 {
    66   var button = document.getElementById("dialog").getButton("accept");
    67   if (button.disabled)
    68     ok(false, "cursor IS snapped to the disabled button (dialog)");
    69   else if (button.hidden)
    70     ok(false, "cursor IS snapped to the hidden button (dialog)");
    71   else
    72     ok(true, "cursor IS snapped to the default button (dialog)");
    73   clearTimeout(gTimer);
    74   finish();
    75 }
    77 function onload()
    78 {
    79   var button = document.getElementById("dialog").getButton("accept");
    80   button.addEventListener("mousemove", onMouseMove, false);
    82   if (window.opener.wrappedJSObject.gDisable) {
    83     button.disabled = true;
    84   }
    85   if (window.opener.wrappedJSObject.gHidden) {
    86     button.hidden = true;
    87   }
    88   gRetry = false;
    89   gTimer = setTimeout(finishByTimeout, getTimeoutTime());
    90 }
    92 function onunload()
    93 {
    94   if (gRetry) {
    95     window.opener.wrappedJSObject.retryCurrentTest();
    96   } else {
    97     window.opener.wrappedJSObject.runNextTest();
    98   }
    99 }
   101 ]]>
   102 </script>
   104 </dialog>

mercurial