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"?>
4 <!--
5 XUL Widget Test for scrollbars
6 -->
7 <window title="Scrollbar"
8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
9 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
12 <!-- test results are displayed in the html:body -->
13 <body xmlns="http://www.w3.org/1999/xhtml"/>
15 <hbox>
16 <scrollbar orient="horizontal"
17 id="scroller"
18 curpos="0"
19 maxpos="600"
20 pageincrement="400"
21 width="500"
22 style="margin:0"/>
23 </hbox>
25 <!-- test code goes here -->
26 <script type="application/javascript"><![CDATA[
28 /** Test for Scrollbar **/
29 var scrollbarTester = {
30 scrollbar: null,
31 middlePref: false,
32 startTest: function() {
33 this.scrollbar = $("scroller");
34 this.middlePref = this.getMiddlePref();
35 var self = this;
36 [0, 1, 2].map(function(button) {
37 [false, true].map(function(alt) {
38 [false, true].map(function(shift) {
39 self.testThumbDragging(button, alt, shift);
40 })
41 })
42 });
43 SimpleTest.finish();
44 },
45 testThumbDragging: function(button, withAlt, withShift) {
46 this.reset();
47 var x = 160; // on the right half of the thumb
48 var y = 5;
50 // Start the drag.
51 this.mousedown(x, y, button, withAlt, withShift);
52 var newPos = this.getPos();
53 var scrollToClick = (newPos != 0);
54 if (navigator.platform.indexOf("Mac") != -1) {
55 ok(!scrollToClick,
56 "On Mac OS X, clicking the scrollbar thumb should never move it.");
57 } else if (button == 0 && withShift) {
58 ok(scrollToClick, "On platforms other than Mac OS X, holding shift should "+
59 "enable scroll-to-click on the scrollbar thumb.");
60 } else if (button == 1 && this.middlePref) {
61 ok(scrollToClick, "When middlemouse.scrollbarPosition is on, clicking the "+
62 "thumb with the middle mouse button should center it "+
63 "around the cursor.")
64 }
66 // Move one pixel to the right.
67 this.mousemove(x+1, y, button, withAlt, withShift);
68 var newPos2 = this.getPos();
69 if (newPos2 != newPos) {
70 ok(newPos2 > newPos, "Scrollbar thumb should follow the mouse when dragged.");
71 ok(newPos2 - newPos < 3, "Scrollbar shouldn't move further than the mouse when dragged.");
72 ok(button == 0 || (button == 1 && this.middlePref),
73 "Dragging the scrollbar should only be possible with the left mouse button.");
74 } else {
75 // Dragging had no effect.
76 if (button == 0) {
77 ok(false, "Dragging the scrollbar thumb should work.");
78 } else if (button == 1 && this.middlePref && navigator.platform.indexOf("Mac") == -1) {
79 ok(false, "When middlemouse.scrollbarPosition is on, dragging the "+
80 "scrollbar thumb should be possible using the middle mouse button.");
81 } else {
82 ok(true, "Dragging works correctly.");
83 }
84 }
86 // Release the mouse button.
87 this.mouseup(x+1, y, button, withAlt, withShift);
88 var newPos3 = this.getPos();
89 ok(newPos3 == newPos2,
90 "Releasing the mouse button after dragging the thumb shouldn't move it.");
91 },
92 getMiddlePref: function() {
93 // It would be better to test with different middlePref settings,
94 // but the setting is only queried once, at browser startup, so
95 // changing it here wouldn't have any effect
96 var prefService = Components.classes["@mozilla.org/preferences-service;1"]
97 .getService(Components.interfaces.nsIPrefService);
98 var mouseBranch = prefService.getBranch("middlemouse.");
99 return mouseBranch.getBoolPref("scrollbarPosition");
100 },
101 setPos: function(pos) {
102 this.scrollbar.setAttribute("curpos", pos);
103 },
104 getPos: function() {
105 return this.scrollbar.getAttribute("curpos");
106 },
107 reset: function() {
108 this.setPos(0);
109 },
110 mousedown: function(x, y, button, alt, shift) {
111 synthesizeMouse(this.scrollbar, x, y, { type: "mousedown", 'button': button,
112 altKey: alt, shiftKey: shift });
113 },
114 mousemove: function(x, y, button, alt, shift) {
115 synthesizeMouse(this.scrollbar, x, y, { type: "mousemove", 'button': button,
116 altKey: alt, shiftKey: shift });
117 },
118 mouseup: function(x, y, button, alt, shift) {
119 synthesizeMouse(this.scrollbar, x, y, { type: "mouseup", 'button': button,
120 altKey: alt, shiftKey: shift });
121 }
122 }
124 function doTest() {
125 setTimeout(function() { scrollbarTester.startTest(); }, 0);
126 }
128 SimpleTest.waitForExplicitFinish();
129 addLoadEvent(doTest);
131 ]]></script>
132 </window>