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 | <window title="Tooltip Tests" |
michael@0 | 6 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 7 | |
michael@0 | 8 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 10 | <script type="application/javascript" src="popup_shared.js"></script> |
michael@0 | 11 | |
michael@0 | 12 | <tooltip id="thetooltip"> |
michael@0 | 13 | <label id="label" value="This is a tooltip"/> |
michael@0 | 14 | </tooltip> |
michael@0 | 15 | |
michael@0 | 16 | <box tooltiptext="Box Tooltip"> |
michael@0 | 17 | <button id="withtext" label="Tooltip Text" tooltiptext="Button Tooltip" |
michael@0 | 18 | style="-moz-appearance: none; padding: 0;"/> |
michael@0 | 19 | <button id="without" label="No Tooltip" style="-moz-appearance: none; padding: 0;"/> |
michael@0 | 20 | <!-- remove the native theme and borders to avoid some platform |
michael@0 | 21 | specific sizing differences --> |
michael@0 | 22 | <button id="withtooltip" label="Tooltip Element" tooltip="thetooltip" |
michael@0 | 23 | class="plain" style="-moz-appearance: none; padding: 0;"/> |
michael@0 | 24 | <iframe id="childframe" type="content" width="10" height="10" |
michael@0 | 25 | src="http://sectest2.example.org:80/chrome/toolkit/content/tests/chrome/popup_childframe_node.xul"/> |
michael@0 | 26 | </box> |
michael@0 | 27 | |
michael@0 | 28 | <script class="testbody" type="application/javascript"> |
michael@0 | 29 | <![CDATA[ |
michael@0 | 30 | |
michael@0 | 31 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 32 | var gOriginalWidth = -1; |
michael@0 | 33 | var gOriginalHeight = -1; |
michael@0 | 34 | var gButton = null; |
michael@0 | 35 | |
michael@0 | 36 | function runTest() |
michael@0 | 37 | { |
michael@0 | 38 | startPopupTests(popupTests); |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | function checkCoords(event) |
michael@0 | 42 | { |
michael@0 | 43 | // all but one test open the tooltip at the button location offset by 6 |
michael@0 | 44 | // in each direction. Test 5 opens it at 4 in each direction. |
michael@0 | 45 | var mod = (gTestIndex == 5) ? 4 : 6; |
michael@0 | 46 | |
michael@0 | 47 | var rect = gButton.getBoundingClientRect(); |
michael@0 | 48 | var popupstyle = window.getComputedStyle(gButton, ""); |
michael@0 | 49 | is(event.clientX, Math.round(rect.left + mod), |
michael@0 | 50 | "step " + (gTestIndex + 1) + " clientX"); |
michael@0 | 51 | is(event.clientY, Math.round(rect.top + mod), |
michael@0 | 52 | "step " + (gTestIndex + 1) + " clientY"); |
michael@0 | 53 | ok(event.screenX > 0, "step " + (gTestIndex + 1) + " screenX"); |
michael@0 | 54 | ok(event.screenY > 0, "step " + (gTestIndex + 1) + " screenY"); |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | var popupTests = [ |
michael@0 | 58 | { |
michael@0 | 59 | testname: "hover tooltiptext attribute", |
michael@0 | 60 | events: [ "popupshowing #tooltip", "popupshown #tooltip" ], |
michael@0 | 61 | test: function() { |
michael@0 | 62 | gButton = document.getElementById("withtext"); |
michael@0 | 63 | disableNonTestMouse(true); |
michael@0 | 64 | synthesizeMouse(gButton, 2, 2, { type: "mouseover" }); |
michael@0 | 65 | synthesizeMouse(gButton, 4, 4, { type: "mousemove" }); |
michael@0 | 66 | synthesizeMouse(gButton, 6, 6, { type: "mousemove" }); |
michael@0 | 67 | disableNonTestMouse(false); |
michael@0 | 68 | } |
michael@0 | 69 | }, |
michael@0 | 70 | { |
michael@0 | 71 | testname: "close tooltip", |
michael@0 | 72 | events: [ "popuphiding #tooltip", "popuphidden #tooltip", |
michael@0 | 73 | "DOMMenuInactive #tooltip" ], |
michael@0 | 74 | test: function() { |
michael@0 | 75 | disableNonTestMouse(true); |
michael@0 | 76 | synthesizeMouse(document.documentElement, 2, 2, { type: "mousemove" }); |
michael@0 | 77 | disableNonTestMouse(false); |
michael@0 | 78 | } |
michael@0 | 79 | }, |
michael@0 | 80 | { |
michael@0 | 81 | testname: "hover inherited tooltip", |
michael@0 | 82 | events: [ "popupshowing #tooltip", "popupshown #tooltip" ], |
michael@0 | 83 | test: function() { |
michael@0 | 84 | gButton = document.getElementById("without"); |
michael@0 | 85 | disableNonTestMouse(true); |
michael@0 | 86 | synthesizeMouse(gButton, 2, 2, { type: "mouseover" }); |
michael@0 | 87 | synthesizeMouse(gButton, 4, 4, { type: "mousemove" }); |
michael@0 | 88 | synthesizeMouse(gButton, 6, 6, { type: "mousemove" }); |
michael@0 | 89 | disableNonTestMouse(false); |
michael@0 | 90 | } |
michael@0 | 91 | }, |
michael@0 | 92 | { |
michael@0 | 93 | testname: "hover tooltip attribute", |
michael@0 | 94 | events: [ "popuphiding #tooltip", "popuphidden #tooltip", |
michael@0 | 95 | "DOMMenuInactive #tooltip", |
michael@0 | 96 | "popupshowing thetooltip", "popupshown thetooltip" ], |
michael@0 | 97 | test: function() { |
michael@0 | 98 | gButton = document.getElementById("withtooltip"); |
michael@0 | 99 | gExpectedTriggerNode = gButton; |
michael@0 | 100 | disableNonTestMouse(true); |
michael@0 | 101 | synthesizeMouse(gButton, 2, 2, { type: "mouseover" }); |
michael@0 | 102 | synthesizeMouse(gButton, 4, 4, { type: "mousemove" }); |
michael@0 | 103 | synthesizeMouse(gButton, 6, 6, { type: "mousemove" }); |
michael@0 | 104 | disableNonTestMouse(false); |
michael@0 | 105 | }, |
michael@0 | 106 | result: function(testname) { |
michael@0 | 107 | var tooltip = document.getElementById("thetooltip"); |
michael@0 | 108 | gExpectedTriggerNode = null; |
michael@0 | 109 | is(tooltip.triggerNode, gButton, testname + " triggerNode"); |
michael@0 | 110 | is(document.popupNode, null, testname + " document.popupNode"); |
michael@0 | 111 | is(document.tooltipNode, gButton, testname + " document.tooltipNode"); |
michael@0 | 112 | |
michael@0 | 113 | var child = $("childframe").contentDocument; |
michael@0 | 114 | var evt = child.createEvent("Event"); |
michael@0 | 115 | evt.initEvent("click", true, true); |
michael@0 | 116 | child.documentElement.dispatchEvent(evt); |
michael@0 | 117 | is(child.documentElement.getAttribute("data"), "xnull", |
michael@0 | 118 | "cannot get tooltipNode from other document"); |
michael@0 | 119 | |
michael@0 | 120 | var buttonrect = document.getElementById("withtooltip").getBoundingClientRect(); |
michael@0 | 121 | var rect = tooltip.getBoundingClientRect(); |
michael@0 | 122 | var popupstyle = window.getComputedStyle(document.getElementById("thetooltip"), ""); |
michael@0 | 123 | |
michael@0 | 124 | is(Math.round(rect.left), |
michael@0 | 125 | Math.round(buttonrect.left + parseFloat(popupstyle.marginLeft) + 6), |
michael@0 | 126 | testname + " left position of tooltip"); |
michael@0 | 127 | is(Math.round(rect.top), |
michael@0 | 128 | Math.round(buttonrect.top + parseFloat(popupstyle.marginTop) + 6), |
michael@0 | 129 | testname + " top position of tooltip"); |
michael@0 | 130 | |
michael@0 | 131 | var labelrect = document.getElementById("label").getBoundingClientRect(); |
michael@0 | 132 | ok(labelrect.right < rect.right, testname + " tooltip width"); |
michael@0 | 133 | ok(labelrect.bottom < rect.bottom, testname + " tooltip height"); |
michael@0 | 134 | |
michael@0 | 135 | gOriginalWidth = rect.right - rect.left; |
michael@0 | 136 | gOriginalHeight = rect.bottom - rect.top; |
michael@0 | 137 | } |
michael@0 | 138 | }, |
michael@0 | 139 | { |
michael@0 | 140 | testname: "click to close tooltip", |
michael@0 | 141 | events: [ "popuphiding thetooltip", "popuphidden thetooltip", |
michael@0 | 142 | "command withtooltip", "DOMMenuInactive thetooltip" ], |
michael@0 | 143 | test: function() { |
michael@0 | 144 | gButton = document.getElementById("withtooltip"); |
michael@0 | 145 | synthesizeMouse(gButton, 2, 2, { }); |
michael@0 | 146 | }, |
michael@0 | 147 | result: function(testname) { |
michael@0 | 148 | var tooltip = document.getElementById("thetooltip"); |
michael@0 | 149 | is(tooltip.triggerNode, null, testname + " triggerNode"); |
michael@0 | 150 | is(document.popupNode, null, testname + " document.popupNode"); |
michael@0 | 151 | is(document.tooltipNode, null, testname + " document.tooltipNode"); |
michael@0 | 152 | } |
michael@0 | 153 | }, |
michael@0 | 154 | { |
michael@0 | 155 | testname: "hover tooltip after size increased", |
michael@0 | 156 | events: [ "popupshowing thetooltip", "popupshown thetooltip" ], |
michael@0 | 157 | test: function() { |
michael@0 | 158 | var label = document.getElementById("label"); |
michael@0 | 159 | label.removeAttribute("value"); |
michael@0 | 160 | label.textContent = "This is a longer tooltip than before\nIt has multiple lines\nIt is testing tooltip sizing\n"; |
michael@0 | 161 | gButton = document.getElementById("withtooltip"); |
michael@0 | 162 | disableNonTestMouse(true); |
michael@0 | 163 | synthesizeMouse(gButton, 2, 2, { type: "mouseover" }); |
michael@0 | 164 | synthesizeMouse(gButton, 6, 6, { type: "mousemove" }); |
michael@0 | 165 | synthesizeMouse(gButton, 4, 4, { type: "mousemove" }); |
michael@0 | 166 | disableNonTestMouse(false); |
michael@0 | 167 | }, |
michael@0 | 168 | result: function(testname) { |
michael@0 | 169 | var buttonrect = document.getElementById("withtooltip").getBoundingClientRect(); |
michael@0 | 170 | var rect = document.getElementById("thetooltip").getBoundingClientRect(); |
michael@0 | 171 | var popupstyle = window.getComputedStyle(document.getElementById("thetooltip"), ""); |
michael@0 | 172 | var buttonstyle = window.getComputedStyle(document.getElementById("withtooltip"), ""); |
michael@0 | 173 | |
michael@0 | 174 | is(Math.round(rect.left), |
michael@0 | 175 | Math.round(buttonrect.left + parseFloat(popupstyle.marginLeft) + 4), |
michael@0 | 176 | testname + " left position of tooltip"); |
michael@0 | 177 | is(Math.round(rect.top), |
michael@0 | 178 | Math.round(buttonrect.top + parseFloat(popupstyle.marginTop) + 4), |
michael@0 | 179 | testname + " top position of tooltip"); |
michael@0 | 180 | |
michael@0 | 181 | var labelrect = document.getElementById("label").getBoundingClientRect(); |
michael@0 | 182 | ok(labelrect.right < rect.right, testname + " tooltip width"); |
michael@0 | 183 | ok(labelrect.bottom < rect.bottom, testname + " tooltip height"); |
michael@0 | 184 | |
michael@0 | 185 | // make sure that the tooltip is larger than it was before by just |
michael@0 | 186 | // checking against the original height plus an arbitrary 15 pixels |
michael@0 | 187 | ok(gOriginalWidth + 15 < rect.right - rect.left, testname + " tooltip is wider"); |
michael@0 | 188 | ok(gOriginalHeight + 15 < rect.bottom - rect.top, testname + " tooltip is taller"); |
michael@0 | 189 | } |
michael@0 | 190 | }, |
michael@0 | 191 | { |
michael@0 | 192 | testname: "close tooltip with hidePopup", |
michael@0 | 193 | events: [ "popuphiding thetooltip", "popuphidden thetooltip", |
michael@0 | 194 | "DOMMenuInactive thetooltip" ], |
michael@0 | 195 | test: function() { |
michael@0 | 196 | document.getElementById("thetooltip").hidePopup(); |
michael@0 | 197 | }, |
michael@0 | 198 | }, |
michael@0 | 199 | { |
michael@0 | 200 | testname: "hover tooltip after size decreased", |
michael@0 | 201 | events: [ "popupshowing thetooltip", "popupshown thetooltip" ], |
michael@0 | 202 | autohide: "thetooltip", |
michael@0 | 203 | test: function() { |
michael@0 | 204 | var label = document.getElementById("label"); |
michael@0 | 205 | label.value = "This is a tooltip"; |
michael@0 | 206 | gButton = document.getElementById("withtooltip"); |
michael@0 | 207 | disableNonTestMouse(true); |
michael@0 | 208 | synthesizeMouse(gButton, 2, 2, { type: "mouseover" }); |
michael@0 | 209 | synthesizeMouse(gButton, 4, 4, { type: "mousemove" }); |
michael@0 | 210 | synthesizeMouse(gButton, 6, 6, { type: "mousemove" }); |
michael@0 | 211 | disableNonTestMouse(false); |
michael@0 | 212 | }, |
michael@0 | 213 | result: function(testname) { |
michael@0 | 214 | var buttonrect = document.getElementById("withtooltip").getBoundingClientRect(); |
michael@0 | 215 | var rect = document.getElementById("thetooltip").getBoundingClientRect(); |
michael@0 | 216 | var popupstyle = window.getComputedStyle(document.getElementById("thetooltip"), ""); |
michael@0 | 217 | var buttonstyle = window.getComputedStyle(document.getElementById("withtooltip"), ""); |
michael@0 | 218 | |
michael@0 | 219 | is(Math.round(rect.left), |
michael@0 | 220 | Math.round(buttonrect.left + parseFloat(popupstyle.marginLeft) + 6), |
michael@0 | 221 | testname + " left position of tooltip"); |
michael@0 | 222 | is(Math.round(rect.top), |
michael@0 | 223 | Math.round(buttonrect.top + parseFloat(popupstyle.marginTop) + 6), |
michael@0 | 224 | testname + " top position of tooltip"); |
michael@0 | 225 | |
michael@0 | 226 | var labelrect = document.getElementById("label").getBoundingClientRect(); |
michael@0 | 227 | ok(labelrect.right < rect.right, testname + " tooltip width"); |
michael@0 | 228 | ok(labelrect.bottom < rect.bottom, testname + " tooltip height"); |
michael@0 | 229 | |
michael@0 | 230 | is(gOriginalWidth, rect.right - rect.left, testname + " tooltip is original width"); |
michael@0 | 231 | is(gOriginalHeight, rect.bottom - rect.top, testname + " tooltip is original height"); |
michael@0 | 232 | } |
michael@0 | 233 | } |
michael@0 | 234 | |
michael@0 | 235 | ]; |
michael@0 | 236 | |
michael@0 | 237 | SimpleTest.waitForFocus(runTest); |
michael@0 | 238 | ]]> |
michael@0 | 239 | </script> |
michael@0 | 240 | |
michael@0 | 241 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 242 | <p id="display"> |
michael@0 | 243 | </p> |
michael@0 | 244 | <div id="content" style="display: none"> |
michael@0 | 245 | </div> |
michael@0 | 246 | <pre id="test"> |
michael@0 | 247 | </pre> |
michael@0 | 248 | </body> |
michael@0 | 249 | |
michael@0 | 250 | </window> |