tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 5f95d4ad4f0674f9055cfd528237271f054c92d0
parent 4340c11d32351cf1652248563055e53a0255cab2
Author: Henrik Skupin <mail@hskupin.info>
Date:   Tue, 11 Nov 2025 10:33:27 +0000

Bug 1848958 - [wdspec] Update tests for dispatching mouse events via the parent process. r=jdescottes

Differential Revision: https://phabricator.services.mozilla.com/D265222

Diffstat:
Mtesting/web-platform/meta/webdriver/tests/bidi/input/perform_actions/pointer_mouse.py.ini | 26+++-----------------------
Atesting/web-platform/meta/webdriver/tests/classic/perform_actions/pointer_dblclick.py.ini | 12++++++++++++
Atesting/web-platform/meta/webdriver/tests/classic/perform_actions/pointer_mouse.py.ini | 12++++++++++++
Mtesting/web-platform/tests/webdriver/tests/bidi/input/perform_actions/pointer_mouse.py | 68+++++++++++++++++++++++++++++++++++++++++++++-----------------------
Mtesting/web-platform/tests/webdriver/tests/bidi/input/perform_actions/pointer_mouse_modifier.py | 3++-
Mtesting/web-platform/tests/webdriver/tests/classic/perform_actions/pointer_contextmenu.py | 3++-
Mtesting/web-platform/tests/webdriver/tests/classic/perform_actions/pointer_mouse.py | 52++++++++++++++++++++++++++++++++++------------------
Mtesting/web-platform/tests/webdriver/tests/classic/perform_actions/pointer_mouse_drag.py | 20++++++++++----------
Mtesting/web-platform/tests/webdriver/tests/classic/perform_actions/pointer_origin.py | 8+++++---
Mtesting/web-platform/tests/webdriver/tests/support/fixtures.py | 2+-
10 files changed, 126 insertions(+), 80 deletions(-)

diff --git a/testing/web-platform/meta/webdriver/tests/bidi/input/perform_actions/pointer_mouse.py.ini b/testing/web-platform/meta/webdriver/tests/bidi/input/perform_actions/pointer_mouse.py.ini @@ -1,24 +1,4 @@ [pointer_mouse.py] - [test_drag_and_drop[10-15-0\]] - disabled: - if os == "android": bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1762119 - - [test_drag_and_drop[10-15-300\]] - disabled: - if os == "android": bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1762119 - - [test_drag_and_drop[10-15-800\]] - disabled: - if os == "android": bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1762119 - - [test_drag_and_drop[10--15-0\]] - disabled: - if os == "android": bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1762119 - - [test_drag_and_drop[10--15-300\]] - disabled: - if os == "android": bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1762119 - - [test_drag_and_drop[10--15-800\]] - disabled: - if os == "android": bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1762119 + [test_move_to_position_in_viewport[default value\]] + expected: + if not remoteAsyncEvents: FAIL # Cannot be fixed when dispatching the event in the content process diff --git a/testing/web-platform/meta/webdriver/tests/classic/perform_actions/pointer_dblclick.py.ini b/testing/web-platform/meta/webdriver/tests/classic/perform_actions/pointer_dblclick.py.ini @@ -0,0 +1,12 @@ +[pointer_dblclick.py] + [test_dblclick_at_coordinates[0\]] + bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1999380 + expected: + if os == "android": FAIL + PASS + + [test_dblclick_at_coordinates[200\]] + bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1999380 + expected: + if os == "android": FAIL + PASS diff --git a/testing/web-platform/meta/webdriver/tests/classic/perform_actions/pointer_mouse.py.ini b/testing/web-platform/meta/webdriver/tests/classic/perform_actions/pointer_mouse.py.ini @@ -0,0 +1,12 @@ +[pointer_mouse.py] + [test_move_to_position_in_viewport[default value\]] + expected: + if not remoteAsyncEvents: FAIL # Cannot be fixed when dispatching the event in the content process + + [test_down_closes_browsing_context[without up\]] + bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1998260 + expected: + if remoteAsyncEvents: PASS + if (os == "android") and not debug: [PASS, FAIL] + if (os == "linux"): [PASS, FAIL] + FAIL diff --git a/testing/web-platform/tests/webdriver/tests/bidi/input/perform_actions/pointer_mouse.py b/testing/web-platform/tests/webdriver/tests/bidi/input/perform_actions/pointer_mouse.py @@ -20,20 +20,27 @@ pytestmark = pytest.mark.asyncio CONTEXT_LOAD_EVENT = "browsingContext.load" -async def test_pointer_down_closes_browsing_context( - bidi_session, configuration, get_element, new_tab, inline, subscribe_events, - wait_for_event +@pytest.mark.parametrize("mouse_up", [False, True], ids=["without up", "with up"]) +async def test_down_closes_browsing_context( + bidi_session, + configuration, + get_element, + top_context, + inline, + subscribe_events, + wait_for_event, + mouse_up ): - url = inline("""<input onpointerdown="window.close()">close</input>""") + url = inline("""<input onmousedown="window.close()">close</input>""") - # Opening a new context via `window.open` is required for script to be able - # to close it. + # Opening a new context via `window.open` is required + # for the script to be able to close it. await subscribe_events(events=[CONTEXT_LOAD_EVENT]) on_load = wait_for_event(CONTEXT_LOAD_EVENT) await bidi_session.script.evaluate( expression=f"window.open('{url}')", - target=ContextTarget(new_tab["context"]), + target=ContextTarget(top_context["context"]), await_promise=True ) # Wait for the new context to be created and get it. @@ -42,20 +49,35 @@ async def test_pointer_down_closes_browsing_context( element = await get_element("input", context=new_context) origin = get_element_origin(element) - actions = Actions() - ( - actions.add_pointer() - .pointer_move(0, 0, origin=origin) - .pointer_down(button=0) - .pause(250 * configuration["timeout_multiplier"]) - .pointer_up(button=0) - ) + if mouse_up: + actions = Actions() + ( + actions.add_pointer() + .pointer_move(0, 0, origin=origin) + .pointer_down(button=0) + .pause(250 * configuration["timeout_multiplier"]) + .pointer_up(button=0) + ) + + with pytest.raises(NoSuchFrameException): + await bidi_session.input.perform_actions( + actions=actions, context=new_context["context"] + ) + else: + actions = Actions() + ( + actions.add_pointer() + .pointer_move(0, 0, origin=origin) + .pointer_down(button=0) + ) - with pytest.raises(NoSuchFrameException): await bidi_session.input.perform_actions( actions=actions, context=new_context["context"] ) + with pytest.raises(NoSuchFrameException): + await bidi_session.browsing_context.get_tree(root=new_context["context"], max_depth=0) + async def test_click_at_coordinates(bidi_session, top_context, load_static_test_page): await load_static_test_page(page="test_actions.html") @@ -361,13 +383,13 @@ async def test_click_navigation( assert event["url"] == destination -@pytest.mark.parametrize("x, y, event_count", [ - (0, 0, 0), - (1, 0, 1), - (0, 1, 1), +@pytest.mark.parametrize("x, y", [ + (0, 0), + (1, 0), + (0, 1), ], ids=["default value", "x", "y"]) async def test_move_to_position_in_viewport( - bidi_session, load_static_test_page, top_context, x, y, event_count + bidi_session, load_static_test_page, top_context, x, y ): await load_static_test_page(page="test_actions.html") @@ -379,7 +401,7 @@ async def test_move_to_position_in_viewport( ) events = await get_events(bidi_session, top_context["context"]) - assert len(events) == event_count + assert len(events) == 1 # Move again to check that no further mouse move event is emitted. actions = Actions() @@ -390,7 +412,7 @@ async def test_move_to_position_in_viewport( ) events = await get_events(bidi_session, top_context["context"]) - assert len(events) == event_count + assert len(events) == 1 @pytest.mark.parametrize("origin", ["viewport", "pointer", "element"]) diff --git a/testing/web-platform/tests/webdriver/tests/bidi/input/perform_actions/pointer_mouse_modifier.py b/testing/web-platform/tests/webdriver/tests/bidi/input/perform_actions/pointer_mouse_modifier.py @@ -126,7 +126,8 @@ async def test_control_click_release( ] all_events = await get_events(bidi_session, top_context["context"]) events = [filter_dict(e, expected[0]) for e in all_events] - assert events == expected + for expected_event in expected: + assert expected_event in events async def test_many_modifiers_click( diff --git a/testing/web-platform/tests/webdriver/tests/classic/perform_actions/pointer_contextmenu.py b/testing/web-platform/tests/webdriver/tests/classic/perform_actions/pointer_contextmenu.py @@ -75,4 +75,5 @@ def test_release_control_click(session, key_reporter, key_chain, mouse_chain): {"type": "keyup"}, ] events = [filter_dict(e, expected[0]) for e in get_events(session)] - assert events == expected + for expected_event in expected: + assert expected_event in events diff --git a/testing/web-platform/tests/webdriver/tests/classic/perform_actions/pointer_mouse.py b/testing/web-platform/tests/webdriver/tests/classic/perform_actions/pointer_mouse.py @@ -33,20 +33,33 @@ def test_no_browsing_context(session, closed_frame, mouse_chain): mouse_chain.click().perform() -def test_pointer_down_closes_browsing_context( - session, configuration, http_new_tab, inline, mouse_chain +@pytest.mark.parametrize("mouse_up", [False, True], ids=["without up", "with up"]) +def test_down_closes_browsing_context( + session, configuration, inline, mouse_chain, mouse_up ): - session.url = inline( - """<input onpointerdown="window.close()">close</input>""") + # Opening a new tab/window via `window.open` is required + # for the script to be able to close it. + new_window = session.execute_script(f"return window.open()") + session.window_handle = new_window.id + session.url = inline("""<input onmousedown="window.close()">close</input>""") + origin = session.find.css("input", all=False) - with pytest.raises(NoSuchWindowException): + if mouse_up: + with pytest.raises(NoSuchWindowException): + mouse_chain.pointer_move(0, 0, origin=origin) \ + .pointer_down(button=0) \ + .pause(100 * configuration["timeout_multiplier"]) \ + .pointer_up(button=0) \ + .perform() + else: mouse_chain.pointer_move(0, 0, origin=origin) \ .pointer_down(button=0) \ - .pause(100 * configuration["timeout_multiplier"]) \ - .pointer_up(button=0) \ .perform() + with pytest.raises(NoSuchWindowException): + session.url + @pytest.mark.parametrize("as_frame", [False, True], ids=["top_context", "child_context"]) def test_stale_element_reference(session, stale_element, mouse_chain, as_frame): @@ -74,13 +87,17 @@ def test_click_at_coordinates(session, test_actions_page, mouse_chain): .pointer_move(div_point["x"], div_point["y"], duration=1000) \ .click() \ .perform() + events = get_events(session) assert len(events) == 4 + assert_move_to_coordinates(div_point, "outer", events) + for e in events: if e["type"] != "mousedown": assert e["buttons"] == 0 assert e["button"] == 0 + expected = [ {"type": "mousedown", "buttons": 1}, {"type": "mouseup", "buttons": 0}, @@ -153,8 +170,10 @@ def test_click_element_center(session, test_actions_page, mouse_chain): outer = session.find.css("#outer", all=False) center = get_inview_center(outer.rect, get_viewport_rect(session)) mouse_chain.click(element=outer).perform() + events = get_events(session) assert len(events) == 4 + event_types = [e["type"] for e in events] assert ["mousemove", "mousedown", "mouseup", "click"] == event_types for e in events: @@ -221,29 +240,27 @@ def test_click_navigation(session, url, inline): wait.until(assert_page_loaded) -@pytest.mark.parametrize("x, y, event_count", [ - (0, 0, 0), - (1, 0, 1), - (0, 1, 1), +@pytest.mark.parametrize("x, y", [ + (0, 0), + (1, 0), + (0, 1), ], ids=["default value", "x", "y"]) -def test_move_to_position_in_viewport( - session, test_actions_page, mouse_chain, x, y, event_count -): +def test_move_to_position_in_viewport(session, test_actions_page, mouse_chain, x, y): mouse_chain.pointer_move(x, y).perform() events = get_events(session) - assert len(events) == event_count + assert len(events) == 1 # Move again to check that no further mouse move event is emitted. mouse_chain.pointer_move(x, y).perform() events = get_events(session) - assert len(events) == event_count + assert len(events) == 1 def test_move_to_fractional_position(session, inline, mouse_chain): session.url = inline(""" <script> var allEvents = { events: [] }; - window.addEventListener("pointermove", ev => { + window.addEventListener("mousemove", ev => { allEvents.events.push({ "type": event.type, "pageX": event.pageX, @@ -267,7 +284,6 @@ def test_move_to_fractional_position(session, inline, mouse_chain): # For now we are allowing any of floor, ceil, or precise values, because # it's unclear what the actual spec requirements really are - assert events[0]["type"] == "pointermove" assert events[0]["pageX"] == pytest.approx(target_point["x"], abs=1.0) assert events[0]["pageY"] == pytest.approx(target_point["y"], abs=1.0) diff --git a/testing/web-platform/tests/webdriver/tests/classic/perform_actions/pointer_mouse_drag.py b/testing/web-platform/tests/webdriver/tests/classic/perform_actions/pointer_mouse_drag.py @@ -33,11 +33,11 @@ def test_drag_and_drop(session, .pointer_move(80, 50, duration=100, origin="pointer") \ .perform() - # mouseup that ends the drag is at the expected destination - e = get_events(session)[1] - assert e["type"] == "mouseup" - assert e["pageX"] == pytest.approx(initial_center["x"] + dx, abs=1.0) - assert e["pageY"] == pytest.approx(initial_center["y"] + dy, abs=1.0) + # `mouseup` that ends the drag is at the expected destination + events = get_events(session) + assert events[1]["type"] == "mouseup" + assert events[1]["pageX"] == pytest.approx(initial_center["x"] + dx, abs=1.0) + assert events[1]["pageY"] == pytest.approx(initial_center["y"] + dy, abs=1.0) def check_final_position(_): assert drag_target.rect["x"] == pytest.approx( @@ -70,12 +70,12 @@ def test_drag_and_drop_with_draggable_element(session_new_window, .pointer_move(80, 50, duration=100, origin="pointer") \ .perform() # mouseup that ends the drag is at the expected destination - e = get_events(new_session) - assert len(e) >= 5 - assert e[1]["type"] == "dragstart", "Events captured were {}".format(e) - assert e[2]["type"] == "dragover", "Events captured were {}".format(e) + events = get_events(session_new_window) + assert len(events) >= 5 + assert events[1]["type"] == "dragstart", "Events captured were {}".format(events) + assert events[2]["type"] == "dragover", "Events captured were {}".format(events) drag_events_captured = [ - ev["type"] for ev in e if ev["type"].startswith("drag") or ev["type"].startswith("drop") + ev["type"] for ev in events if ev["type"].startswith("drag") or ev["type"].startswith("drop") ] assert "dragend" in drag_events_captured assert "dragenter" in drag_events_captured diff --git a/testing/web-platform/tests/webdriver/tests/classic/perform_actions/pointer_origin.py b/testing/web-platform/tests/webdriver/tests/classic/perform_actions/pointer_origin.py @@ -37,9 +37,11 @@ def test_pointer_inside(session, mouse_chain, get_actions_origin_page): session.url = get_actions_origin_page( "width: 100px; height: 50px; background: green;" ) - mouse_chain.pointer_move(start_point["x"], start_point["y"]).pointer_move( - offset["x"], offset["y"], origin="pointer" - ).perform() + (mouse_chain + .pointer_move(start_point["x"], start_point["y"]) + .pointer_move(offset["x"], offset["y"], origin="pointer") + .perform() + ) click_coords = session.execute_script("return window.coords;") assert click_coords["x"] == pytest.approx(start_point["x"] + offset["x"], abs=1.0) diff --git a/testing/web-platform/tests/webdriver/tests/support/fixtures.py b/testing/web-platform/tests/webdriver/tests/support/fixtures.py @@ -315,7 +315,7 @@ def iframe(inline): @pytest.fixture def get_actions_origin_page(inline): - """Create a test pagefor action origin tests, recording mouse coordinates + """Create a test page for action origin tests, recording mouse coordinates automatically on window.coords.""" def get_actions_origin_page(inner_style, outer_style=""):