Sat, 03 Jan 2015 20:18:00 +0100
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 | <!-- |
michael@0 | 4 | XUL Widget Test for the titlebar element and window dragging |
michael@0 | 5 | --> |
michael@0 | 6 | <window title="Titlebar" width="200" height="200" |
michael@0 | 7 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 8 | |
michael@0 | 9 | <script type="application/javascript" |
michael@0 | 10 | src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> |
michael@0 | 11 | |
michael@0 | 12 | <titlebar id="titlebar"> |
michael@0 | 13 | <label id="label" value="Titlebar"/> |
michael@0 | 14 | </titlebar> |
michael@0 | 15 | |
michael@0 | 16 | <!-- a non-noautohide panel is treated as anchored --> |
michael@0 | 17 | <panel id="panel" onpopupshown="popupshown(this, false)" onpopuphidden="popuphidden('panelnoautohide')"> |
michael@0 | 18 | <titlebar> |
michael@0 | 19 | <label id="panellabel" value="Titlebar"/> |
michael@0 | 20 | </titlebar> |
michael@0 | 21 | </panel> |
michael@0 | 22 | |
michael@0 | 23 | <panel id="panelnoautohide" noautohide="true" |
michael@0 | 24 | onpopupshown="popupshown(this, false)" onpopuphidden="popuphidden('panelanchored')"> |
michael@0 | 25 | <titlebar> |
michael@0 | 26 | <label id="panellabelnoautohide" value="Titlebar"/> |
michael@0 | 27 | </titlebar> |
michael@0 | 28 | </panel> |
michael@0 | 29 | |
michael@0 | 30 | <panel id="panelanchored" noautohide="true" |
michael@0 | 31 | onpopupshown="popupshown(this, true)" onpopuphidden="popuphidden('paneltop')"> |
michael@0 | 32 | <titlebar> |
michael@0 | 33 | <label id="panellabelanchored" value="Titlebar"/> |
michael@0 | 34 | </titlebar> |
michael@0 | 35 | </panel> |
michael@0 | 36 | |
michael@0 | 37 | <panel id="paneltop" noautohide="true" level="top" |
michael@0 | 38 | onpopupshown="popupshown(this, false)" onpopuphidden="popuphidden('panelfloating')"> |
michael@0 | 39 | <titlebar> |
michael@0 | 40 | <label id="panellabeltop" value="Titlebar"/> |
michael@0 | 41 | </titlebar> |
michael@0 | 42 | </panel> |
michael@0 | 43 | |
michael@0 | 44 | <panel id="panelfloating" noautohide="true" level="floating" |
michael@0 | 45 | onpopupshown="popupshown(this, false)" onpopuphidden="popuphidden('')"> |
michael@0 | 46 | <titlebar> |
michael@0 | 47 | <label id="panellabelfloating" value="Titlebar"/> |
michael@0 | 48 | </titlebar> |
michael@0 | 49 | </panel> |
michael@0 | 50 | |
michael@0 | 51 | <button id="button" label="OK"/> |
michael@0 | 52 | <statusbar id="statusbar"> |
michael@0 | 53 | <statusbarpanel> |
michael@0 | 54 | <label id="statuslabel" value="Status"/> |
michael@0 | 55 | </statusbarpanel> |
michael@0 | 56 | </statusbar> |
michael@0 | 57 | |
michael@0 | 58 | <script> |
michael@0 | 59 | <![CDATA[ |
michael@0 | 60 | |
michael@0 | 61 | var SimpleTest = window.opener.wrappedJSObject.SimpleTest; |
michael@0 | 62 | |
michael@0 | 63 | SimpleTest.waitForFocus(test_titlebar, window); |
michael@0 | 64 | |
michael@0 | 65 | var mouseDownTarget; |
michael@0 | 66 | var origoldx, origoldy, oldx, oldy, waitSteps = 0; |
michael@0 | 67 | function waitForWindowMove(element, x, y, callback, arg, panel, anchored) |
michael@0 | 68 | { |
michael@0 | 69 | var isPanelMove = (element.id != "label"); |
michael@0 | 70 | |
michael@0 | 71 | if (!waitSteps) { |
michael@0 | 72 | oldx = isPanelMove ? panel.getBoundingClientRect().left : window.screenX; |
michael@0 | 73 | oldy = isPanelMove ? panel.getBoundingClientRect().top : window.screenY; |
michael@0 | 74 | synthesizeMouse(element, x, y, { type: "mousemove" }); |
michael@0 | 75 | } |
michael@0 | 76 | |
michael@0 | 77 | var newx = isPanelMove ? panel.getBoundingClientRect().left : window.screenX; |
michael@0 | 78 | var newy = isPanelMove ? panel.getBoundingClientRect().top : window.screenY; |
michael@0 | 79 | if (newx == oldx && newy == oldy) { |
michael@0 | 80 | if (waitSteps++ > 10) { |
michael@0 | 81 | SimpleTest.is(window.screenX + "," + window.screenY, oldx + "," + oldy + " ", |
michael@0 | 82 | "Window never moved properly to " + x + "," + y + (panel ? " " + panel.id : "")); |
michael@0 | 83 | window.opener.wrappedJSObject.SimpleTest.finish(); |
michael@0 | 84 | window.close(); |
michael@0 | 85 | return; |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | setTimeout(waitForWindowMove, 100, element, x, y, callback, arg, panel, anchored); |
michael@0 | 89 | } |
michael@0 | 90 | else { |
michael@0 | 91 | waitSteps = 0; |
michael@0 | 92 | |
michael@0 | 93 | // on Linux, we need to wait a bit for the popup to be moved as well |
michael@0 | 94 | if (navigator.platform.indexOf("Linux") >= 0) { |
michael@0 | 95 | setTimeout(callback, 0, arg, panel, anchored); |
michael@0 | 96 | } |
michael@0 | 97 | else { |
michael@0 | 98 | callback(arg, panel, anchored); |
michael@0 | 99 | } |
michael@0 | 100 | } |
michael@0 | 101 | } |
michael@0 | 102 | |
michael@0 | 103 | function test_titlebar() |
michael@0 | 104 | { |
michael@0 | 105 | var titlebar = document.getElementById("titlebar"); |
michael@0 | 106 | var label = document.getElementById("label"); |
michael@0 | 107 | |
michael@0 | 108 | // On Mac, the window can also be moved with the statusbar, but this works |
michael@0 | 109 | // via the MozMouseHittest event, not via mouse events. |
michael@0 | 110 | if (navigator.platform.indexOf("Mac") >= 0) { |
michael@0 | 111 | var preventDefaulted; |
michael@0 | 112 | |
michael@0 | 113 | var statuslabel = document.getElementById("statuslabel"); |
michael@0 | 114 | preventDefaulted = synthesizeMouse(statuslabel, 2, 2, { type: "MozMouseHittest" }); |
michael@0 | 115 | SimpleTest.ok(preventDefaulted, "MozMouseHittest should have been defaultPrevented over statusbar"); |
michael@0 | 116 | |
michael@0 | 117 | var button = document.getElementById("button"); |
michael@0 | 118 | preventDefaulted = synthesizeMouse(button, 2, 2, { type: "MozMouseHittest" }); |
michael@0 | 119 | SimpleTest.ok(!preventDefaulted, "MozMouseHittest should NOT have been defaultPrevented over button"); |
michael@0 | 120 | } |
michael@0 | 121 | |
michael@0 | 122 | origoldx = window.screenX; |
michael@0 | 123 | origoldy = window.screenY; |
michael@0 | 124 | |
michael@0 | 125 | var mousedownListener = function (event) mouseDownTarget = event.originalTarget; |
michael@0 | 126 | window.addEventListener("mousedown", mousedownListener, false); |
michael@0 | 127 | synthesizeMouse(label, 2, 2, { type: "mousedown" }); |
michael@0 | 128 | SimpleTest.is(mouseDownTarget, titlebar, "movedown on titlebar"); |
michael@0 | 129 | waitForWindowMove(label, 22, 22, test_titlebar_step2, mousedownListener); |
michael@0 | 130 | } |
michael@0 | 131 | |
michael@0 | 132 | function test_titlebar_step2(mousedownListener) |
michael@0 | 133 | { |
michael@0 | 134 | var titlebar = document.getElementById("titlebar"); |
michael@0 | 135 | var label = document.getElementById("label"); |
michael@0 | 136 | |
michael@0 | 137 | SimpleTest.is(window.screenX, origoldx + 20, "move window horizontal"); |
michael@0 | 138 | SimpleTest.is(window.screenY, origoldy + 20, "move window vertical"); |
michael@0 | 139 | synthesizeMouse(label, 22, 22, { type: "mouseup" }); |
michael@0 | 140 | |
michael@0 | 141 | // with allowEvents set to true, the mouse should target the label instead |
michael@0 | 142 | // and not move the window |
michael@0 | 143 | titlebar.allowEvents = true; |
michael@0 | 144 | |
michael@0 | 145 | synthesizeMouse(label, 2, 2, { type: "mousedown" }); |
michael@0 | 146 | SimpleTest.is(mouseDownTarget, label, "movedown on titlebar with allowevents"); |
michael@0 | 147 | synthesizeMouse(label, 22, 22, { type: "mousemove" }); |
michael@0 | 148 | SimpleTest.is(window.screenX, origoldx + 20, "mouse on label move window horizontal"); |
michael@0 | 149 | SimpleTest.is(window.screenY, origoldy + 20, "mouse on label move window vertical"); |
michael@0 | 150 | synthesizeMouse(label, 22, 22, { type: "mouseup" }); |
michael@0 | 151 | |
michael@0 | 152 | window.removeEventListener("mousedown", mousedownListener, false); |
michael@0 | 153 | |
michael@0 | 154 | document.getElementById("panel").openPopupAtScreen(window.screenX + 50, window.screenY + 60, false); |
michael@0 | 155 | } |
michael@0 | 156 | |
michael@0 | 157 | function popupshown(panel, anchored) |
michael@0 | 158 | { |
michael@0 | 159 | var rect = panel.getBoundingClientRect(); |
michael@0 | 160 | |
michael@0 | 161 | // skip this check for non-noautohide panels |
michael@0 | 162 | if (panel.id == "panel") { |
michael@0 | 163 | var panellabel = panel.firstChild.firstChild; |
michael@0 | 164 | synthesizeMouse(panellabel, 2, 2, { type: "mousedown" }); |
michael@0 | 165 | waitForWindowMove(panellabel, 22, 22, popupshown_step3, rect, panel, anchored); |
michael@0 | 166 | return; |
michael@0 | 167 | } |
michael@0 | 168 | |
michael@0 | 169 | // now, try moving the window. If anchored, the popup should move with the |
michael@0 | 170 | // window. If not anchored, the popup should remain at its current screen location. |
michael@0 | 171 | window.moveBy(10, 10); |
michael@0 | 172 | waitSteps = 1; |
michael@0 | 173 | waitForWindowMove(document.getElementById("label"), 1, 1, popupshown_step2, rect, panel, anchored); |
michael@0 | 174 | } |
michael@0 | 175 | |
michael@0 | 176 | function popupshown_step2(oldrect, panel, anchored) |
michael@0 | 177 | { |
michael@0 | 178 | var newrect = panel.getBoundingClientRect(); |
michael@0 | 179 | |
michael@0 | 180 | // The window movement that occured long ago at the beginning of the test |
michael@0 | 181 | // on Linux is delayed and there isn't any way to tell when the move |
michael@0 | 182 | // actually happened. This causes the checks here to fail. Instead, just |
michael@0 | 183 | // wait a bit for the test to be ready. |
michael@0 | 184 | if (navigator.platform.indexOf("Linux") >= 0 && |
michael@0 | 185 | newrect.left != oldrect.left - (anchored ? 0 : 10)) { |
michael@0 | 186 | setTimeout(popupshown_step2, 10, oldrect, panel, anchored); |
michael@0 | 187 | return; |
michael@0 | 188 | } |
michael@0 | 189 | |
michael@0 | 190 | // anchored popups should still be at the same offset. Non-anchored popups will |
michael@0 | 191 | // now be offset by 10 pixels less. |
michael@0 | 192 | SimpleTest.is(newrect.left, oldrect.left - (anchored ? 0 : 10), |
michael@0 | 193 | panel.id + " horizontal after window move"); |
michael@0 | 194 | SimpleTest.is(newrect.top, oldrect.top - (anchored ? 0 : 10), |
michael@0 | 195 | panel.id + " vertical after window move"); |
michael@0 | 196 | |
michael@0 | 197 | var panellabel = panel.firstChild.firstChild; |
michael@0 | 198 | synthesizeMouse(panellabel, 2, 2, { type: "mousedown" }); |
michael@0 | 199 | waitForWindowMove(panellabel, 22, 22, popupshown_step3, newrect, panel, anchored); |
michael@0 | 200 | } |
michael@0 | 201 | |
michael@0 | 202 | function popupshown_step3(oldrect, panel, anchored) |
michael@0 | 203 | { |
michael@0 | 204 | // skip this check on Linux for the same window positioning reasons as above |
michael@0 | 205 | if (navigator.platform.indexOf("Linux") == -1 || (panel.id != "panelanchored" && panel.id != "paneltop")) { |
michael@0 | 206 | // next, drag the titlebar in the panel |
michael@0 | 207 | var newrect = panel.getBoundingClientRect(); |
michael@0 | 208 | SimpleTest.is(newrect.left, oldrect.left + 20, panel.id + " move popup horizontal"); |
michael@0 | 209 | SimpleTest.is(newrect.top, oldrect.top + 20, panel.id + " move popup vertical"); |
michael@0 | 210 | synthesizeMouse(document.getElementById("panellabel"), 22, 22, { type: "mouseup" }); |
michael@0 | 211 | |
michael@0 | 212 | synthesizeMouse(document.getElementById("button"), 5, 5, { type: "mousemove" }); |
michael@0 | 213 | newrect = panel.getBoundingClientRect(); |
michael@0 | 214 | SimpleTest.is(newrect.left, oldrect.left + 20, panel.id + " horizontal after mouse on button"); |
michael@0 | 215 | SimpleTest.is(newrect.top, oldrect.top + 20, panel.id + " vertical after mouse on button"); |
michael@0 | 216 | } |
michael@0 | 217 | else { |
michael@0 | 218 | synthesizeMouse(document.getElementById("panellabel"), 22, 22, { type: "mouseup" }); |
michael@0 | 219 | } |
michael@0 | 220 | |
michael@0 | 221 | panel.hidePopup(); |
michael@0 | 222 | } |
michael@0 | 223 | |
michael@0 | 224 | function popuphidden(nextPopup) |
michael@0 | 225 | { |
michael@0 | 226 | if (nextPopup) { |
michael@0 | 227 | var panel = document.getElementById(nextPopup); |
michael@0 | 228 | if (panel.id == "panelnoautohide") { |
michael@0 | 229 | panel.openPopupAtScreen(window.screenX + 50, window.screenY + 60, false); |
michael@0 | 230 | } |
michael@0 | 231 | else { |
michael@0 | 232 | panel.openPopup(document.getElementById("button"), "after_start"); |
michael@0 | 233 | } |
michael@0 | 234 | } |
michael@0 | 235 | else |
michael@0 | 236 | window.opener.wrappedJSObject.done(window); |
michael@0 | 237 | } |
michael@0 | 238 | |
michael@0 | 239 | ]]> |
michael@0 | 240 | </script> |
michael@0 | 241 | |
michael@0 | 242 | </window> |