toolkit/content/tests/chrome/test_cursorsnap.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/content/tests/chrome/test_cursorsnap.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,127 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
     1.7 +                 type="text/css"?>
     1.8 +<window title="Cursor snapping test"
     1.9 +  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    1.10 +
    1.11 +  <script type="application/javascript"
    1.12 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
    1.13 +  <script type="application/javascript"
    1.14 +          src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" />
    1.15 +
    1.16 +<body  xmlns="http://www.w3.org/1999/xhtml">
    1.17 +<div id="content" style="display: none">
    1.18 +  
    1.19 +</div>
    1.20 +<pre id="test">
    1.21 +</pre>
    1.22 +</body>
    1.23 +
    1.24 +<script class="testbody" type="application/javascript">
    1.25 +<![CDATA[
    1.26 +
    1.27 +SimpleTest.waitForExplicitFinish();
    1.28 +
    1.29 +const kMaxRetryCount = 4;
    1.30 +const kTimeoutTime = [
    1.31 +  100, 100, 1000, 1000, 5000
    1.32 +];
    1.33 +
    1.34 +var gRetryCount;
    1.35 +
    1.36 +var gTestingCount = 0;
    1.37 +var gTestingIndex = -1;
    1.38 +var gDisable = false;
    1.39 +var gHidden = false;
    1.40 +
    1.41 +function canRetryTest()
    1.42 +{
    1.43 +  return gRetryCount <= kMaxRetryCount;
    1.44 +}
    1.45 +
    1.46 +function getTimeoutTime()
    1.47 +{
    1.48 +  return kTimeoutTime[gRetryCount];
    1.49 +}
    1.50 +
    1.51 +function runNextTest()
    1.52 +{
    1.53 +  gRetryCount = 0;
    1.54 +  gTestingIndex++;
    1.55 +  runCurrentTest();
    1.56 +}
    1.57 +
    1.58 +function retryCurrentTest()
    1.59 +{
    1.60 +  ok(canRetryTest(), "retry the current test...");
    1.61 +  gRetryCount++;
    1.62 +  runCurrentTest();
    1.63 +}
    1.64 +
    1.65 +function runCurrentTest()
    1.66 +{
    1.67 +  var position = "top=" + gTestingCount + ",left=" + gTestingCount + ",";
    1.68 +  gTestingCount++;
    1.69 +  switch (gTestingIndex) {
    1.70 +    case 0:
    1.71 +      gDisable = false;
    1.72 +      gHidden = false;
    1.73 +      window.open("window_cursorsnap_dialog.xul", "_blank",
    1.74 +                  position + "chrome,width=100,height=100");
    1.75 +      break;
    1.76 +    case 1:
    1.77 +      gDisable = true;
    1.78 +      gHidden = false;
    1.79 +      window.open("window_cursorsnap_dialog.xul", "_blank",
    1.80 +                  position + "chrome,width=100,height=100");
    1.81 +      break;
    1.82 +    case 2:
    1.83 +      gDisable = false;
    1.84 +      gHidden = true;
    1.85 +      window.open("window_cursorsnap_dialog.xul", "_blank",
    1.86 +                  position + "chrome,width=100,height=100");
    1.87 +      break;
    1.88 +    case 3:
    1.89 +      gDisable = false;
    1.90 +      gHidden = false;
    1.91 +      window.open("window_cursorsnap_wizard.xul", "_blank",
    1.92 +                  position + "chrome,width=100,height=100");
    1.93 +      break;
    1.94 +    case 4:
    1.95 +      gDisable = true;
    1.96 +      gHidden = false;
    1.97 +      window.open("window_cursorsnap_wizard.xul", "_blank",
    1.98 +                  position + "chrome,width=100,height=100");
    1.99 +      break;
   1.100 +    case 5:
   1.101 +      gDisable = false;
   1.102 +      gHidden = true;
   1.103 +      window.open("window_cursorsnap_wizard.xul", "_blank",
   1.104 +                  position + "chrome,width=100,height=100");
   1.105 +      break;
   1.106 +    default:
   1.107 +      SetPrefs(false);
   1.108 +      SimpleTest.finish();
   1.109 +      return;
   1.110 +  }
   1.111 +}
   1.112 +
   1.113 +function SetPrefs(aSet)
   1.114 +{
   1.115 +  var prefSvc = Components.classes["@mozilla.org/preferences-service;1"].
   1.116 +                           getService(Components.interfaces.nsIPrefBranch);
   1.117 +  const kPrefName = "ui.cursor_snapping.always_enabled";
   1.118 +  if (aSet) {
   1.119 +    prefSvc.setBoolPref(kPrefName, true);
   1.120 +  } else if (prefSvc.prefHasUserValue(kPrefName)) {
   1.121 +    prefSvc.clearUserPref(kPrefName);
   1.122 +  }
   1.123 +}
   1.124 +
   1.125 +SetPrefs(true);
   1.126 +runNextTest();
   1.127 +
   1.128 +]]>
   1.129 +</script>
   1.130 +</window>

mercurial