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="Popups in Scaled Content" |
michael@0 | 6 | onload="setTimeout(runTests, 0);" |
michael@0 | 7 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 8 | |
michael@0 | 9 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 11 | |
michael@0 | 12 | <!-- This test checks that the position is correct in two cases: |
michael@0 | 13 | - a popup anchored at an element in a scaled document |
michael@0 | 14 | - a popup opened at a screen coordinate in a scaled window |
michael@0 | 15 | --> |
michael@0 | 16 | |
michael@0 | 17 | <iframe id="frame" width="60" height="140" |
michael@0 | 18 | src="data:text/html,<html><body><input size='4' id='one'><input size='4' id='two'></body></html>"/> |
michael@0 | 19 | |
michael@0 | 20 | <menupopup id="popup" onpopupshown="shown()" onpopuphidden="nextTest()"> |
michael@0 | 21 | <menuitem label="One"/> |
michael@0 | 22 | </menupopup> |
michael@0 | 23 | |
michael@0 | 24 | <script class="testbody" type="application/javascript"> |
michael@0 | 25 | <![CDATA[ |
michael@0 | 26 | |
michael@0 | 27 | var screenTest = false; |
michael@0 | 28 | var screenx = -1, screeny = -1; |
michael@0 | 29 | |
michael@0 | 30 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 31 | |
michael@0 | 32 | function runTests() |
michael@0 | 33 | { |
michael@0 | 34 | setScale($("frame").contentWindow, 2); |
michael@0 | 35 | |
michael@0 | 36 | var anchor = $("frame").contentDocument.getElementById("two"); |
michael@0 | 37 | anchor.getBoundingClientRect(); // flush to update display after scale change |
michael@0 | 38 | $("popup").openPopup(anchor, "after_start"); |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | function setScale(win, scale) |
michael@0 | 42 | { |
michael@0 | 43 | var wn = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor) |
michael@0 | 44 | .getInterface(Components.interfaces.nsIWebNavigation); |
michael@0 | 45 | var shell = wn.QueryInterface(Components.interfaces.nsIDocShell); |
michael@0 | 46 | var docViewer = shell.contentViewer.QueryInterface(Components.interfaces.nsIMarkupDocumentViewer); |
michael@0 | 47 | docViewer.fullZoom = scale; |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | function shown() |
michael@0 | 51 | { |
michael@0 | 52 | if (screenTest) { |
michael@0 | 53 | var box = $("popup").boxObject; |
michael@0 | 54 | is(box.screenX, screenx, "screen left position"); |
michael@0 | 55 | is(box.screenY, screeny, "screen top position"); |
michael@0 | 56 | } |
michael@0 | 57 | else { |
michael@0 | 58 | var anchor = $("frame").contentDocument.getElementById("two"); |
michael@0 | 59 | |
michael@0 | 60 | is(Math.round(anchor.getBoundingClientRect().left * 2), |
michael@0 | 61 | Math.round($("popup").getBoundingClientRect().left), "anchored left position"); |
michael@0 | 62 | is(Math.round(anchor.getBoundingClientRect().bottom * 2), |
michael@0 | 63 | Math.round($("popup").getBoundingClientRect().top), "anchored top position"); |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | $("popup").hidePopup(); |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | function nextTest() |
michael@0 | 70 | { |
michael@0 | 71 | if (screenTest) { |
michael@0 | 72 | setScale(window, 1); |
michael@0 | 73 | SimpleTest.finish(); |
michael@0 | 74 | } |
michael@0 | 75 | else { |
michael@0 | 76 | screenTest = true; |
michael@0 | 77 | var box = document.documentElement.boxObject; |
michael@0 | 78 | |
michael@0 | 79 | // - the iframe is at 4×, but out here css pixels are only 2× device pixels |
michael@0 | 80 | // - the popup manager rounds off (or truncates) the coordinates to |
michael@0 | 81 | // integers, so ensure we pass in even numbers to openPopupAtScreen |
michael@0 | 82 | screenx = (x = even(box.screenX + 120))/2; |
michael@0 | 83 | screeny = (y = even(box.screenY + 120))/2; |
michael@0 | 84 | setScale(window, 2); |
michael@0 | 85 | $("popup").openPopupAtScreen(x, y); |
michael@0 | 86 | } |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | function even(n) |
michael@0 | 90 | { |
michael@0 | 91 | return (n % 2) ? n+1 : n; |
michael@0 | 92 | } |
michael@0 | 93 | ]]> |
michael@0 | 94 | </script> |
michael@0 | 95 | |
michael@0 | 96 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 97 | <p id="display"> |
michael@0 | 98 | </p> |
michael@0 | 99 | <div id="content" style="display: none"> |
michael@0 | 100 | </div> |
michael@0 | 101 | <pre id="test"> |
michael@0 | 102 | </pre> |
michael@0 | 103 | </body> |
michael@0 | 104 | |
michael@0 | 105 | </window> |