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