dom/events/test/test_bug534833.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 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=534833
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 534833</title>
michael@0 8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 9 <script type="application/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=534833">Mozilla Bug 534833</a>
michael@0 14 <p id="display"></p>
michael@0 15 <div id="content" style="display: none">
michael@0 16
michael@0 17 </div>
michael@0 18 <pre id="test">
michael@0 19 <script type="application/javascript">
michael@0 20
michael@0 21 /** Test for Bug 534833 **/
michael@0 22 SimpleTest.waitForExplicitFinish();
michael@0 23 addLoadEvent(runTests);
michael@0 24
michael@0 25 var input1GotClick = 0;
michael@0 26 var input2GotClick = 0;
michael@0 27 var textarea1GotClick = 0;
michael@0 28 var textarea2GotClick = 0;
michael@0 29 var div1GotClick = 0;
michael@0 30 var div2GotClick = 0;
michael@0 31
michael@0 32 var tests = [ { element: "text", clickText: true },
michael@0 33 { element: "text2", clickText: false },
michael@0 34 { element: "area", clickText: true },
michael@0 35 { element: "area2", clickText: false },
michael@0 36 { element: "d", clickText: true },
michael@0 37 { element: "d", clickText: false },
michael@0 38 { element: "d2", clickText: true },
michael@0 39 { element: "d2", clickText: false }
michael@0 40 ];
michael@0 41
michael@0 42 function nextTest_() {
michael@0 43 if (!tests.length) {
michael@0 44 finishTests();
michael@0 45 return;
michael@0 46 }
michael@0 47
michael@0 48 var test = tests.shift();
michael@0 49 var el = document.getElementById(test.element);
michael@0 50 el.scrollIntoView(true);
michael@0 51 if (test.clickText) {
michael@0 52 synthesizeMouse(el, 5, 5, {type : "mousedown" });
michael@0 53 synthesizeMouse(el, 5, 5, {type : "mouseup" });
michael@0 54 } else {
michael@0 55 synthesizeMouse(el, el.getBoundingClientRect().width - 5, 5, {type : "mousedown" });
michael@0 56 synthesizeMouse(el, el.getBoundingClientRect().width - 5, 5, {type : "mouseup" });
michael@0 57 }
michael@0 58 nextTest();
michael@0 59 }
michael@0 60
michael@0 61 function nextTest() {
michael@0 62 var el = document.getElementById("initialfocus");
michael@0 63
michael@0 64 el.addEventListener("focus", function() {
michael@0 65 el.removeEventListener("focus", arguments.callee, false);
michael@0 66 setTimeout(nextTest_, 0);
michael@0 67 }, false);
michael@0 68 el.focus();
michael@0 69 }
michael@0 70
michael@0 71 function runTests() {
michael@0 72 var t = document.getElementById("text");
michael@0 73 var t2 = document.getElementById("text2");
michael@0 74 var a = document.getElementById("area");
michael@0 75 var a2 = document.getElementById("area2");
michael@0 76 var d = document.getElementById("d");
michael@0 77 var d2 = document.getElementById("d2");
michael@0 78
michael@0 79 // input 1
michael@0 80 t.onfocus = function(e) {
michael@0 81 t.value = "";
michael@0 82 }
michael@0 83 t.onclick = function(e) {
michael@0 84 ++input1GotClick;
michael@0 85 }
michael@0 86
michael@0 87 // input 2
michael@0 88 t2.onfocus = function(e) {
michael@0 89 t2.value = "";
michael@0 90 }
michael@0 91 t2.onclick = function(e) {
michael@0 92 ++input2GotClick;
michael@0 93 }
michael@0 94
michael@0 95 // textarea 1
michael@0 96 a.onfocus = function(e) {
michael@0 97 a.value = "";
michael@0 98 }
michael@0 99 a.onclick = function(e) {
michael@0 100 ++textarea1GotClick;
michael@0 101 }
michael@0 102
michael@0 103 // textarea 2
michael@0 104 a2.onfocus = function(e) {
michael@0 105 a2.value = "";
michael@0 106 }
michael@0 107 a2.onclick = function(e) {
michael@0 108 ++textarea2GotClick;
michael@0 109 }
michael@0 110
michael@0 111 // div 1
michael@0 112 var c = 0;
michael@0 113 d.onmousedown = function(e) {
michael@0 114 d.textContent = (++c) + " / click before or after |";
michael@0 115 }
michael@0 116 d.onclick = function(e) {
michael@0 117 ++div1GotClick;
michael@0 118 }
michael@0 119
michael@0 120 // div 2
michael@0 121 var c2 = 0;
michael@0 122 d2.onmousedown = function(e) {
michael@0 123 d2.firstChild.data = (++c2) + " / click before or after |";
michael@0 124 }
michael@0 125 d2.onclick = function(e) {
michael@0 126 ++div2GotClick;
michael@0 127 }
michael@0 128 nextTest();
michael@0 129 }
michael@0 130
michael@0 131 function finishTests() {
michael@0 132 is(input1GotClick, 1, "input element should have got a click!");
michael@0 133 is(input2GotClick, 1, "input element should have got a click! (2)");
michael@0 134 is(textarea1GotClick, 1, "textarea element should have got a click!");
michael@0 135 is(textarea2GotClick, 1, "textarea element should have got a click! (2)");
michael@0 136 is(div1GotClick, 2, "div element's content text was replaced, it should have got 2 click!");
michael@0 137 is(div2GotClick, 2, "div element's content text was modified, it should have got 2 clicks!");
michael@0 138 SimpleTest.finish();
michael@0 139 }
michael@0 140
michael@0 141 </script>
michael@0 142 </pre>
michael@0 143 <input type="text" id="initialfocus"><br>
michael@0 144 <input type="text" id="text" value="click before |" style="width: 95%;"><br>
michael@0 145 <input type="text" id="text2" value="click after |" style="width: 95%;">
michael@0 146 <br>
michael@0 147 <textarea id="area" rows="2" style="width: 95%;">
michael@0 148 click before
michael@0 149 |
michael@0 150 </textarea><br>
michael@0 151 <textarea id="area2" rows="2" style="width: 95%;">
michael@0 152 click after |
michael@0 153 </textarea>
michael@0 154 <div id="d" style="border: 1px solid black;">click before or after |</div>
michael@0 155 <div id="d2" style="border: 1px solid black;">click before or after |</div>
michael@0 156 </body>
michael@0 157 </html>

mercurial