editor/libeditor/base/tests/test_bug795785.html

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 <html>
michael@0 2 <!--
michael@0 3 https://bugzilla.mozilla.org/show_bug.cgi?id=795785
michael@0 4 -->
michael@0 5 <head>
michael@0 6 <title>Test for Bug 795785</title>
michael@0 7 <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
michael@0 8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 9 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
michael@0 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 11 </head>
michael@0 12 <body>
michael@0 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=795785">Mozilla Bug 795785</a>
michael@0 14 <div id="display">
michael@0 15 <textarea id="textarea" style="overflow: hidden; height: 3em; width: 5em; word-wrap: normal;"></textarea>
michael@0 16 <div id="div" contenteditable style="overflow: hidden; height: 3em; width: 5em;"></div>
michael@0 17 </div>
michael@0 18 <div id="content" style="display: none">
michael@0 19
michael@0 20 </div>
michael@0 21 <pre id="test">
michael@0 22 </pre>
michael@0 23
michael@0 24 <script class="testbody" type="application/javascript">
michael@0 25
michael@0 26
michael@0 27 SimpleTest.waitForExplicitFinish();
michael@0 28
michael@0 29 // Turn off spatial navigation because it hijacks arrow key events and VK_RETURN
michael@0 30 // events.
michael@0 31 SpecialPowers.setBoolPref("snav.enabled", false);
michael@0 32
michael@0 33 SimpleTest.waitForFocus(runTests);
michael@0 34
michael@0 35 var textarea = document.getElementById("textarea");
michael@0 36 var div = document.getElementById("div");
michael@0 37
michael@0 38 function hitEventLoop(aFunc, aTimes)
michael@0 39 {
michael@0 40 if (--aTimes) {
michael@0 41 setTimeout(hitEventLoop, 0, aFunc, aTimes);
michael@0 42 } else {
michael@0 43 setTimeout(aFunc, 100);
michael@0 44 }
michael@0 45 }
michael@0 46
michael@0 47 function doKeyEventTest(aElement, aElementDescription, aCallback)
michael@0 48 {
michael@0 49 aElement.focus();
michael@0 50 aElement.scrollTop = 0;
michael@0 51 hitEventLoop(function () {
michael@0 52 is(aElement.scrollTop, 0,
michael@0 53 aElementDescription + "'s scrollTop isn't 0");
michael@0 54 synthesizeKey("VK_RETURN", { });
michael@0 55 synthesizeKey("VK_RETURN", { });
michael@0 56 synthesizeKey("VK_RETURN", { });
michael@0 57 synthesizeKey("VK_RETURN", { });
michael@0 58 synthesizeKey("VK_RETURN", { });
michael@0 59 synthesizeKey("VK_RETURN", { });
michael@0 60 hitEventLoop(function () {
michael@0 61 isnot(aElement.scrollTop, 0,
michael@0 62 aElementDescription + " was not scrolled by inserting line breaks");
michael@0 63 var scrollTop = aElement.scrollTop;
michael@0 64 synthesizeKey("VK_UP", { });
michael@0 65 synthesizeKey("VK_UP", { });
michael@0 66 synthesizeKey("VK_UP", { });
michael@0 67 synthesizeKey("VK_UP", { });
michael@0 68 synthesizeKey("VK_UP", { });
michael@0 69 hitEventLoop(function () {
michael@0 70 isnot(aElement.scrollTop, scrollTop,
michael@0 71 aElementDescription + " was not scrolled by up key events");
michael@0 72 synthesizeKey("VK_DOWN", { });
michael@0 73 synthesizeKey("VK_DOWN", { });
michael@0 74 synthesizeKey("VK_DOWN", { });
michael@0 75 synthesizeKey("VK_DOWN", { });
michael@0 76 synthesizeKey("VK_DOWN", { });
michael@0 77 hitEventLoop(function () {
michael@0 78 is(aElement.scrollTop, scrollTop,
michael@0 79 aElementDescription + " was not scrolled by down key events");
michael@0 80 var longWord = "aaaaaaaaaaaaaaaaaaaa";
michael@0 81 sendString(longWord);
michael@0 82 hitEventLoop(function () {
michael@0 83 isnot(aElement.scrollLeft, 0,
michael@0 84 aElementDescription + " was not scrolled by typing long word");
michael@0 85 var scrollLeft = aElement.scrollLeft;
michael@0 86 var i;
michael@0 87 for (i = 0; i < longWord.length; i++) {
michael@0 88 synthesizeKey("VK_LEFT", { });
michael@0 89 }
michael@0 90 hitEventLoop(function () {
michael@0 91 isnot(aElement.scrollLeft, scrollLeft,
michael@0 92 aElementDescription + " was not scrolled by left key events");
michael@0 93 for (i = 0; i < longWord.length; i++) {
michael@0 94 synthesizeKey("VK_RIGHT", { });
michael@0 95 }
michael@0 96 hitEventLoop(function () {
michael@0 97 is(aElement.scrollLeft, scrollLeft,
michael@0 98 aElementDescription + " was not scrolled by right key events");
michael@0 99 aCallback();
michael@0 100 }, 20);
michael@0 101 }, 20);
michael@0 102 }, 20);
michael@0 103 }, 20);
michael@0 104 }, 20);
michael@0 105 }, 20);
michael@0 106 }, 20);
michael@0 107 }
michael@0 108
michael@0 109 function doCompositionTest(aElement, aElementDescription, aCallback)
michael@0 110 {
michael@0 111 aElement.focus();
michael@0 112 aElement.scrollTop = 0;
michael@0 113 hitEventLoop(function () {
michael@0 114 is(aElement.scrollTop, 0,
michael@0 115 aElementDescription + "'s scrollTop isn't 0");
michael@0 116 synthesizeComposition({ type: "compositionstart" });
michael@0 117 var str = "Web \u958b\u767a\u8005\u306e\u7686\u3055\u3093\u306f\u3001" +
michael@0 118 "Firefox \u306b\u5b9f\u88c5\u3055\u308c\u3066\u3044\u308b HTML5" +
michael@0 119 " \u3084 CSS \u306e\u65b0\u6a5f\u80fd\u3092\u6d3b\u7528\u3059" +
michael@0 120 "\u308b\u3053\u3068\u3067\u3001\u9b45\u529b\u3042\u308b Web " +
michael@0 121 "\u30b5\u30a4\u30c8\u3084\u9769\u65b0\u7684\u306a Web \u30a2" +
michael@0 122 "\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u3088\u308a" +
michael@0 123 "\u77ed\u6642\u9593\u3067\u7c21\u5358\u306b\u4f5c\u6210\u3067" +
michael@0 124 "\u304d\u307e\u3059\u3002";
michael@0 125 synthesizeComposition({ type: "compositionupdate", data: str });
michael@0 126 synthesizeText({
michael@0 127 composition: {
michael@0 128 string: str,
michael@0 129 clauses: [
michael@0 130 { length: str.length, attr: COMPOSITION_ATTR_RAWINPUT }
michael@0 131 ]
michael@0 132 },
michael@0 133 caret: { start: str.length, length: 0 }
michael@0 134 });
michael@0 135 hitEventLoop(function () {
michael@0 136 isnot(aElement.scrollTop, 0,
michael@0 137 aElementDescription + " was not scrolled by composition");
michael@0 138 synthesizeComposition({ type: "compositionupdate", data: "" });
michael@0 139 synthesizeText({
michael@0 140 composition: { string: "", clauses: [ { length: 0, attr: 0 } ] },
michael@0 141 caret: { start: 0, length: 0 }
michael@0 142 });
michael@0 143 synthesizeComposition({ type: "compositionend", data: "" });
michael@0 144 hitEventLoop(function () {
michael@0 145 is(aElement.scrollTop, 0,
michael@0 146 aElementDescription + " was not scrolled back to the top by canceling composition");
michael@0 147 aCallback();
michael@0 148 }, 20);
michael@0 149 }, 20);
michael@0 150 }, 20);
michael@0 151 }
michael@0 152
michael@0 153 function runTests()
michael@0 154 {
michael@0 155 doKeyEventTest(textarea, "textarea",
michael@0 156 function () {
michael@0 157 textarea.value = "";
michael@0 158 doKeyEventTest(div, "div (contenteditable)",
michael@0 159 function () {
michael@0 160 div.innerHTML = "";
michael@0 161 doCompositionTest(textarea, "textarea",
michael@0 162 function () {
michael@0 163 doCompositionTest(div, "div (contenteditable)",
michael@0 164 function () {
michael@0 165 SimpleTest.finish();
michael@0 166 });
michael@0 167 });
michael@0 168 });
michael@0 169 });
michael@0 170 }
michael@0 171
michael@0 172 </script>
michael@0 173 </body>
michael@0 174
michael@0 175 </html>

mercurial