2009-08-22 02:12:31 -07:00
|
|
|
|
function test()
|
|
|
|
|
{
|
|
|
|
|
const kPrefName_AutoScroll = "general.autoScroll";
|
2010-03-13 23:02:11 -08:00
|
|
|
|
Services.prefs.setBoolPref(kPrefName_AutoScroll, true);
|
2009-08-22 02:12:31 -07:00
|
|
|
|
|
|
|
|
|
const expectScrollNone = 0;
|
|
|
|
|
const expectScrollVert = 1;
|
|
|
|
|
const expectScrollHori = 2;
|
|
|
|
|
const expectScrollBoth = 3;
|
|
|
|
|
|
|
|
|
|
var allTests = [
|
2013-09-11 03:28:06 -07:00
|
|
|
|
{dataUri: 'data:text/html,<body><style type="text/css">div { display: inline-block; }</style>\
|
|
|
|
|
<div id="a" style="width: 100px; height: 100px; overflow: hidden;"><div style="width: 200px; height: 200px;"></div></div>\
|
|
|
|
|
<div id="b" style="width: 100px; height: 100px; overflow: auto;"><div style="width: 200px; height: 200px;"></div></div>\
|
|
|
|
|
<div id="c" style="width: 100px; height: 100px; overflow-x: auto; overflow-y: hidden;"><div style="width: 200px; height: 200px;"></div></div>\
|
|
|
|
|
<div id="d" style="width: 100px; height: 100px; overflow-y: auto; overflow-x: hidden;"><div style="width: 200px; height: 200px;"></div></div>\
|
|
|
|
|
<select id="e" style="width: 100px; height: 100px;" multiple="multiple"><option>aaaaaaaaaaaaaaaaaaaaaaaa</option><option>a</option><option>a</option>\
|
|
|
|
|
<option>a</option><option>a</option><option>a</option><option>a</option><option>a</option><option>a</option><option>a</option>\
|
|
|
|
|
<option>a</option><option>a</option><option>a</option><option>a</option><option>a</option><option>a</option><option>a</option></select>\
|
|
|
|
|
<select id="f" style="width: 100px; height: 100px;"><option>a</option><option>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</option><option>a</option>\
|
|
|
|
|
<option>a</option><option>a</option><option>a</option><option>a</option><option>a</option><option>a</option><option>a</option>\
|
|
|
|
|
<option>a</option><option>a</option><option>a</option><option>a</option><option>a</option><option>a</option><option>a</option></select>\
|
|
|
|
|
<div id="g" style="width: 99px; height: 99px; border: 10px solid black; margin: 10px; overflow: auto;"><div style="width: 100px; height: 100px;"></div></div>\
|
|
|
|
|
<div id="h" style="width: 100px; height: 100px; overflow: -moz-hidden-unscrollable;"><div style="width: 200px; height: 200px;"></div></div>\
|
|
|
|
|
<iframe id="iframe" style="display: none;"></iframe>\
|
|
|
|
|
</body>'},
|
2009-08-22 02:12:31 -07:00
|
|
|
|
{elem: 'a', expected: expectScrollNone},
|
|
|
|
|
{elem: 'b', expected: expectScrollBoth},
|
|
|
|
|
{elem: 'c', expected: expectScrollHori},
|
|
|
|
|
{elem: 'd', expected: expectScrollVert},
|
|
|
|
|
{elem: 'e', expected: expectScrollVert},
|
2010-02-13 03:31:10 -08:00
|
|
|
|
{elem: 'f', expected: expectScrollNone},
|
2010-04-13 01:50:17 -07:00
|
|
|
|
{elem: 'g', expected: expectScrollBoth},
|
2013-09-11 03:28:06 -07:00
|
|
|
|
{elem: 'h', expected: expectScrollNone},
|
|
|
|
|
{dataUri: 'data:text/html,<html><body id="i" style="overflow-y: scroll"><div style="height: 2000px"></div>\
|
|
|
|
|
<iframe id="iframe" style="display: none;"></iframe>\
|
|
|
|
|
</body></html>'},
|
|
|
|
|
{elem: 'i', expected: expectScrollVert}, // bug 695121
|
|
|
|
|
{dataUri: 'data:text/html,<html><style>html, body { width: 100%; height: 100%; overflow-x: hidden; overflow-y: scroll; }</style>\
|
|
|
|
|
<body id="j"><div style="height: 2000px"></div>\
|
|
|
|
|
<iframe id="iframe" style="display: none;"></iframe>\
|
|
|
|
|
</body></html>'},
|
|
|
|
|
{elem: 'j', expected: expectScrollVert} // bug 914251
|
2009-08-22 02:12:31 -07:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
var doc;
|
|
|
|
|
|
|
|
|
|
function nextTest() {
|
|
|
|
|
var test = allTests.shift();
|
2009-12-28 01:47:47 -08:00
|
|
|
|
if (!test) {
|
2009-08-22 02:12:31 -07:00
|
|
|
|
endTest();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2009-12-28 01:47:47 -08:00
|
|
|
|
|
2013-09-11 03:28:06 -07:00
|
|
|
|
if (test.dataUri) {
|
|
|
|
|
startLoad(test.dataUri);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-22 02:12:31 -07:00
|
|
|
|
var elem = doc.getElementById(test.elem);
|
2011-11-30 16:45:32 -08:00
|
|
|
|
// Skip the first callback as it's the same callback that the browser
|
2011-03-22 11:45:13 -07:00
|
|
|
|
// uses to kick off the scrolling.
|
|
|
|
|
var skipFrames = 1;
|
2010-08-18 10:57:31 -07:00
|
|
|
|
var checkScroll = function () {
|
|
|
|
|
if (skipFrames--) {
|
2011-11-28 04:49:44 -08:00
|
|
|
|
window.mozRequestAnimationFrame(checkScroll);
|
2010-08-18 10:57:31 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
2009-08-22 02:12:31 -07:00
|
|
|
|
EventUtils.synthesizeKey("VK_ESCAPE", {}, gBrowser.contentWindow);
|
|
|
|
|
var scrollVert = test.expected & expectScrollVert;
|
|
|
|
|
ok((scrollVert && elem.scrollTop > 0) ||
|
|
|
|
|
(!scrollVert && elem.scrollTop == 0),
|
|
|
|
|
test.elem+' should'+(scrollVert ? '' : ' not')+' have scrolled vertically');
|
|
|
|
|
var scrollHori = test.expected & expectScrollHori;
|
|
|
|
|
ok((scrollHori && elem.scrollLeft > 0) ||
|
|
|
|
|
(!scrollHori && elem.scrollLeft == 0),
|
|
|
|
|
test.elem+' should'+(scrollHori ? '' : ' not')+' have scrolled horizontally');
|
|
|
|
|
nextTest();
|
2010-08-18 10:57:31 -07:00
|
|
|
|
};
|
|
|
|
|
EventUtils.synthesizeMouse(elem, 50, 50, { button: 1 },
|
|
|
|
|
gBrowser.contentWindow);
|
2010-12-29 00:14:12 -08:00
|
|
|
|
|
|
|
|
|
var iframe = gBrowser.contentDocument.getElementById("iframe");
|
|
|
|
|
var e = iframe.contentDocument.createEvent("pagetransition");
|
|
|
|
|
e.initPageTransitionEvent("pagehide", true, true, false);
|
|
|
|
|
iframe.contentDocument.dispatchEvent(e);
|
|
|
|
|
iframe.contentDocument.documentElement.dispatchEvent(e);
|
|
|
|
|
|
2010-08-18 10:57:31 -07:00
|
|
|
|
EventUtils.synthesizeMouse(elem, 100, 100,
|
|
|
|
|
{ type: "mousemove", clickCount: "0" },
|
|
|
|
|
gBrowser.contentWindow);
|
|
|
|
|
/*
|
|
|
|
|
* if scrolling didn’t work, we wouldn’t do any redraws and thus time out.
|
|
|
|
|
* so request and force redraws to get the chance to check for scrolling at
|
|
|
|
|
* all.
|
|
|
|
|
*/
|
2011-11-28 04:49:44 -08:00
|
|
|
|
window.mozRequestAnimationFrame(checkScroll);
|
2009-08-22 02:12:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
waitForExplicitFinish();
|
2013-09-11 03:28:06 -07:00
|
|
|
|
|
|
|
|
|
nextTest();
|
|
|
|
|
|
|
|
|
|
function startLoad(dataUri) {
|
|
|
|
|
gBrowser.selectedBrowser.addEventListener("pageshow", onLoad, false);
|
|
|
|
|
gBrowser.loadURI(dataUri);
|
|
|
|
|
}
|
2010-03-14 00:08:14 -08:00
|
|
|
|
|
|
|
|
|
function onLoad() {
|
|
|
|
|
gBrowser.selectedBrowser.removeEventListener("pageshow", onLoad, false);
|
|
|
|
|
waitForFocus(onFocus, content);
|
|
|
|
|
}
|
2009-08-22 02:12:31 -07:00
|
|
|
|
|
|
|
|
|
function onFocus() {
|
|
|
|
|
doc = gBrowser.contentDocument;
|
|
|
|
|
nextTest();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function endTest() {
|
|
|
|
|
// restore the changed prefs
|
2010-03-13 23:02:11 -08:00
|
|
|
|
if (Services.prefs.prefHasUserValue(kPrefName_AutoScroll))
|
|
|
|
|
Services.prefs.clearUserPref(kPrefName_AutoScroll);
|
2009-08-22 02:12:31 -07:00
|
|
|
|
|
|
|
|
|
// cleaning-up
|
2009-12-28 01:47:47 -08:00
|
|
|
|
gBrowser.addTab("about:blank");
|
2009-08-22 02:12:31 -07:00
|
|
|
|
gBrowser.removeCurrentTab();
|
|
|
|
|
|
2009-12-28 01:47:47 -08:00
|
|
|
|
// waitForFocus() fixes a failure in the next test if the latter runs too soon.
|
|
|
|
|
waitForFocus(finish);
|
2009-08-22 02:12:31 -07:00
|
|
|
|
}
|
|
|
|
|
}
|