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.

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

mercurial