toolkit/content/tests/chrome/window_cursorsnap_dialog.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 <dialog title="Cursor snapping test" id="dialog"
michael@0 4 width="600" height="600"
michael@0 5 onload="onload();"
michael@0 6 onunload="onunload();"
michael@0 7 buttons="accept,cancel"
michael@0 8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
michael@0 9
michael@0 10 <script class="testbody" type="application/javascript">
michael@0 11 <![CDATA[
michael@0 12
michael@0 13 function ok(aCondition, aMessage)
michael@0 14 {
michael@0 15 window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage);
michael@0 16 }
michael@0 17
michael@0 18 function is(aLeft, aRight, aMessage)
michael@0 19 {
michael@0 20 window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage);
michael@0 21 }
michael@0 22
michael@0 23 function isnot(aLeft, aRight, aMessage)
michael@0 24 {
michael@0 25 window.opener.wrappedJSObject.SimpleTest.isnot(aLeft, aRight, aMessage);
michael@0 26 }
michael@0 27
michael@0 28 function canRetryTest()
michael@0 29 {
michael@0 30 return window.opener.wrappedJSObject.canRetryTest();
michael@0 31 }
michael@0 32
michael@0 33 function getTimeoutTime()
michael@0 34 {
michael@0 35 return window.opener.wrappedJSObject.getTimeoutTime();
michael@0 36 }
michael@0 37
michael@0 38 var gTimer;
michael@0 39 var gRetry;
michael@0 40
michael@0 41 function finishByTimeout()
michael@0 42 {
michael@0 43 var button = document.getElementById("dialog").getButton("accept");
michael@0 44 if (button.disabled)
michael@0 45 ok(true, "cursor is NOT snapped to the disabled button (dialog)");
michael@0 46 else if (button.hidden)
michael@0 47 ok(true, "cursor is NOT snapped to the hidden button (dialog)");
michael@0 48 else {
michael@0 49 if (!canRetryTest()) {
michael@0 50 ok(false, "cursor is NOT snapped to the default button (dialog)");
michael@0 51 } else {
michael@0 52 // otherwise, this may be unexpected timeout, we should retry the test.
michael@0 53 gRetry = true;
michael@0 54 }
michael@0 55 }
michael@0 56 finish();
michael@0 57 }
michael@0 58
michael@0 59 function finish()
michael@0 60 {
michael@0 61 window.close();
michael@0 62 }
michael@0 63
michael@0 64 function onMouseMove(aEvent)
michael@0 65 {
michael@0 66 var button = document.getElementById("dialog").getButton("accept");
michael@0 67 if (button.disabled)
michael@0 68 ok(false, "cursor IS snapped to the disabled button (dialog)");
michael@0 69 else if (button.hidden)
michael@0 70 ok(false, "cursor IS snapped to the hidden button (dialog)");
michael@0 71 else
michael@0 72 ok(true, "cursor IS snapped to the default button (dialog)");
michael@0 73 clearTimeout(gTimer);
michael@0 74 finish();
michael@0 75 }
michael@0 76
michael@0 77 function onload()
michael@0 78 {
michael@0 79 var button = document.getElementById("dialog").getButton("accept");
michael@0 80 button.addEventListener("mousemove", onMouseMove, false);
michael@0 81
michael@0 82 if (window.opener.wrappedJSObject.gDisable) {
michael@0 83 button.disabled = true;
michael@0 84 }
michael@0 85 if (window.opener.wrappedJSObject.gHidden) {
michael@0 86 button.hidden = true;
michael@0 87 }
michael@0 88 gRetry = false;
michael@0 89 gTimer = setTimeout(finishByTimeout, getTimeoutTime());
michael@0 90 }
michael@0 91
michael@0 92 function onunload()
michael@0 93 {
michael@0 94 if (gRetry) {
michael@0 95 window.opener.wrappedJSObject.retryCurrentTest();
michael@0 96 } else {
michael@0 97 window.opener.wrappedJSObject.runNextTest();
michael@0 98 }
michael@0 99 }
michael@0 100
michael@0 101 ]]>
michael@0 102 </script>
michael@0 103
michael@0 104 </dialog>

mercurial