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