toolkit/content/tests/chrome/window_cursorsnap_dialog.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/content/tests/chrome/window_cursorsnap_dialog.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,104 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     1.6 +<dialog title="Cursor snapping test" id="dialog"
     1.7 +  width="600" height="600"
     1.8 +  onload="onload();"
     1.9 +  onunload="onunload();"
    1.10 +  buttons="accept,cancel"
    1.11 +  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    1.12 +
    1.13 +<script class="testbody" type="application/javascript">
    1.14 +<![CDATA[
    1.15 +
    1.16 +function ok(aCondition, aMessage)
    1.17 +{
    1.18 +  window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage);
    1.19 +}
    1.20 +
    1.21 +function is(aLeft, aRight, aMessage)
    1.22 +{
    1.23 +  window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage);
    1.24 +}
    1.25 +
    1.26 +function isnot(aLeft, aRight, aMessage)
    1.27 +{
    1.28 +  window.opener.wrappedJSObject.SimpleTest.isnot(aLeft, aRight, aMessage);
    1.29 +}
    1.30 +
    1.31 +function canRetryTest()
    1.32 +{
    1.33 +  return window.opener.wrappedJSObject.canRetryTest();
    1.34 +}
    1.35 +
    1.36 +function getTimeoutTime()
    1.37 +{
    1.38 +  return window.opener.wrappedJSObject.getTimeoutTime();
    1.39 +}
    1.40 +
    1.41 +var gTimer;
    1.42 +var gRetry;
    1.43 +
    1.44 +function finishByTimeout()
    1.45 +{
    1.46 +  var button = document.getElementById("dialog").getButton("accept");
    1.47 +  if (button.disabled)
    1.48 +    ok(true, "cursor is NOT snapped to the disabled button (dialog)");
    1.49 +  else if (button.hidden)
    1.50 +    ok(true, "cursor is NOT snapped to the hidden button (dialog)");
    1.51 +  else {
    1.52 +    if (!canRetryTest()) {
    1.53 +      ok(false, "cursor is NOT snapped to the default button (dialog)");
    1.54 +    } else {
    1.55 +      // otherwise, this may be unexpected timeout, we should retry the test.
    1.56 +      gRetry = true;
    1.57 +    }
    1.58 +  }
    1.59 +  finish();
    1.60 +}
    1.61 +
    1.62 +function finish()
    1.63 +{
    1.64 +  window.close();
    1.65 +}
    1.66 +
    1.67 +function onMouseMove(aEvent)
    1.68 +{
    1.69 +  var button = document.getElementById("dialog").getButton("accept");
    1.70 +  if (button.disabled)
    1.71 +    ok(false, "cursor IS snapped to the disabled button (dialog)");
    1.72 +  else if (button.hidden)
    1.73 +    ok(false, "cursor IS snapped to the hidden button (dialog)");
    1.74 +  else
    1.75 +    ok(true, "cursor IS snapped to the default button (dialog)");
    1.76 +  clearTimeout(gTimer);
    1.77 +  finish();
    1.78 +}
    1.79 +
    1.80 +function onload()
    1.81 +{
    1.82 +  var button = document.getElementById("dialog").getButton("accept");
    1.83 +  button.addEventListener("mousemove", onMouseMove, false);
    1.84 +
    1.85 +  if (window.opener.wrappedJSObject.gDisable) {
    1.86 +    button.disabled = true;
    1.87 +  }
    1.88 +  if (window.opener.wrappedJSObject.gHidden) {
    1.89 +    button.hidden = true;
    1.90 +  }
    1.91 +  gRetry = false;
    1.92 +  gTimer = setTimeout(finishByTimeout, getTimeoutTime());
    1.93 +}
    1.94 +
    1.95 +function onunload()
    1.96 +{
    1.97 +  if (gRetry) {
    1.98 +    window.opener.wrappedJSObject.retryCurrentTest();
    1.99 +  } else {
   1.100 +    window.opener.wrappedJSObject.runNextTest();
   1.101 +  }
   1.102 +}
   1.103 +
   1.104 +]]>
   1.105 +</script>
   1.106 +
   1.107 +</dialog>

mercurial