зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1423255 - Cleanup tests in test_click_scrolling.py. r=ato
MozReview-Commit-ID: CWJS4izi4RK --HG-- extra : rebase_source : 064592ed72d49238dc2cefffff58fa7a2a75013c
This commit is contained in:
Родитель
63f0dbc751
Коммит
426fd860a6
|
@ -2,36 +2,42 @@
|
|||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import urllib
|
||||
|
||||
from marionette_driver.by import By
|
||||
from marionette_driver.errors import MoveTargetOutOfBoundsException
|
||||
|
||||
from marionette_harness import MarionetteTestCase, skip, skip_if_mobile
|
||||
from marionette_harness import MarionetteTestCase, skip_if_mobile
|
||||
|
||||
|
||||
def inline(doc):
|
||||
return "data:text/html;charset=utf-8,{}".format(urllib.quote(doc))
|
||||
|
||||
|
||||
class TestClickScrolling(MarionetteTestCase):
|
||||
|
||||
|
||||
def test_clicking_on_anchor_scrolls_page(self):
|
||||
scrollScript = """
|
||||
var pageY;
|
||||
if (typeof(window.pageYOffset) == 'number') {
|
||||
pageY = window.pageYOffset;
|
||||
} else {
|
||||
pageY = document.documentElement.scrollTop;
|
||||
}
|
||||
return pageY;"""
|
||||
|
||||
test_html = self.marionette.absolute_url("macbeth.html")
|
||||
self.marionette.navigate(test_html)
|
||||
|
||||
self.marionette.find_element(By.PARTIAL_LINK_TEXT, "last speech").click()
|
||||
y_offset = self.marionette.execute_script(scrollScript)
|
||||
self.marionette.navigate(inline("""
|
||||
<a href="#content">Link to content</a>
|
||||
<div id="content" style="margin-top: 205vh;">Text</div>
|
||||
"""))
|
||||
|
||||
# Focusing on to click, but not actually following,
|
||||
# the link will scroll it in to view, which is a few
|
||||
# pixels further than 0
|
||||
self.marionette.find_element(By.CSS_SELECTOR, "a").click()
|
||||
|
||||
self.assertTrue(y_offset > 300)
|
||||
y_offset = self.marionette.execute_script("""
|
||||
var pageY;
|
||||
if (typeof(window.pageYOffset) == 'number') {
|
||||
pageY = window.pageYOffset;
|
||||
} else {
|
||||
pageY = document.documentElement.scrollTop;
|
||||
}
|
||||
return pageY;
|
||||
""")
|
||||
|
||||
self.assertGreater(y_offset, 300)
|
||||
|
||||
def test_should_scroll_to_click_on_an_element_hidden_by_overflow(self):
|
||||
test_html = self.marionette.absolute_url("click_out_of_bounds_overflow.html")
|
||||
|
@ -43,45 +49,6 @@ class TestClickScrolling(MarionetteTestCase):
|
|||
except MoveTargetOutOfBoundsException:
|
||||
self.fail("Should not be out of bounds")
|
||||
|
||||
@skip("Bug 1200197 - Cannot interact with elements hidden inside overflow:scroll")
|
||||
def test_should_be_able_to_click_on_an_element_hidden_by_overflow(self):
|
||||
test_html = self.marionette.absolute_url("scroll.html")
|
||||
self.marionette.navigate(test_html)
|
||||
|
||||
link = self.marionette.find_element(By.ID, "line8")
|
||||
link.click()
|
||||
self.assertEqual("line8", self.marionette.find_element(By.ID, "clicked").text)
|
||||
|
||||
def test_should_not_scroll_overflow_elements_which_are_visible(self):
|
||||
test_html = self.marionette.absolute_url("scroll2.html")
|
||||
self.marionette.navigate(test_html)
|
||||
|
||||
list_el = self.marionette.find_element(By.TAG_NAME, "ul")
|
||||
item = list_el.find_element(By.ID, "desired")
|
||||
item.click()
|
||||
y_offset = self.marionette.execute_script("return arguments[0].scrollTop;", script_args=[list_el])
|
||||
self.assertEqual(0, y_offset)
|
||||
|
||||
def test_should_not_scroll_if_already_scrolled_and_element_is_in_view(self):
|
||||
test_html = self.marionette.absolute_url("scroll3.html")
|
||||
self.marionette.navigate(test_html)
|
||||
|
||||
button1 = self.marionette.find_element(By.ID, "button1")
|
||||
button2 = self.marionette.find_element(By.ID, "button2")
|
||||
|
||||
button2.click()
|
||||
scroll_top = self.marionette.execute_script("return document.body.scrollTop;")
|
||||
button1.click()
|
||||
|
||||
self.assertEqual(scroll_top, self.marionette.execute_script("return document.body.scrollTop;"))
|
||||
|
||||
def test_should_be_able_to_click_radio_button_scrolled_into_view(self):
|
||||
test_html = self.marionette.absolute_url("scroll4.html")
|
||||
self.marionette.navigate(test_html)
|
||||
|
||||
# If we dont throw we are good
|
||||
self.marionette.find_element(By.ID, "radio").click()
|
||||
|
||||
@skip_if_mobile("Bug 1293855 - Lists differ: [70, 70] != [70, 120]")
|
||||
def test_should_not_scroll_elements_if_click_point_is_in_view(self):
|
||||
test_html = self.marionette.absolute_url("element_outside_viewport.html")
|
||||
|
@ -91,12 +58,76 @@ class TestClickScrolling(MarionetteTestCase):
|
|||
self.marionette.navigate(test_html)
|
||||
scroll = self.marionette.execute_script("return [window.scrollX, window.scrollY];")
|
||||
self.marionette.find_element(By.ID, "{0}-{1}".format(s, p)).click()
|
||||
self.assertEqual(scroll, self.marionette.execute_script("return [window.scrollX, window.scrollY];"))
|
||||
self.assertEqual(scroll, self.marionette.execute_script(
|
||||
"return [window.scrollX, window.scrollY];"))
|
||||
|
||||
@skip("Bug 1003687")
|
||||
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")
|
||||
self.marionette.navigate(test_html)
|
||||
def test_do_not_scroll_again_if_element_is_already_in_view(self):
|
||||
self.marionette.navigate(inline("""
|
||||
<div style="height: 200vh;">
|
||||
<button id="button1" style="margin-top: 105vh">Button1</button>
|
||||
<button id="button2" style="position: relative; top: 5em">Button2</button>
|
||||
</div>
|
||||
"""))
|
||||
button1 = self.marionette.find_element(By.ID, "button1")
|
||||
button2 = self.marionette.find_element(By.ID, "button2")
|
||||
|
||||
button2.click()
|
||||
scroll_top = self.marionette.execute_script("return document.body.scrollTop;")
|
||||
button1.click()
|
||||
|
||||
self.assertEqual(scroll_top, self.marionette.execute_script(
|
||||
"return document.body.scrollTop;"))
|
||||
|
||||
def test_scroll_radio_button_into_view(self):
|
||||
self.marionette.navigate(inline("""
|
||||
<input type="radio" id="radio" style="margin-top: 105vh;">
|
||||
"""))
|
||||
self.marionette.find_element(By.ID, "radio").click()
|
||||
|
||||
def test_overflow_scroll_do_not_scroll_elements_which_are_visible(self):
|
||||
self.marionette.navigate(inline("""
|
||||
<ul style='overflow: scroll; height: 8em; line-height: 3em'>
|
||||
<li></li>
|
||||
<li id="desired">Text</li>
|
||||
<li></li>
|
||||
<li></li>
|
||||
</ul>
|
||||
"""))
|
||||
|
||||
list_el = self.marionette.find_element(By.TAG_NAME, "ul")
|
||||
expected_y_offset = self.marionette.execute_script(
|
||||
"return arguments[0].scrollTop;", script_args=(list_el,))
|
||||
|
||||
item = list_el.find_element(By.ID, "desired")
|
||||
item.click()
|
||||
|
||||
y_offset = self.marionette.execute_script("return arguments[0].scrollTop;",
|
||||
script_args=(list_el,))
|
||||
self.assertEqual(expected_y_offset, y_offset)
|
||||
|
||||
def test_overflow_scroll_click_on_hidden_element(self):
|
||||
self.marionette.navigate(inline("""
|
||||
Result: <span id="result"></span>
|
||||
<ul style='overflow: scroll; width: 150px; height: 8em; line-height: 4em'
|
||||
onclick="document.getElementById('result').innerText = event.target.id;">
|
||||
<li>line1</li>
|
||||
<li>line2</li>
|
||||
<li>line3</li>
|
||||
<li id="line4">line4</li>
|
||||
</ul>
|
||||
"""))
|
||||
|
||||
self.marionette.find_element(By.ID, "line4").click()
|
||||
self.assertEqual("line4", self.marionette.find_element(By.ID, "result").text)
|
||||
|
||||
def test_overflow_scroll_vertically_for_click_point_outside_of_viewport(self):
|
||||
self.marionette.navigate(inline("""
|
||||
Result: <span id="result"></span>
|
||||
<div style='overflow: scroll; width: 100px; height: 100px; background-color: yellow;'>
|
||||
<div id="inner" style="width: 100px; height: 300px; background-color: green;"
|
||||
onclick="document.getElementById('result').innerText = event.type" ></div>
|
||||
</div>
|
||||
"""))
|
||||
|
||||
self.marionette.find_element(By.ID, "inner").click()
|
||||
self.assertEqual("clicked", self.marionette.find_element(By.ID, "clicked").text)
|
||||
self.assertEqual("click", self.marionette.find_element(By.ID, "result").text)
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,30 +0,0 @@
|
|||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<html>
|
||||
<head></head>
|
||||
<body>
|
||||
<script>
|
||||
function dump(event) {
|
||||
var elt = event.target || event.srcElement;
|
||||
document.getElementById('clicked').innerHTML = elt.innerHTML;
|
||||
}
|
||||
</script>
|
||||
<div style='height: 150px'></div>
|
||||
<ul style='overflow: scroll; width: 150px; height: 80px; background-color: yellow' onclick="dump(event)">
|
||||
<li id='line1'>line1</li>
|
||||
<li id='line2'>line2</li>
|
||||
<li id='line3'>line3</li>
|
||||
<li id='line4'>line4</li>
|
||||
<li id='line5'>line5</li>
|
||||
<li id='line6'>line6</li>
|
||||
<li id='line7'>line7</li>
|
||||
<li id='line8'>line8</li>
|
||||
<li id='line9'>line9</li>
|
||||
</ul>
|
||||
<div>
|
||||
Clicked: <span id='clicked'></span>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,24 +0,0 @@
|
|||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<html>
|
||||
<head></head>
|
||||
<body>
|
||||
<ul style='overflow: scroll; height: 100px;'>
|
||||
<li></li>
|
||||
<li></li>
|
||||
<li id="desired">Text</li>
|
||||
<li></li>
|
||||
<li></li>
|
||||
<li></li>
|
||||
<li></li>
|
||||
<li></li>
|
||||
<li></li>
|
||||
<li></li>
|
||||
<li></li>
|
||||
<li></li>
|
||||
<li></li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
|
@ -1,18 +0,0 @@
|
|||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
|
||||
<style type="text/css"></style>
|
||||
</head>
|
||||
<body>
|
||||
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
|
||||
<button id="button1">Button1</button>
|
||||
<br><br><br><br>
|
||||
|
||||
<button id="button2">Button2</button>
|
||||
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
|
||||
</body>
|
||||
</html>
|
|
@ -1,15 +0,0 @@
|
|||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
|
||||
<style type="text/css"></style>
|
||||
</head>
|
||||
<body>
|
||||
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
|
||||
<input type="radio" id="radio">
|
||||
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
|
||||
</body>
|
||||
</html>
|
|
@ -1,20 +0,0 @@
|
|||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<html>
|
||||
<head></head>
|
||||
<body>
|
||||
<script>
|
||||
function dump(text) {
|
||||
document.getElementById('clicked').innerHTML = text;
|
||||
}
|
||||
</script>
|
||||
<div style='overflow: scroll; width: 150px; height: 200px; background-color: yellow' id="outer">
|
||||
<div style="width: 150px; height: 5000px; background-color: red;" onclick="dump('clicked')" id="inner"></div>
|
||||
</div>
|
||||
<div>
|
||||
Clicked: <span id='clicked'></span>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче