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 | <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> |
michael@0 | 4 | <!-- |
michael@0 | 5 | XUL Widget Test for panels |
michael@0 | 6 | --> |
michael@0 | 7 | <window title="Titlebar" width="200" height="200" |
michael@0 | 8 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 9 | <script type="application/javascript" |
michael@0 | 10 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> |
michael@0 | 11 | <script type="application/javascript" |
michael@0 | 12 | src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> |
michael@0 | 13 | |
michael@0 | 14 | <tree id="tree" seltype="single" width="100" height="100"> |
michael@0 | 15 | <treecols> |
michael@0 | 16 | <treecol flex="1"/> |
michael@0 | 17 | <treecol flex="1"/> |
michael@0 | 18 | </treecols> |
michael@0 | 19 | <treechildren id="treechildren"> |
michael@0 | 20 | <treeitem><treerow><treecell label="One"/><treecell label="Two"/></treerow></treeitem> |
michael@0 | 21 | <treeitem><treerow><treecell label="One"/><treecell label="Two"/></treerow></treeitem> |
michael@0 | 22 | <treeitem><treerow><treecell label="One"/><treecell label="Two"/></treerow></treeitem> |
michael@0 | 23 | <treeitem><treerow><treecell label="One"/><treecell label="Two"/></treerow></treeitem> |
michael@0 | 24 | <treeitem><treerow><treecell label="One"/><treecell label="Two"/></treerow></treeitem> |
michael@0 | 25 | <treeitem><treerow><treecell label="One"/><treecell label="Two"/></treerow></treeitem> |
michael@0 | 26 | </treechildren> |
michael@0 | 27 | </tree> |
michael@0 | 28 | |
michael@0 | 29 | |
michael@0 | 30 | <!-- test results are displayed in the html:body --> |
michael@0 | 31 | <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/> |
michael@0 | 32 | |
michael@0 | 33 | <!-- test code goes here --> |
michael@0 | 34 | <script type="application/javascript"><![CDATA[ |
michael@0 | 35 | |
michael@0 | 36 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 37 | |
michael@0 | 38 | var currentTest = null; |
michael@0 | 39 | |
michael@0 | 40 | function ok(condition, message) { |
michael@0 | 41 | window.opener.wrappedJSObject.SimpleTest.ok(condition, message); |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | function is(left, right, message) { |
michael@0 | 45 | window.opener.wrappedJSObject.SimpleTest.is(left, right, message); |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | function test_panels() |
michael@0 | 49 | { |
michael@0 | 50 | checkTreeCoords(); |
michael@0 | 51 | |
michael@0 | 52 | addEventListener("popupshowing", popupShowing, false); |
michael@0 | 53 | addEventListener("popupshown", popupShown, false); |
michael@0 | 54 | addEventListener("popuphidden", nextTest, false); |
michael@0 | 55 | nextTest(); |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | function nextTest() |
michael@0 | 59 | { |
michael@0 | 60 | if (!tests.length) { |
michael@0 | 61 | window.close(); |
michael@0 | 62 | window.opener.wrappedJSObject.SimpleTest.finish(); |
michael@0 | 63 | return; |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | currentTest = tests.shift(); |
michael@0 | 67 | var panel = createPanel(currentTest.attrs); |
michael@0 | 68 | currentTest.test(panel); |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | function popupShowing(event) |
michael@0 | 72 | { |
michael@0 | 73 | var rect = event.target.getOuterScreenRect(); |
michael@0 | 74 | ok(!rect.left && !rect.top && !rect.width && !rect.height, |
michael@0 | 75 | currentTest.testname + " empty rectangle during popupshowing"); |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | var waitSteps = 0; |
michael@0 | 79 | function popupShown(event) |
michael@0 | 80 | { |
michael@0 | 81 | var panel = event.target; |
michael@0 | 82 | |
michael@0 | 83 | if (waitSteps > 0 && navigator.platform.indexOf("Linux") >= 0 && |
michael@0 | 84 | panel.boxObject.screenY == 210) { |
michael@0 | 85 | waitSteps--; |
michael@0 | 86 | setTimeout(popupShown, 10, event); |
michael@0 | 87 | return; |
michael@0 | 88 | } |
michael@0 | 89 | |
michael@0 | 90 | currentTest.result(currentTest.testname + " ", panel); |
michael@0 | 91 | panel.hidePopup(); |
michael@0 | 92 | } |
michael@0 | 93 | |
michael@0 | 94 | function createPanel(attrs) |
michael@0 | 95 | { |
michael@0 | 96 | var panel = document.createElement("panel"); |
michael@0 | 97 | for (var a in attrs) { |
michael@0 | 98 | panel.setAttribute(a, attrs[a]); |
michael@0 | 99 | } |
michael@0 | 100 | |
michael@0 | 101 | var button = document.createElement("button"); |
michael@0 | 102 | panel.appendChild(button); |
michael@0 | 103 | button.label = "OK"; |
michael@0 | 104 | button.width = 120; |
michael@0 | 105 | button.height = 40; |
michael@0 | 106 | button.setAttribute("style", "-moz-appearance: none; border: 0; margin: 0;"); |
michael@0 | 107 | panel.setAttribute("style", "-moz-appearance: none; border: 0; margin: 0;"); |
michael@0 | 108 | return document.documentElement.appendChild(panel); |
michael@0 | 109 | } |
michael@0 | 110 | |
michael@0 | 111 | function checkTreeCoords() |
michael@0 | 112 | { |
michael@0 | 113 | var tree = $("tree"); |
michael@0 | 114 | var treechildren = $("treechildren"); |
michael@0 | 115 | tree.currentIndex = 0; |
michael@0 | 116 | tree.treeBoxObject.scrollToRow(0); |
michael@0 | 117 | synthesizeMouse(treechildren, 10, tree.treeBoxObject.rowHeight + 2, { }); |
michael@0 | 118 | is(tree.currentIndex, 1, "tree selection"); |
michael@0 | 119 | |
michael@0 | 120 | tree.treeBoxObject.scrollToRow(2); |
michael@0 | 121 | synthesizeMouse(treechildren, 10, tree.treeBoxObject.rowHeight + 2, { }); |
michael@0 | 122 | is(tree.currentIndex, 3, "tree selection after scroll"); |
michael@0 | 123 | } |
michael@0 | 124 | |
michael@0 | 125 | var tests = [ |
michael@0 | 126 | { |
michael@0 | 127 | testname: "normal panel", |
michael@0 | 128 | attrs: { }, |
michael@0 | 129 | test: function(panel) { |
michael@0 | 130 | var screenRect = panel.getOuterScreenRect(); |
michael@0 | 131 | is(screenRect.left, 0, this.testname + " screen left before open"); |
michael@0 | 132 | is(screenRect.top, 0, this.testname + " screen top before open"); |
michael@0 | 133 | is(screenRect.width, 0, this.testname + " screen width before open"); |
michael@0 | 134 | is(screenRect.height, 0, this.testname + " screen height before open"); |
michael@0 | 135 | |
michael@0 | 136 | panel.openPopupAtScreen(200, 210); |
michael@0 | 137 | }, |
michael@0 | 138 | result: function(testname, panel) { |
michael@0 | 139 | var panelrect = panel.getBoundingClientRect(); |
michael@0 | 140 | is(panelrect.left, 200 - mozInnerScreenX, testname + "left"); |
michael@0 | 141 | is(panelrect.top, 210 - mozInnerScreenY, testname + "top"); |
michael@0 | 142 | is(panelrect.width, 120, testname + "width"); |
michael@0 | 143 | is(panelrect.height, 40, testname + "height"); |
michael@0 | 144 | |
michael@0 | 145 | var screenRect = panel.getOuterScreenRect(); |
michael@0 | 146 | is(screenRect.left, 200, testname + " screen left"); |
michael@0 | 147 | is(screenRect.top, 210, testname + " screen top"); |
michael@0 | 148 | is(screenRect.width, 120, testname + " screen width"); |
michael@0 | 149 | is(screenRect.height, 40, testname + " screen height"); |
michael@0 | 150 | } |
michael@0 | 151 | }, |
michael@0 | 152 | { |
michael@0 | 153 | // only noautohide panels support titlebars, so one shouldn't be shown here |
michael@0 | 154 | testname: "autohide panel with titlebar", |
michael@0 | 155 | attrs: { titlebar: "normal" }, |
michael@0 | 156 | test: function(panel) { |
michael@0 | 157 | var screenRect = panel.getOuterScreenRect(); |
michael@0 | 158 | is(screenRect.left, 0, this.testname + " screen left before open"); |
michael@0 | 159 | is(screenRect.top, 0, this.testname + " screen top before open"); |
michael@0 | 160 | is(screenRect.width, 0, this.testname + " screen width before open"); |
michael@0 | 161 | is(screenRect.height, 0, this.testname + " screen height before open"); |
michael@0 | 162 | |
michael@0 | 163 | panel.openPopupAtScreen(200, 210); |
michael@0 | 164 | }, |
michael@0 | 165 | result: function(testname, panel) { |
michael@0 | 166 | var panelrect = panel.getBoundingClientRect(); |
michael@0 | 167 | is(panelrect.left, 200 - mozInnerScreenX, testname + "left"); |
michael@0 | 168 | is(panelrect.top, 210 - mozInnerScreenY, testname + "top"); |
michael@0 | 169 | is(panelrect.width, 120, testname + "width"); |
michael@0 | 170 | is(panelrect.height, 40, testname + "height"); |
michael@0 | 171 | |
michael@0 | 172 | var screenRect = panel.getOuterScreenRect(); |
michael@0 | 173 | is(screenRect.left, 200, testname + " screen left"); |
michael@0 | 174 | is(screenRect.top, 210, testname + " screen top"); |
michael@0 | 175 | is(screenRect.width, 120, testname + " screen width"); |
michael@0 | 176 | is(screenRect.height, 40, testname + " screen height"); |
michael@0 | 177 | } |
michael@0 | 178 | }, |
michael@0 | 179 | { |
michael@0 | 180 | testname: "noautohide panel with titlebar", |
michael@0 | 181 | attrs: { noautohide: true, titlebar: "normal" }, |
michael@0 | 182 | test: function(panel) { |
michael@0 | 183 | waitSteps = 25; |
michael@0 | 184 | |
michael@0 | 185 | var screenRect = panel.getOuterScreenRect(); |
michael@0 | 186 | is(screenRect.left, 0, this.testname + " screen left before open"); |
michael@0 | 187 | is(screenRect.top, 0, this.testname + " screen top before open"); |
michael@0 | 188 | is(screenRect.width, 0, this.testname + " screen width before open"); |
michael@0 | 189 | is(screenRect.height, 0, this.testname + " screen height before open"); |
michael@0 | 190 | |
michael@0 | 191 | panel.openPopupAtScreen(200, 210); |
michael@0 | 192 | }, |
michael@0 | 193 | result: function(testname, panel) { |
michael@0 | 194 | var panelrect = panel.getBoundingClientRect(); |
michael@0 | 195 | ok(panelrect.left >= 200 - mozInnerScreenX, testname + "left"); |
michael@0 | 196 | if (navigator.platform.indexOf("Linux") < 0) { |
michael@0 | 197 | ok(panelrect.top >= 210 - mozInnerScreenY + 10, testname + "top greater"); |
michael@0 | 198 | } |
michael@0 | 199 | ok(panelrect.top <= 210 - mozInnerScreenY + 30, testname + "top less"); |
michael@0 | 200 | is(panelrect.width, 120, testname + "width"); |
michael@0 | 201 | is(panelrect.height, 40, testname + "height"); |
michael@0 | 202 | |
michael@0 | 203 | var screenRect = panel.getOuterScreenRect(); |
michael@0 | 204 | if (navigator.platform.indexOf("Linux") < 0) { |
michael@0 | 205 | is(screenRect.left, 200, testname + " screen left"); |
michael@0 | 206 | is(screenRect.top, 210, testname + " screen top"); |
michael@0 | 207 | } |
michael@0 | 208 | ok(screenRect.width >= 120 && screenRect.width <= 140, testname + " screen width"); |
michael@0 | 209 | ok(screenRect.height >= 40 && screenRect.height <= 80, testname + " screen height"); |
michael@0 | 210 | |
michael@0 | 211 | var gotMouseEvent = false; |
michael@0 | 212 | function mouseMoved(event) |
michael@0 | 213 | { |
michael@0 | 214 | is(event.clientY, panelrect.top + 10, |
michael@0 | 215 | "popup clientY"); |
michael@0 | 216 | is(event.screenY, panel.boxObject.screenY + 10, |
michael@0 | 217 | "popup screenY"); |
michael@0 | 218 | is(event.originalTarget, panel.firstChild, "popup target"); |
michael@0 | 219 | gotMouseEvent = true; |
michael@0 | 220 | } |
michael@0 | 221 | |
michael@0 | 222 | panel.addEventListener("mousemove", mouseMoved, true); |
michael@0 | 223 | synthesizeMouse(panel, 10, 10, { type: "mousemove" }); |
michael@0 | 224 | ok(gotMouseEvent, "mouse event on panel"); |
michael@0 | 225 | panel.removeEventListener("mousemove", mouseMoved, true); |
michael@0 | 226 | |
michael@0 | 227 | var tree = $("tree"); |
michael@0 | 228 | tree.currentIndex = 0; |
michael@0 | 229 | panel.appendChild(tree); |
michael@0 | 230 | checkTreeCoords(); |
michael@0 | 231 | } |
michael@0 | 232 | }, |
michael@0 | 233 | { |
michael@0 | 234 | testname: "noautohide panel with backdrag", |
michael@0 | 235 | attrs: { noautohide: true, backdrag: "true" }, |
michael@0 | 236 | test: function(panel) { |
michael@0 | 237 | var label = document.createElement("label"); |
michael@0 | 238 | label.id = "backdragspot"; |
michael@0 | 239 | label.setAttribute("value", "Hello There"); |
michael@0 | 240 | panel.appendChild(label); |
michael@0 | 241 | panel.openPopupAtScreen(200, 230); |
michael@0 | 242 | }, |
michael@0 | 243 | result: function(testname, panel) { |
michael@0 | 244 | var oldrect = panel.getOuterScreenRect(); |
michael@0 | 245 | |
michael@0 | 246 | // Linux uses native window moving |
michael@0 | 247 | if (navigator.platform.indexOf("Linux") == -1) { |
michael@0 | 248 | var backdragspot = document.getElementById("backdragspot"); |
michael@0 | 249 | synthesizeMouse(backdragspot, 5, 5, { type: "mousedown" }); |
michael@0 | 250 | synthesizeMouse(backdragspot, 15, 20, { type: "mousemove" }); |
michael@0 | 251 | synthesizeMouse(backdragspot, 15, 20, { type: "mouseup" }); |
michael@0 | 252 | |
michael@0 | 253 | is(panel.getOuterScreenRect().left, 210, testname + "left"); |
michael@0 | 254 | is(panel.getOuterScreenRect().top, 245, testname + "top"); |
michael@0 | 255 | } |
michael@0 | 256 | } |
michael@0 | 257 | }, |
michael@0 | 258 | { |
michael@0 | 259 | // The panel should be allowed to appear and remain offscreen |
michael@0 | 260 | testname: "normal panel with flip='none' off-screen", |
michael@0 | 261 | attrs: { "flip": "none" }, |
michael@0 | 262 | test: function(panel) { |
michael@0 | 263 | panel.openPopup(document.documentElement, "", -100 - mozInnerScreenX, -100 - mozInnerScreenY, false, false, null); |
michael@0 | 264 | }, |
michael@0 | 265 | result: function(testname, panel) { |
michael@0 | 266 | var panelrect = panel.getBoundingClientRect(); |
michael@0 | 267 | is(panelrect.left, -100 - mozInnerScreenX, testname + "left"); |
michael@0 | 268 | is(panelrect.top, -100 - mozInnerScreenY, testname + "top"); |
michael@0 | 269 | is(panelrect.width, 120, testname + "width"); |
michael@0 | 270 | is(panelrect.height, 40, testname + "height"); |
michael@0 | 271 | |
michael@0 | 272 | var screenRect = panel.getOuterScreenRect(); |
michael@0 | 273 | is(screenRect.left, -100, testname + " screen left"); |
michael@0 | 274 | is(screenRect.top, -100, testname + " screen top"); |
michael@0 | 275 | is(screenRect.width, 120, testname + " screen width"); |
michael@0 | 276 | is(screenRect.height, 40, testname + " screen height"); |
michael@0 | 277 | } |
michael@0 | 278 | }, |
michael@0 | 279 | { |
michael@0 | 280 | // The panel should be allowed to remain offscreen after moving and it should follow the anchor |
michael@0 | 281 | testname: "normal panel with flip='none' moved off-screen", |
michael@0 | 282 | attrs: { "flip": "none" }, |
michael@0 | 283 | test: function(panel) { |
michael@0 | 284 | panel.openPopup(document.documentElement, "", -100 - mozInnerScreenX, -100 - mozInnerScreenY, false, false, null); |
michael@0 | 285 | window.moveBy(-50, -50); |
michael@0 | 286 | }, |
michael@0 | 287 | result: function(testname, panel) { |
michael@0 | 288 | if (navigator.platform.indexOf("Linux") >= 0) { |
michael@0 | 289 | // The window position doesn't get updated immediately on Linux. |
michael@0 | 290 | return; |
michael@0 | 291 | } |
michael@0 | 292 | var panelrect = panel.getBoundingClientRect(); |
michael@0 | 293 | is(panelrect.left, -150 - mozInnerScreenX, testname + "left"); |
michael@0 | 294 | is(panelrect.top, -150 - mozInnerScreenY, testname + "top"); |
michael@0 | 295 | is(panelrect.width, 120, testname + "width"); |
michael@0 | 296 | is(panelrect.height, 40, testname + "height"); |
michael@0 | 297 | |
michael@0 | 298 | var screenRect = panel.getOuterScreenRect(); |
michael@0 | 299 | is(screenRect.left, -150, testname + " screen left"); |
michael@0 | 300 | is(screenRect.top, -150, testname + " screen top"); |
michael@0 | 301 | is(screenRect.width, 120, testname + " screen width"); |
michael@0 | 302 | is(screenRect.height, 40, testname + " screen height"); |
michael@0 | 303 | } |
michael@0 | 304 | }, |
michael@0 | 305 | ]; |
michael@0 | 306 | |
michael@0 | 307 | window.opener.wrappedJSObject.SimpleTest.waitForFocus(test_panels, window); |
michael@0 | 308 | |
michael@0 | 309 | ]]> |
michael@0 | 310 | </script> |
michael@0 | 311 | |
michael@0 | 312 | </window> |