Bug 1317386 - Scroll element into view at the bottom; r=automatedtester

When scrolling an element into view using `Element.scrollIntoView`,
use the `{block: "end", inline: "nearest"}` scroll position arguments,
which are equivalent to `Element.scrollIntoView(false)`.  This is what
other WebDriver implementations have used for a while, and we meant to
change to this sooner.

This ensures that the element appears at the bottom of the viewport
rather than the top, where overlaying menus with fixed style position
may more frequently appear.

In the future we might consider replacing this with `{block: "center"}`
which is specified in the CSSOM specification, but not yet implemented
in any browsers.

This implements https://github.com/w3c/webdriver/pull/440, which should
fix https://github.com/mozilla/geckodriver/issues/327.

MozReview-Commit-ID: BRMupP4fM89

--HG--
extra : rebase_source : 952edd6932b0f7e8b7d2694d428435508a4ffc8c
This commit is contained in:
Andreas Tolfsen 2016-11-14 21:06:50 +00:00
Родитель a75ebc8c52
Коммит cbe8e9b6dc
1 изменённых файлов: 15 добавлений и 7 удалений

Просмотреть файл

@ -774,7 +774,7 @@ element.toJson = function(obj, seenEls) {
*
* @param {nsIDOMElement} el
* Element to be checked.
* @param nsIDOMWindow frame
* @param {nsIDOMWindow} frame
* Window object that contains the element or the current host
* of the shadow root.
* @param {ShadowRoot=} shadowRoot
@ -910,12 +910,8 @@ element.isVisible = function(el, x = undefined, y = undefined) {
}
if (!element.inViewport(el, x, y)) {
if (el.scrollIntoView) {
el.scrollIntoView({block: "start", inline: "nearest"});
if (!element.inViewport(el)) {
return false;
}
} else {
element.scrollIntoView(el);
if (!element.inViewport(el)) {
return false;
}
}
@ -1003,6 +999,18 @@ element.isKeyboardInteractable = function(el) {
return true;
};
/**
* Attempts to scroll into view |el|.
*
* @param {DOMElement} el
* Element to scroll into view.
*/
element.scrollIntoView = function(el) {
if (el.scrollIntoView) {
el.scrollIntoView({block: "end", inline: "nearest", behavior: "instant"});
}
};
element.isXULElement = function(el) {
let ns = atom.getElementAttribute(el, "namespaceURI");
return ns.indexOf("there.is.only.xul") >= 0;