toolkit/content/tests/chrome/window_cursorsnap_wizard.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 <wizard title="Cursor snapping test" id="wizard"
     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   <wizardpage>
    11     <label value="first page"/>
    12   </wizardpage>
    14   <wizardpage>
    15     <label value="second page"/>
    16   </wizardpage>
    18 <script class="testbody" type="application/javascript">
    19 <![CDATA[
    21 function ok(aCondition, aMessage)
    22 {
    23   window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage);
    24 }
    26 function is(aLeft, aRight, aMessage)
    27 {
    28   window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage);
    29 }
    31 function isnot(aLeft, aRight, aMessage)
    32 {
    33   window.opener.wrappedJSObject.SimpleTest.isnot(aLeft, aRight, aMessage);
    34 }
    36 function canRetryTest()
    37 {
    38   return window.opener.wrappedJSObject.canRetryTest();
    39 }
    41 function getTimeoutTime()
    42 {
    43   return window.opener.wrappedJSObject.getTimeoutTime();
    44 }
    46 var gTimer;
    47 var gRetry = false;
    49 function finishByTimeout()
    50 {
    51   var button = document.getElementById("wizard").getButton("next");
    52   if (button.disabled)
    53     ok(true, "cursor is NOT snapped to the disabled button (wizard)");
    54   else if (button.hidden)
    55     ok(true, "cursor is NOT snapped to the hidden button (wizard)");
    56   else {
    57     if (!canRetryTest()) {
    58       ok(false, "cursor is NOT snapped to the default button (wizard)");
    59     } else {
    60       // otherwise, this may be unexpected timeout, we should retry the test.
    61       gRetry = true;
    62     }
    63   }
    64   finish();
    65 }
    67 function finish()
    68 {
    69   window.close();
    70 }
    72 function onMouseMove()
    73 {
    74   var button = document.getElementById("wizard").getButton("next");
    75   if (button.disabled)
    76     ok(false, "cursor IS snapped to the disabled button (wizard)");
    77   else if (button.hidden)
    78     ok(false, "cursor IS snapped to the hidden button (wizard)");
    79   else
    80     ok(true, "cursor IS snapped to the default button (wizard)");
    81   clearTimeout(gTimer);
    82   finish();
    83 }
    85 function onload()
    86 {
    87   var button = document.getElementById("wizard").getButton("next");
    88   button.addEventListener("mousemove", onMouseMove, false);
    90   if (window.opener.wrappedJSObject.gDisable) {
    91     button.disabled = true;
    92   }
    93   if (window.opener.wrappedJSObject.gHidden) {
    94     button.hidden = true;
    95   }
    96   gTimer = setTimeout(finishByTimeout, getTimeoutTime());
    97 }
    99 function onunload()
   100 {
   101   if (gRetry) {
   102     window.opener.wrappedJSObject.retryCurrentTest();
   103   } else {
   104     window.opener.wrappedJSObject.runNextTest();
   105   }
   106 }
   108 ]]>
   109 </script>
   111 </wizard>

mercurial