toolkit/content/tests/chrome/test_cursorsnap.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"
     4                  type="text/css"?>
     5 <window title="Cursor snapping test"
     6   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
     8   <script type="application/javascript"
     9           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
    10   <script type="application/javascript"
    11           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" />
    13 <body  xmlns="http://www.w3.org/1999/xhtml">
    14 <div id="content" style="display: none">
    16 </div>
    17 <pre id="test">
    18 </pre>
    19 </body>
    21 <script class="testbody" type="application/javascript">
    22 <![CDATA[
    24 SimpleTest.waitForExplicitFinish();
    26 const kMaxRetryCount = 4;
    27 const kTimeoutTime = [
    28   100, 100, 1000, 1000, 5000
    29 ];
    31 var gRetryCount;
    33 var gTestingCount = 0;
    34 var gTestingIndex = -1;
    35 var gDisable = false;
    36 var gHidden = false;
    38 function canRetryTest()
    39 {
    40   return gRetryCount <= kMaxRetryCount;
    41 }
    43 function getTimeoutTime()
    44 {
    45   return kTimeoutTime[gRetryCount];
    46 }
    48 function runNextTest()
    49 {
    50   gRetryCount = 0;
    51   gTestingIndex++;
    52   runCurrentTest();
    53 }
    55 function retryCurrentTest()
    56 {
    57   ok(canRetryTest(), "retry the current test...");
    58   gRetryCount++;
    59   runCurrentTest();
    60 }
    62 function runCurrentTest()
    63 {
    64   var position = "top=" + gTestingCount + ",left=" + gTestingCount + ",";
    65   gTestingCount++;
    66   switch (gTestingIndex) {
    67     case 0:
    68       gDisable = false;
    69       gHidden = false;
    70       window.open("window_cursorsnap_dialog.xul", "_blank",
    71                   position + "chrome,width=100,height=100");
    72       break;
    73     case 1:
    74       gDisable = true;
    75       gHidden = false;
    76       window.open("window_cursorsnap_dialog.xul", "_blank",
    77                   position + "chrome,width=100,height=100");
    78       break;
    79     case 2:
    80       gDisable = false;
    81       gHidden = true;
    82       window.open("window_cursorsnap_dialog.xul", "_blank",
    83                   position + "chrome,width=100,height=100");
    84       break;
    85     case 3:
    86       gDisable = false;
    87       gHidden = false;
    88       window.open("window_cursorsnap_wizard.xul", "_blank",
    89                   position + "chrome,width=100,height=100");
    90       break;
    91     case 4:
    92       gDisable = true;
    93       gHidden = false;
    94       window.open("window_cursorsnap_wizard.xul", "_blank",
    95                   position + "chrome,width=100,height=100");
    96       break;
    97     case 5:
    98       gDisable = false;
    99       gHidden = true;
   100       window.open("window_cursorsnap_wizard.xul", "_blank",
   101                   position + "chrome,width=100,height=100");
   102       break;
   103     default:
   104       SetPrefs(false);
   105       SimpleTest.finish();
   106       return;
   107   }
   108 }
   110 function SetPrefs(aSet)
   111 {
   112   var prefSvc = Components.classes["@mozilla.org/preferences-service;1"].
   113                            getService(Components.interfaces.nsIPrefBranch);
   114   const kPrefName = "ui.cursor_snapping.always_enabled";
   115   if (aSet) {
   116     prefSvc.setBoolPref(kPrefName, true);
   117   } else if (prefSvc.prefHasUserValue(kPrefName)) {
   118     prefSvc.clearUserPref(kPrefName);
   119   }
   120 }
   122 SetPrefs(true);
   123 runNextTest();
   125 ]]>
   126 </script>
   127 </window>

mercurial