Bug 1904665 - [wdspec] Updated tests for perform actions to check for "move target out of bounds" errors. r=webdriver-reviewers,jdescottes

Differential Revision: https://phabricator.services.mozilla.com/D220937
This commit is contained in:
Henrik Skupin 2024-09-10 13:12:33 +00:00
Родитель 5155a142db
Коммит 861fc2a11e
8 изменённых файлов: 152 добавлений и 29 удалений

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

@ -54,34 +54,26 @@ async def test_click_at_coordinates(bidi_session, top_context, load_static_test_
assert expected == filtered_events[1:]
@pytest.mark.parametrize("origin", ["pointer", "viewport"])
async def test_params_actions_origin_outside_viewport(bidi_session, top_context, origin):
actions = Actions()
actions.add_pointer().pointer_move(x=-50, y=-50, origin=origin)
with pytest.raises(MoveTargetOutOfBoundsException):
await bidi_session.input.perform_actions(
actions=actions, context=top_context["context"]
@pytest.mark.parametrize("origin", ["element", "pointer", "viewport"])
async def test_params_actions_origin_outside_viewport(
bidi_session, top_context, get_actions_origin_page, get_element, origin
):
if origin == "element":
url = get_actions_origin_page(
"""width: 100px; height: 50px; background: green;
position: relative; left: -200px; top: -100px;"""
)
await bidi_session.browsing_context.navigate(
context=top_context["context"],
url=url,
wait="complete",
)
async def test_params_actions_origin_element_outside_viewport(
bidi_session, top_context, get_actions_origin_page, get_element
):
url = get_actions_origin_page(
"""width: 100px; height: 50px; background: green;
position: relative; left: -200px; top: -100px;"""
)
await bidi_session.browsing_context.navigate(
context=top_context["context"],
url=url,
wait="complete",
)
elem = await get_element("#inner")
element = await get_element("#inner")
origin = get_element_origin(element)
actions = Actions()
actions.add_pointer().pointer_move(x=0, y=0, origin=get_element_origin(elem))
actions.add_pointer().pointer_move(x=-100, y=-100, origin=origin)
with pytest.raises(MoveTargetOutOfBoundsException):
await bidi_session.input.perform_actions(

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

@ -1,5 +1,6 @@
import pytest
from webdriver.bidi.error import MoveTargetOutOfBoundsException
from webdriver.bidi.modules.input import Actions, get_element_origin
from .. import get_events
@ -13,6 +14,36 @@ from . import (
pytestmark = pytest.mark.asyncio
@pytest.mark.parametrize("origin", ["element", "pointer", "viewport"])
async def test_params_actions_origin_outside_viewport(
bidi_session, get_actions_origin_page, top_context, get_element, origin
):
if origin == "element":
url = get_actions_origin_page(
"""width: 100px; height: 50px; background: green;
position: relative; left: -200px; top: -100px;"""
)
await bidi_session.browsing_context.navigate(
context=top_context["context"],
url=url,
wait="complete",
)
element = await get_element("#inner")
origin = get_element_origin(element)
actions = Actions()
(
actions.add_pointer(pointer_type="pen")
.pointer_move(x=-100, y=-100, origin=origin)
)
with pytest.raises(MoveTargetOutOfBoundsException):
await bidi_session.input.perform_actions(
actions=actions, context=top_context["context"]
)
@pytest.mark.parametrize("mode", ["open", "closed"])
@pytest.mark.parametrize("nested", [False, True], ids=["outer", "inner"])
async def test_pen_pointer_in_shadow_tree(

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

@ -1,5 +1,6 @@
import pytest
from webdriver.bidi.error import MoveTargetOutOfBoundsException
from webdriver.bidi.modules.input import Actions, get_element_origin
from .. import get_events
@ -13,6 +14,36 @@ from . import (
pytestmark = pytest.mark.asyncio
@pytest.mark.parametrize("origin", ["element", "pointer", "viewport"])
async def test_params_actions_origin_outside_viewport(
bidi_session, get_actions_origin_page, top_context, get_element, origin
):
if origin == "element":
url = get_actions_origin_page(
"""width: 100px; height: 50px; background: green;
position: relative; left: -200px; top: -100px;"""
)
await bidi_session.browsing_context.navigate(
context=top_context["context"],
url=url,
wait="complete",
)
element = await get_element("#inner")
origin = get_element_origin(element)
actions = Actions()
(
actions.add_pointer(pointer_type="touch")
.pointer_move(x=-100, y=-100, origin=origin)
)
with pytest.raises(MoveTargetOutOfBoundsException):
await bidi_session.input.perform_actions(
actions=actions, context=top_context["context"]
)
@pytest.mark.parametrize("mode", ["open", "closed"])
@pytest.mark.parametrize("nested", [False, True], ids=["outer", "inner"])
async def test_touch_pointer_in_shadow_tree(

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

@ -1,6 +1,6 @@
import pytest
from webdriver.bidi.error import NoSuchFrameException
from webdriver.bidi.error import MoveTargetOutOfBoundsException, NoSuchFrameException
from webdriver.bidi.modules.input import Actions, get_element_origin
from webdriver.bidi.modules.script import ContextTarget
@ -20,6 +20,23 @@ async def test_invalid_browsing_context(bidi_session):
await bidi_session.input.perform_actions(actions=actions, context="foo")
@pytest.mark.parametrize("origin", ["element", "viewport"])
async def test_params_actions_origin_outside_viewport(
bidi_session, setup_wheel_test, top_context, get_element, origin
):
if origin == "element":
element = await get_element("#scrollable")
origin = get_element_origin(element)
actions = Actions()
actions.add_wheel().scroll(x=-100, y=-100, delta_x=10, delta_y=20, origin=origin)
with pytest.raises(MoveTargetOutOfBoundsException):
await bidi_session.input.perform_actions(
actions=actions, context=top_context["context"]
)
@pytest.mark.parametrize("delta_x, delta_y", [(0, 10), (5, 0), (5, 10)])
async def test_scroll_not_scrollable(
bidi_session, setup_wheel_test, top_context, get_element, delta_x, delta_y

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

@ -1,6 +1,11 @@
import pytest
from webdriver.error import InvalidArgumentException, NoSuchWindowException, StaleElementReferenceException
from webdriver.error import (
InvalidArgumentException,
MoveTargetOutOfBoundsException,
NoSuchWindowException,
StaleElementReferenceException,
)
from tests.classic.perform_actions.support.mouse import (
get_inview_center,
@ -37,6 +42,15 @@ def test_stale_element_reference(session, stale_element, mouse_chain, as_frame):
mouse_chain.click(element=element).perform()
@pytest.mark.parametrize("origin", ["element", "pointer", "viewport"])
def test_params_actions_origin_outside_viewport(session, test_actions_page, mouse_chain, origin):
if origin == "element":
origin = session.find.css("#outer", all=False)
with pytest.raises(MoveTargetOutOfBoundsException):
mouse_chain.pointer_move(-100, -100, origin=origin).perform()
def test_click_at_coordinates(session, test_actions_page, mouse_chain):
div_point = {
"x": 82,

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

@ -1,6 +1,10 @@
import pytest
from webdriver.error import NoSuchWindowException, StaleElementReferenceException
from webdriver.error import (
MoveTargetOutOfBoundsException,
NoSuchWindowException,
StaleElementReferenceException,
)
from tests.classic.perform_actions.support.mouse import (
get_inview_center,
@ -34,6 +38,15 @@ def test_stale_element_reference(session, stale_element, pen_chain, as_frame):
pen_chain.click(element=element).perform()
@pytest.mark.parametrize("origin", ["element", "pointer", "viewport"])
def test_params_actions_origin_outside_viewport(session, test_actions_page, pen_chain, origin):
if origin == "element":
origin = session.find.css("#outer", all=False)
with pytest.raises(MoveTargetOutOfBoundsException):
pen_chain.pointer_move(-100, -100, origin=origin).perform()
@pytest.mark.parametrize("mode", ["open", "closed"])
@pytest.mark.parametrize("nested", [False, True], ids=["outer", "inner"])
def test_pen_pointer_in_shadow_tree(

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

@ -1,6 +1,10 @@
import pytest
from webdriver.error import NoSuchWindowException, StaleElementReferenceException
from webdriver.error import (
MoveTargetOutOfBoundsException,
NoSuchWindowException,
StaleElementReferenceException
)
from tests.classic.perform_actions.support.mouse import (
get_inview_center,
get_viewport_rect,
@ -9,6 +13,7 @@ from tests.classic.perform_actions.support.refine import get_events
from . import assert_pointer_events, record_pointer_events
def test_null_response_value(session, touch_chain):
value = touch_chain.click().perform()
assert value is None
@ -32,6 +37,15 @@ def test_stale_element_reference(session, stale_element, touch_chain, as_frame):
touch_chain.click(element=element).perform()
@pytest.mark.parametrize("origin", ["element", "pointer", "viewport"])
def test_params_actions_origin_outside_viewport(session, test_actions_page, touch_chain, origin):
if origin == "element":
origin = session.find.css("#outer", all=False)
with pytest.raises(MoveTargetOutOfBoundsException):
touch_chain.pointer_move(-100, -100, origin=origin).perform()
@pytest.mark.parametrize("mode", ["open", "closed"])
@pytest.mark.parametrize("nested", [False, True], ids=["outer", "inner"])
def test_touch_pointer_in_shadow_tree(

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

@ -1,6 +1,6 @@
import pytest
from webdriver.error import NoSuchWindowException
from webdriver.error import MoveTargetOutOfBoundsException, NoSuchWindowException
import time
from tests.classic.perform_actions.support.refine import get_events
@ -23,6 +23,17 @@ def test_no_browsing_context(session, closed_window, wheel_chain):
wheel_chain.scroll(0, 0, 0, 10).perform()
@pytest.mark.parametrize("origin", ["element", "viewport"])
def test_params_actions_origin_outside_viewport(
session, test_actions_scroll_page, wheel_chain, origin
):
if origin == "element":
origin = session.find.css("#scrollable", all=False)
with pytest.raises(MoveTargetOutOfBoundsException):
wheel_chain.scroll(-100, -100, 10, 20, origin="viewport").perform()
def test_scroll_not_scrollable(session, test_actions_scroll_page, wheel_chain):
target = session.find.css("#not-scrollable", all=False)