mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 04:15:43 +00:00
Backed out changeset 9e996cc695eb (bug 937053) for breaking marionette
This commit is contained in:
parent
10cfe98f1e
commit
80bfa23035
@ -77,31 +77,6 @@ class TestClickScrolling(MarionetteTestCase):
|
|||||||
# If we dont throw we are good
|
# If we dont throw we are good
|
||||||
self.marionette.find_element(By.ID, "radio").click()
|
self.marionette.find_element(By.ID, "radio").click()
|
||||||
|
|
||||||
def test_should_scroll_elements_if_click_point_is_out_of_view_but_element_is_in_view(self):
|
|
||||||
test_html = self.marionette.absolute_url("element_outside_viewport.html")
|
|
||||||
|
|
||||||
for s in ["top", "bottom"]:
|
|
||||||
self.marionette.navigate(test_html)
|
|
||||||
scroll_y = self.marionette.execute_script("return window.scrollY;")
|
|
||||||
self.marionette.find_element(By.ID, "%s-70" % s).click()
|
|
||||||
self.assertNotEqual(scroll_y, self.marionette.execute_script("return window.scrollY;"))
|
|
||||||
|
|
||||||
for s in ["left", "right"]:
|
|
||||||
self.marionette.navigate(test_html)
|
|
||||||
scroll_x = self.marionette.execute_script("return window.scrollX;")
|
|
||||||
self.marionette.find_element(By.ID, "%s-70" % s).click()
|
|
||||||
self.assertNotEqual(scroll_x, self.marionette.execute_script("return window.scrollX;"))
|
|
||||||
|
|
||||||
def test_should_not_scroll_elements_if_click_point_is_in_view(self):
|
|
||||||
test_html = self.marionette.absolute_url("element_outside_viewport.html")
|
|
||||||
|
|
||||||
for s in ["top", "right", "bottom", "left"]:
|
|
||||||
for p in ["50", "30"]:
|
|
||||||
self.marionette.navigate(test_html)
|
|
||||||
scroll = self.marionette.execute_script("return [window.scrollX, window.scrollY];")
|
|
||||||
self.marionette.find_element(By.ID, "%s-%s" % (s, p)).click()
|
|
||||||
self.assertEqual(scroll, self.marionette.execute_script("return [window.scrollX, window.scrollY];"))
|
|
||||||
|
|
||||||
@skip("Bug 1003687")
|
@skip("Bug 1003687")
|
||||||
def test_should_scroll_overflow_elements_if_click_point_is_out_of_view_but_element_is_in_view(self):
|
def test_should_scroll_overflow_elements_if_click_point_is_out_of_view_but_element_is_in_view(self):
|
||||||
test_html = self.marionette.absolute_url("scroll5.html")
|
test_html = self.marionette.absolute_url("scroll5.html")
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<style>
|
|
||||||
div {
|
|
||||||
position: absolute;
|
|
||||||
width: 100px;
|
|
||||||
height: 100px;
|
|
||||||
}
|
|
||||||
.top { background-color: red; }
|
|
||||||
#top-70 { left: 80px; top: 0; }
|
|
||||||
#top-50 { left: 190px; top: 20px; }
|
|
||||||
#top-30 { left: 300px; top: 40px; }
|
|
||||||
|
|
||||||
.right { background-color: black; }
|
|
||||||
#right-70 { top: 80px; right: -140px;}
|
|
||||||
#right-50 { top: 190px; right: -120px;}
|
|
||||||
#right-30 { top: 300px; right: -100px;}
|
|
||||||
|
|
||||||
.bottom { background-color: blue; }
|
|
||||||
#bottom-70 { right: -50px; bottom: -140px; }
|
|
||||||
#bottom-50 { right: 60px; bottom: -120px; }
|
|
||||||
#bottom-30 { right: 170px; bottom: -100px; }
|
|
||||||
|
|
||||||
.left { background-color: green; }
|
|
||||||
#left-70 { bottom: -50px; left: 0; }
|
|
||||||
#left-50 { bottom: 60px; left: 20px; }
|
|
||||||
#left-30 { bottom: 170px; left: 40px; }
|
|
||||||
</style>
|
|
||||||
<body onload="window.scrollTo(70, 70);">
|
|
||||||
<div id="top-70" class="top"></div>
|
|
||||||
<div id="top-50" class="top"></div>
|
|
||||||
<div id="top-30" class="top"></div>
|
|
||||||
<div id="right-70" class="right"></div>
|
|
||||||
<div id="right-50" class="right"></div>
|
|
||||||
<div id="right-30" class="right"></div>
|
|
||||||
<div id="bottom-70" class="bottom"></div>
|
|
||||||
<div id="bottom-50" class="bottom"></div>
|
|
||||||
<div id="bottom-30" class="bottom"></div>
|
|
||||||
<div id="left-70" class="left"></div>
|
|
||||||
<div id="left-50" class="left"></div>
|
|
||||||
<div id="left-30" class="left"></div>
|
|
||||||
</body>
|
|
@ -779,29 +779,24 @@ function coordinates(target, x, y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function returns true if the given coordinates are in the viewport.
|
* This function returns if the element is in viewport
|
||||||
* @param 'x', and 'y' are the coordinates relative to the target.
|
|
||||||
* If they are not specified, then the center of the target is used.
|
|
||||||
*/
|
*/
|
||||||
function elementInViewport(el, x, y) {
|
function elementInViewport(el) {
|
||||||
let c = coordinates(el, x, y);
|
let rect = el.getBoundingClientRect();
|
||||||
let viewPort = {top: curFrame.pageYOffset,
|
let viewPort = {top: curFrame.pageYOffset,
|
||||||
left: curFrame.pageXOffset,
|
left: curFrame.pageXOffset,
|
||||||
bottom: (curFrame.pageYOffset + curFrame.innerHeight),
|
bottom: (curFrame.pageYOffset + curFrame.innerHeight),
|
||||||
right:(curFrame.pageXOffset + curFrame.innerWidth)};
|
right:(curFrame.pageXOffset + curFrame.innerWidth)};
|
||||||
return (viewPort.left <= c.x + curFrame.pageXOffset &&
|
return (viewPort.left <= rect.right + curFrame.pageXOffset &&
|
||||||
c.x + curFrame.pageXOffset <= viewPort.right &&
|
rect.left + curFrame.pageXOffset <= viewPort.right &&
|
||||||
viewPort.top <= c.y + curFrame.pageYOffset &&
|
viewPort.top <= rect.bottom + curFrame.pageYOffset &&
|
||||||
c.y + curFrame.pageYOffset <= viewPort.bottom);
|
rect.top + curFrame.pageYOffset <= viewPort.bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function throws the visibility of the element error if the element is
|
* This function throws the visibility of the element error
|
||||||
* not displayed or the given coordinates are not within the viewport.
|
|
||||||
* @param 'x', and 'y' are the coordinates relative to the target.
|
|
||||||
* If they are not specified, then the center of the target is used.
|
|
||||||
*/
|
*/
|
||||||
function checkVisible(el, x, y) {
|
function checkVisible(el) {
|
||||||
//check if the element is visible
|
//check if the element is visible
|
||||||
let visible = utils.isElementDisplayed(el);
|
let visible = utils.isElementDisplayed(el);
|
||||||
if (!visible) {
|
if (!visible) {
|
||||||
@ -810,7 +805,7 @@ function checkVisible(el, x, y) {
|
|||||||
if (el.tagName.toLowerCase() === 'body') {
|
if (el.tagName.toLowerCase() === 'body') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!elementInViewport(el, x, y)) {
|
if (!elementInViewport(el)) {
|
||||||
//check if scroll function exist. If so, call it.
|
//check if scroll function exist. If so, call it.
|
||||||
if (el.scrollIntoView) {
|
if (el.scrollIntoView) {
|
||||||
el.scrollIntoView(false);
|
el.scrollIntoView(false);
|
||||||
@ -939,14 +934,14 @@ function singleTap(msg) {
|
|||||||
try {
|
try {
|
||||||
let el = elementManager.getKnownElement(msg.json.id, curFrame);
|
let el = elementManager.getKnownElement(msg.json.id, curFrame);
|
||||||
// after this block, the element will be scrolled into view
|
// after this block, the element will be scrolled into view
|
||||||
if (!checkVisible(el, msg.json.corx, msg.json.cory)) {
|
if (!checkVisible(el)) {
|
||||||
sendError("Element is not currently visible and may not be manipulated", 11, null, command_id);
|
sendError("Element is not currently visible and may not be manipulated", 11, null, command_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!curFrame.document.createTouch) {
|
if (!curFrame.document.createTouch) {
|
||||||
mouseEventsOnly = true;
|
mouseEventsOnly = true;
|
||||||
}
|
}
|
||||||
c = coordinates(el, msg.json.corx, msg.json.cory);
|
let c = coordinates(el, msg.json.corx, msg.json.cory);
|
||||||
generateEvents('tap', c.x, c.y, null, el);
|
generateEvents('tap', c.x, c.y, null, el);
|
||||||
sendOk(msg.json.command_id);
|
sendOk(msg.json.command_id);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user