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