michael@0: function test() michael@0: { michael@0: const kPrefName_AutoScroll = "general.autoScroll"; michael@0: Services.prefs.setBoolPref(kPrefName_AutoScroll, false); michael@0: michael@0: gBrowser.selectedTab = gBrowser.addTab(); michael@0: michael@0: var doc; michael@0: michael@0: function startLoad(dataUri) { michael@0: gBrowser.selectedBrowser.addEventListener("pageshow", onLoad, false); michael@0: gBrowser.loadURI(dataUri); michael@0: } michael@0: michael@0: function onLoad() { michael@0: gBrowser.selectedBrowser.removeEventListener("pageshow", onLoad, false); michael@0: waitForFocus(onFocus, content); michael@0: } michael@0: michael@0: function onFocus() { michael@0: doc = gBrowser.contentDocument; michael@0: runChecks(); michael@0: } michael@0: michael@0: function endTest() { michael@0: // restore the changed prefs michael@0: if (Services.prefs.prefHasUserValue(kPrefName_AutoScroll)) michael@0: Services.prefs.clearUserPref(kPrefName_AutoScroll); michael@0: michael@0: // cleaning-up michael@0: gBrowser.removeCurrentTab(); michael@0: michael@0: // waitForFocus() fixes a failure in the next test if the latter runs too soon. michael@0: waitForFocus(finish); michael@0: } michael@0: michael@0: waitForExplicitFinish(); michael@0: michael@0: let dataUri = 'data:text/html,
\ michael@0: \ michael@0: '; michael@0: startLoad(dataUri); michael@0: michael@0: function runChecks() { michael@0: var elem = doc.getElementById('i'); michael@0: // Skip the first callback as it's the same callback that the browser michael@0: // uses to kick off the scrolling. michael@0: var skipFrames = 1; michael@0: var checkScroll = function () { michael@0: if (skipFrames--) { michael@0: window.mozRequestAnimationFrame(checkScroll); michael@0: return; michael@0: } michael@0: ok(elem.scrollTop == 0, "element should not have scrolled vertically"); michael@0: ok(elem.scrollLeft == 0, "element should not have scrolled horizontally"); michael@0: michael@0: endTest(); michael@0: }; michael@0: EventUtils.synthesizeMouse(elem, 50, 50, { button: 1 }, michael@0: gBrowser.contentWindow); michael@0: michael@0: var iframe = gBrowser.contentDocument.getElementById("iframe"); michael@0: var e = iframe.contentDocument.createEvent("pagetransition"); michael@0: e.initPageTransitionEvent("pagehide", true, true, false); michael@0: iframe.contentDocument.dispatchEvent(e); michael@0: iframe.contentDocument.documentElement.dispatchEvent(e); michael@0: michael@0: EventUtils.synthesizeMouse(elem, 100, 100, michael@0: { type: "mousemove", clickCount: "0" }, michael@0: gBrowser.contentWindow); michael@0: /* michael@0: * if scrolling didn’t work, we wouldn’t do any redraws and thus time out. michael@0: * so request and force redraws to get the chance to check for scrolling at michael@0: * all. michael@0: */ michael@0: window.mozRequestAnimationFrame(checkScroll); michael@0: } michael@0: }