toolkit/content/tests/browser/browser_autoscroll_disabled.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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 function test()
michael@0 2 {
michael@0 3 const kPrefName_AutoScroll = "general.autoScroll";
michael@0 4 Services.prefs.setBoolPref(kPrefName_AutoScroll, false);
michael@0 5
michael@0 6 gBrowser.selectedTab = gBrowser.addTab();
michael@0 7
michael@0 8 var doc;
michael@0 9
michael@0 10 function startLoad(dataUri) {
michael@0 11 gBrowser.selectedBrowser.addEventListener("pageshow", onLoad, false);
michael@0 12 gBrowser.loadURI(dataUri);
michael@0 13 }
michael@0 14
michael@0 15 function onLoad() {
michael@0 16 gBrowser.selectedBrowser.removeEventListener("pageshow", onLoad, false);
michael@0 17 waitForFocus(onFocus, content);
michael@0 18 }
michael@0 19
michael@0 20 function onFocus() {
michael@0 21 doc = gBrowser.contentDocument;
michael@0 22 runChecks();
michael@0 23 }
michael@0 24
michael@0 25 function endTest() {
michael@0 26 // restore the changed prefs
michael@0 27 if (Services.prefs.prefHasUserValue(kPrefName_AutoScroll))
michael@0 28 Services.prefs.clearUserPref(kPrefName_AutoScroll);
michael@0 29
michael@0 30 // cleaning-up
michael@0 31 gBrowser.removeCurrentTab();
michael@0 32
michael@0 33 // waitForFocus() fixes a failure in the next test if the latter runs too soon.
michael@0 34 waitForFocus(finish);
michael@0 35 }
michael@0 36
michael@0 37 waitForExplicitFinish();
michael@0 38
michael@0 39 let dataUri = 'data:text/html,<html><body id="i" style="overflow-y: scroll"><div style="height: 2000px"></div>\
michael@0 40 <iframe id="iframe" style="display: none;"></iframe>\
michael@0 41 </body></html>';
michael@0 42 startLoad(dataUri);
michael@0 43
michael@0 44 function runChecks() {
michael@0 45 var elem = doc.getElementById('i');
michael@0 46 // Skip the first callback as it's the same callback that the browser
michael@0 47 // uses to kick off the scrolling.
michael@0 48 var skipFrames = 1;
michael@0 49 var checkScroll = function () {
michael@0 50 if (skipFrames--) {
michael@0 51 window.mozRequestAnimationFrame(checkScroll);
michael@0 52 return;
michael@0 53 }
michael@0 54 ok(elem.scrollTop == 0, "element should not have scrolled vertically");
michael@0 55 ok(elem.scrollLeft == 0, "element should not have scrolled horizontally");
michael@0 56
michael@0 57 endTest();
michael@0 58 };
michael@0 59 EventUtils.synthesizeMouse(elem, 50, 50, { button: 1 },
michael@0 60 gBrowser.contentWindow);
michael@0 61
michael@0 62 var iframe = gBrowser.contentDocument.getElementById("iframe");
michael@0 63 var e = iframe.contentDocument.createEvent("pagetransition");
michael@0 64 e.initPageTransitionEvent("pagehide", true, true, false);
michael@0 65 iframe.contentDocument.dispatchEvent(e);
michael@0 66 iframe.contentDocument.documentElement.dispatchEvent(e);
michael@0 67
michael@0 68 EventUtils.synthesizeMouse(elem, 100, 100,
michael@0 69 { type: "mousemove", clickCount: "0" },
michael@0 70 gBrowser.contentWindow);
michael@0 71 /*
michael@0 72 * if scrolling didn’t work, we wouldn’t do any redraws and thus time out.
michael@0 73 * so request and force redraws to get the chance to check for scrolling at
michael@0 74 * all.
michael@0 75 */
michael@0 76 window.mozRequestAnimationFrame(checkScroll);
michael@0 77 }
michael@0 78 }

mercurial