mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 251903 - Autoscroll does not function as expected when in an iframe. r=Neil
This commit is contained in:
parent
1e9a78865d
commit
20f33b9309
@ -105,7 +105,9 @@ function pastedGlobal(event)
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SimpleTest.waitForFocus(selectArea);
|
||||
SimpleTest.waitForFocus(function() {
|
||||
SpecialPowers.pushPrefEnv({"set": [["general.autoScroll", false]]}, selectArea);
|
||||
});
|
||||
</script>
|
||||
|
||||
</pre>
|
||||
|
@ -53,13 +53,13 @@ let ClickEventHandler = {
|
||||
return false;
|
||||
},
|
||||
|
||||
startScroll: function(event) {
|
||||
findNearestScrollableElement: function(aNode) {
|
||||
// this is a list of overflow property values that allow scrolling
|
||||
const scrollingAllowed = ['scroll', 'auto'];
|
||||
|
||||
// go upward in the DOM and find any parent element that has a overflow
|
||||
// area and can therefore be scrolled
|
||||
for (this._scrollable = event.originalTarget; this._scrollable;
|
||||
for (this._scrollable = aNode; this._scrollable;
|
||||
this._scrollable = this._scrollable.parentNode) {
|
||||
// do not use overflow based autoscroll for <html> and <body>
|
||||
// Elements or non-html elements such as svg or Document nodes
|
||||
@ -96,16 +96,25 @@ let ClickEventHandler = {
|
||||
}
|
||||
|
||||
if (!this._scrollable) {
|
||||
this._scrollable = event.originalTarget.ownerDocument.defaultView;
|
||||
this._scrollable = aNode.ownerDocument.defaultView;
|
||||
if (this._scrollable.scrollMaxX > 0) {
|
||||
this._scrolldir = this._scrollable.scrollMaxY > 0 ? "NSEW" : "EW";
|
||||
} else if (this._scrollable.scrollMaxY > 0) {
|
||||
this._scrolldir = "NS";
|
||||
} else if (this._scrollable.frameElement) {
|
||||
this.findNearestScrollableElement(this._scrollable.frameElement);
|
||||
} else {
|
||||
this._scrollable = null; // abort scrolling
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
startScroll: function(event) {
|
||||
|
||||
this.findNearestScrollableElement(event.originalTarget);
|
||||
|
||||
if (!this._scrollable)
|
||||
return;
|
||||
|
||||
let [enabled] = sendSyncMessage("Autoscroll:Start",
|
||||
{scrolldir: this._scrolldir,
|
||||
|
@ -40,7 +40,42 @@ function test()
|
||||
<body id="j"><div style="height: 2000px"></div>\
|
||||
<iframe id="iframe" style="display: none;"></iframe>\
|
||||
</body></html>'},
|
||||
{elem: 'j', expected: expectScrollVert} // bug 914251
|
||||
{elem: 'j', expected: expectScrollVert}, // bug 914251
|
||||
{dataUri: 'data:text/html,<html><head><meta charset="utf-8"></head><body>\
|
||||
<div id="k" style="height: 150px; width: 200px; overflow: scroll; border: 1px solid black;">\
|
||||
<iframe style="height: 200px; width: 300px;"></iframe>\
|
||||
</div>\
|
||||
<div id="l" style="height: 150px; width: 300px; overflow: scroll; border: 1px dashed black;">\
|
||||
<iframe style="height: 200px; width: 200px;" src="data:text/html,<div style=\'border: 5px solid blue; height: 200%; width: 200%;\'></div>"></iframe>\
|
||||
</div>\
|
||||
<iframe id="m"></iframe>\
|
||||
<div style="height: 200%; border: 5px dashed black;">filler to make document overflow: scroll;</div>\
|
||||
</body></html>'},
|
||||
{elem: 'k', expected: expectScrollBoth},
|
||||
{elem: 'k', expected: expectScrollNone, testwindow: true},
|
||||
{elem: 'l', expected: expectScrollNone},
|
||||
{elem: 'm', expected: expectScrollVert, testwindow: true},
|
||||
{dataUri: 'data:text/html,<html><head><meta charset="utf-8"></head><body>\
|
||||
<img width="100" height="100" alt="image map" usemap="%23planetmap">\
|
||||
<map name="planetmap">\
|
||||
<area id="n" shape="rect" coords="0,0,100,100" href="javascript:void(null)">\
|
||||
</map>\
|
||||
<a href="javascript:void(null)" id="o" style="width: 100px; height: 100px; border: 1px solid black; display: inline-block; vertical-align: top;">link</a>\
|
||||
<input id="p" style="width: 100px; height: 100px; vertical-align: top;">\
|
||||
<textarea id="q" style="width: 100px; height: 100px; vertical-align: top;"></textarea>\
|
||||
<div style="height: 200%; border: 1px solid black;"></div>\
|
||||
</body></html>'},
|
||||
{elem: 'n', expected: expectScrollNone, testwindow: true},
|
||||
{elem: 'o', expected: expectScrollNone, testwindow: true},
|
||||
{elem: 'p', expected: expectScrollVert, testwindow: true, middlemousepastepref: false},
|
||||
{elem: 'q', expected: expectScrollVert, testwindow: true, middlemousepastepref: false},
|
||||
{dataUri: 'data:text/html,<html><head><meta charset="utf-8"></head><body>\
|
||||
<input id="r" style="width: 100px; height: 100px; vertical-align: top;">\
|
||||
<textarea id="s" style="width: 100px; height: 100px; vertical-align: top;"></textarea>\
|
||||
<div style="height: 200%; border: 1px solid black;"></div>\
|
||||
</body></html>'},
|
||||
{elem: 'r', expected: expectScrollNone, testwindow: true, middlemousepastepref: true},
|
||||
{elem: 's', expected: expectScrollNone, testwindow: true, middlemousepastepref: true}
|
||||
];
|
||||
|
||||
var doc;
|
||||
@ -89,35 +124,55 @@ function test()
|
||||
// Close the autoscroll popup by synthesizing Esc.
|
||||
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');
|
||||
|
||||
if (test.testwindow) {
|
||||
ok((scrollVert && gBrowser.contentWindow.scrollY > 0) ||
|
||||
(!scrollVert && gBrowser.contentWindow.scrollY == 0),
|
||||
'Window for '+test.elem+' should'+(scrollVert ? '' : ' not')+' have scrolled vertically');
|
||||
ok((scrollHori && gBrowser.contentWindow.scrollX > 0) ||
|
||||
(!scrollHori && gBrowser.contentWindow.scrollX == 0),
|
||||
'Window for '+test.elem+' should'+(scrollHori ? '' : ' not')+' have scrolled horizontally');
|
||||
} else {
|
||||
ok((scrollVert && elem.scrollTop > 0) ||
|
||||
(!scrollVert && elem.scrollTop == 0),
|
||||
test.elem+' should'+(scrollVert ? '' : ' not')+' have scrolled vertically');
|
||||
ok((scrollHori && elem.scrollLeft > 0) ||
|
||||
(!scrollHori && elem.scrollLeft == 0),
|
||||
test.elem+' should'+(scrollHori ? '' : ' not')+' have scrolled horizontally');
|
||||
}
|
||||
|
||||
// Before continuing the test, we need to ensure that the IPC
|
||||
// message that stops autoscrolling has had time to arrive.
|
||||
executeSoon(nextTest);
|
||||
};
|
||||
|
||||
if (test.middlemousepastepref == false || test.middlemousepastepref == true)
|
||||
Services.prefs.setBoolPref("middlemouse.paste", test.middlemousepastepref);
|
||||
|
||||
EventUtils.synthesizeMouse(elem, 50, 50, { button: 1 },
|
||||
gBrowser.contentWindow);
|
||||
|
||||
// This ensures bug 605127 is fixed: pagehide in an unrelated document
|
||||
// should not cancel the autoscroll.
|
||||
var iframe = gBrowser.contentDocument.getElementById("iframe");
|
||||
var e = new iframe.contentWindow.PageTransitionEvent("pagehide",
|
||||
{ bubbles: true,
|
||||
cancelable: true,
|
||||
persisted: false });
|
||||
iframe.contentDocument.dispatchEvent(e);
|
||||
iframe.contentDocument.documentElement.dispatchEvent(e);
|
||||
|
||||
if (iframe) {
|
||||
var e = new iframe.contentWindow.PageTransitionEvent("pagehide",
|
||||
{ bubbles: true,
|
||||
cancelable: true,
|
||||
persisted: false });
|
||||
iframe.contentDocument.dispatchEvent(e);
|
||||
iframe.contentDocument.documentElement.dispatchEvent(e);
|
||||
}
|
||||
|
||||
EventUtils.synthesizeMouse(elem, 100, 100,
|
||||
{ type: "mousemove", clickCount: "0" },
|
||||
gBrowser.contentWindow);
|
||||
|
||||
if (Services.prefs.prefHasUserValue("middlemouse.paste"))
|
||||
Services.prefs.clearUserPref("middlemouse.paste");
|
||||
|
||||
// Start checking for the scroll.
|
||||
window.mozRequestAnimationFrame(checkScroll);
|
||||
}
|
||||
@ -142,6 +197,10 @@ function test()
|
||||
}
|
||||
|
||||
function endTest() {
|
||||
// remove 2 tabs that were opened by middle-click on links
|
||||
gBrowser.removeTab(gBrowser.tabs[gBrowser.visibleTabs.length - 1]);
|
||||
gBrowser.removeTab(gBrowser.tabs[gBrowser.visibleTabs.length - 1]);
|
||||
|
||||
// restore the changed prefs
|
||||
if (Services.prefs.prefHasUserValue(kPrefName_AutoScroll))
|
||||
Services.prefs.clearUserPref(kPrefName_AutoScroll);
|
||||
|
Loading…
Reference in New Issue
Block a user