Backed out 2 changesets (bug 1806897, bug 1824230) for causing webredenr failures CLOSED TREE

Backed out changeset 8a3e28c800cf (bug 1824230)
Backed out changeset 83439fa6f77c (bug 1806897)
This commit is contained in:
Noemi Erli 2023-07-02 08:09:16 +03:00
Родитель decb18e6ab
Коммит ba5e5ab5dc
16 изменённых файлов: 13 добавлений и 571 удалений

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

@ -1,16 +1,4 @@
[pointer_pen.py]
[test_pen_pointer_in_shadow_tree[outer-open\]]
expected: FAIL
[test_pen_pointer_in_shadow_tree[outer-closed\]]
expected: FAIL
[test_pen_pointer_in_shadow_tree[inner-open\]]
expected: FAIL
[test_pen_pointer_in_shadow_tree[inner-closed\]]
expected: FAIL
[test_pen_pointer_properties]
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1658880
expected: FAIL

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

@ -4,17 +4,5 @@
if (os == "win") and not debug and (processor == "x86_64"): [ERROR, FAIL]
ERROR
[test_pen_pointer_in_shadow_tree[outer-open\]]
expected: FAIL
[test_pen_pointer_in_shadow_tree[outer-closed\]]
expected: FAIL
[test_pen_pointer_in_shadow_tree[inner-open\]]
expected: FAIL
[test_pen_pointer_in_shadow_tree[inner-closed\]]
expected: FAIL
[test_pen_pointer_properties]
expected: FAIL

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

@ -2,19 +2,15 @@ import json
from webdriver.bidi.modules.script import ContextTarget
async def get_object_from_context(bidi_session, context, object_path):
"""Return a plain JS object from a given context, accessible at the given object_path"""
events_str = await bidi_session.script.evaluate(
expression=f"JSON.stringify({object_path})",
target=ContextTarget(context),
await_promise=False,
)
return json.loads(events_str["value"])
async def get_events(bidi_session, context):
"""Return list of key events recorded on the test_actions.html page."""
events = await get_object_from_context(bidi_session, context, "allEvents.events")
events_str = await bidi_session.script.evaluate(
expression="JSON.stringify(allEvents.events)",
target=ContextTarget(context),
await_promise=False,
)
events = json.loads(events_str["value"])
# `key` values in `allEvents` may be escaped (see `escapeSurrogateHalf` in
# test_actions.html), so this converts them back into unicode literals.

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

@ -1,23 +1,6 @@
from webdriver.bidi.modules.script import ContextTarget
from ... import get_viewport_dimensions, remote_mapping_to_dict
from .. import get_object_from_context
async def assert_pointer_events(
bidi_session, context, expected_events, target, pointer_type
):
events = await get_object_from_context(
bidi_session, context["context"], "window.recordedEvents"
)
assert len(events) == len(expected_events)
event_types = [e["type"] for e in events]
assert expected_events == event_types
for e in events:
assert e["target"] == target
assert e["pointerType"] == pointer_type
async def get_inview_center_bidi(bidi_session, context, element):
elem_rect = await get_element_rect(bidi_session, context=context, element=element)
@ -56,31 +39,3 @@ el => el.getBoundingClientRect().toJSON()
)
return remote_mapping_to_dict(result["value"])
async def record_pointer_events(bidi_session, context, container, selector):
# Record basic mouse / pointer events on the element matching the given
# selector in the container.
# The serialized element will be returned
target = await bidi_session.script.call_function(
function_declaration=f"""container => {{
const target = container.querySelector("{selector}");
window.recordedEvents = [];
function onPointerEvent(event) {{
window.recordedEvents.push({{
"type": event.type,
"pointerType": event.pointerType,
"target": event.target.id
}});
}}
target.addEventListener("pointerdown", onPointerEvent);
target.addEventListener("pointerup", onPointerEvent);
return target;
}}
""",
arguments=[container],
target=ContextTarget(context["context"]),
await_promise=False,
)
return target

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

@ -1,11 +1,9 @@
import pytest
from webdriver.bidi.modules.input import Actions
from webdriver.bidi.modules.script import ContextTarget
from tests.support.keys import Keys
from .. import get_keys_value
from . import get_shadow_root_from_test_page
pytestmark = pytest.mark.asyncio
@ -47,48 +45,6 @@ async def test_key_codepoint(
assert keys_value == value
@pytest.mark.parametrize("mode", ["open", "closed"])
@pytest.mark.parametrize("nested", [False, True], ids=["outer", "inner"])
async def test_key_shadow_tree(bidi_session, top_context, get_test_page, mode, nested):
await bidi_session.browsing_context.navigate(
context=top_context["context"],
url=get_test_page(
shadow_doc="<div><input type=text></div>",
shadow_root_mode=mode,
nested_shadow_dom=nested,
),
wait="complete",
)
shadow_root = await get_shadow_root_from_test_page(bidi_session, top_context, nested)
input_el = await bidi_session.script.call_function(
function_declaration=f"""shadowRoot => {{
const input = shadowRoot.querySelector('input');
input.focus();
return input;
}}
""",
arguments=[shadow_root],
target=ContextTarget(top_context["context"]),
await_promise=False,
)
actions = Actions()
(actions.add_key().key_down("a").key_up("a"))
await bidi_session.input.perform_actions(
actions=actions, context=top_context["context"]
)
input_value = await bidi_session.script.call_function(
function_declaration="input => input.value",
arguments=[input_el],
target=ContextTarget(top_context["context"]),
await_promise=False,
)
assert input_value["value"] == "a"
async def test_null_response_value(bidi_session, top_context):
actions = Actions()
actions.add_key().key_down("a").key_up("a")

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

@ -75,7 +75,9 @@ async def test_non_printable_key_sends_events(
(Keys.R_SHIFT, "R_SHIFT"),
],
)
async def test_key_modifier_key(bidi_session, top_context, setup_key_test, key, event):
async def test_key_modifier_key(
bidi_session, top_context, setup_key_test, key, event
):
code = ALL_EVENTS[event]["code"]
value = ALL_EVENTS[event]["key"]

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

@ -1,19 +1,12 @@
import pytest
from webdriver.bidi.modules.input import Actions, get_element_origin
from webdriver.bidi.modules.script import ContextTarget
from tests.support.asserts import assert_move_to_coordinates
from tests.support.helpers import filter_dict
from .. import get_events
from . import (
assert_pointer_events,
get_element_rect,
get_inview_center_bidi,
get_shadow_root_from_test_page,
record_pointer_events,
)
from . import get_element_rect, get_inview_center_bidi
pytestmark = pytest.mark.asyncio
@ -124,53 +117,6 @@ async def test_click_element_center(
assert e["target"] == "outer"
@pytest.mark.parametrize("mode", ["open", "closed"])
@pytest.mark.parametrize("nested", [False, True], ids=["outer", "inner"])
async def test_click_element_in_shadow_tree(
bidi_session, top_context, get_test_page, mode, nested
):
await bidi_session.browsing_context.navigate(
context=top_context["context"],
url=get_test_page(
shadow_doc="""
<div id="pointer-target"
style="width: 10px; height: 10px; background-color:blue;">
</div>""",
shadow_root_mode=mode,
nested_shadow_dom=nested,
),
wait="complete",
)
shadow_root = await get_shadow_root_from_test_page(
bidi_session, top_context, nested
)
target = await record_pointer_events(
bidi_session, top_context, shadow_root, "#pointer-target"
)
actions = Actions()
(
actions.add_pointer()
.pointer_move(x=0, y=0, origin=get_element_origin(target))
.pointer_down(button=0)
.pointer_up(button=0)
)
await bidi_session.input.perform_actions(
actions=actions, context=top_context["context"]
)
await assert_pointer_events(
bidi_session,
top_context,
expected_events=["pointerdown", "pointerup"],
target="pointer-target",
pointer_type="mouse",
)
async def test_click_navigation(
bidi_session,
top_context,

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

@ -1,67 +1,13 @@
import pytest
from webdriver.bidi.modules.input import Actions, get_element_origin
from webdriver.bidi.modules.script import ContextTarget
from .. import get_events
from . import (
assert_pointer_events,
get_inview_center_bidi,
get_shadow_root_from_test_page,
record_pointer_events,
)
from . import get_inview_center_bidi
pytestmark = pytest.mark.asyncio
@pytest.mark.parametrize("mode", ["open", "closed"])
@pytest.mark.parametrize("nested", [False, True], ids=["outer", "inner"])
async def test_pen_pointer_in_shadow_tree(
bidi_session, top_context, get_test_page, mode, nested
):
await bidi_session.browsing_context.navigate(
context=top_context["context"],
url=get_test_page(
shadow_doc="""
<div id="pointer-target"
style="width: 10px; height: 10px; background-color:blue;">
</div>""",
shadow_root_mode=mode,
nested_shadow_dom=nested,
),
wait="complete",
)
shadow_root = await get_shadow_root_from_test_page(
bidi_session, top_context, nested
)
# Add a simplified event recorder to track events in the test ShadowRoot.
target = await record_pointer_events(
bidi_session, top_context, shadow_root, "#pointer-target"
)
actions = Actions()
(
actions.add_pointer(pointer_type="pen")
.pointer_move(x=0, y=0, origin=get_element_origin(target))
.pointer_down(button=0)
.pointer_up(button=0)
)
await bidi_session.input.perform_actions(
actions=actions, context=top_context["context"]
)
await assert_pointer_events(
bidi_session,
top_context,
expected_events=["pointerdown", "pointerup"],
target="pointer-target",
pointer_type="pen",
)
async def test_pen_pointer_properties(
bidi_session, top_context, get_element, load_static_test_page
):

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

@ -1,67 +1,13 @@
import pytest
from webdriver.bidi.modules.input import Actions, get_element_origin
from webdriver.bidi.modules.script import ContextTarget
from .. import get_events
from . import (
assert_pointer_events,
get_inview_center_bidi,
get_shadow_root_from_test_page,
record_pointer_events,
)
from . import get_inview_center_bidi
pytestmark = pytest.mark.asyncio
@pytest.mark.parametrize("mode", ["open", "closed"])
@pytest.mark.parametrize("nested", [False, True], ids=["outer", "inner"])
async def test_touch_pointer_in_shadow_tree(
bidi_session, top_context, get_test_page, mode, nested
):
await bidi_session.browsing_context.navigate(
context=top_context["context"],
url=get_test_page(
shadow_doc="""
<div id="pointer-target"
style="width: 10px; height: 10px; background-color:blue;">
</div>""",
shadow_root_mode=mode,
nested_shadow_dom=nested,
),
wait="complete",
)
shadow_root = await get_shadow_root_from_test_page(
bidi_session, top_context, nested
)
# Add a simplified event recorder to track events in the test ShadowRoot.
target = await record_pointer_events(
bidi_session, top_context, shadow_root, "#pointer-target"
)
actions = Actions()
(
actions.add_pointer(pointer_type="touch")
.pointer_move(x=0, y=0, origin=get_element_origin(target))
.pointer_down(button=0)
.pointer_up(button=0)
)
await bidi_session.input.perform_actions(
actions=actions, context=top_context["context"]
)
await assert_pointer_events(
bidi_session,
top_context,
expected_events=["pointerdown", "pointerup"],
target="pointer-target",
pointer_type="touch",
)
async def test_touch_pointer_properties(
bidi_session, top_context, get_element, load_static_test_page
):

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

@ -1,10 +1,7 @@
import pytest
from webdriver.bidi.modules.input import Actions, get_element_origin
from webdriver.bidi.modules.script import ContextTarget
from .. import get_events, get_object_from_context
from . import get_shadow_root_from_test_page
from .. import get_events
pytestmark = pytest.mark.asyncio
@ -82,71 +79,3 @@ async def test_wheel_scroll_overflow(
assert events[0]["deltaY"] >= delta_y
assert events[0]["deltaZ"] == 0
assert events[0]["target"] == "scrollContent"
@pytest.mark.parametrize("mode", ["open", "closed"])
@pytest.mark.parametrize("nested", [False, True], ids=["outer", "inner"])
async def test_wheel_scroll_shadow_tree(
bidi_session, top_context, get_test_page, mode, nested
):
await bidi_session.browsing_context.navigate(
context=top_context["context"],
url=get_test_page(
shadow_doc="""
<div id="scrollableShadowTree"
style="width: 100px; height: 100px; overflow: auto;">
<div
id="scrollableShadowTreeContent"
style="width: 600px; height: 1000px; background-color:blue"></div>
</div>""",
shadow_root_mode=mode,
nested_shadow_dom=nested,
),
wait="complete",
)
shadow_root = await get_shadow_root_from_test_page(bidi_session, top_context, nested)
# Add a simplified event recorder to track events in the test ShadowRoot.
scrollable = await bidi_session.script.call_function(
function_declaration=f"""shadowRoot => {{
window.wheelEvents = [];
const scrollable = shadowRoot.querySelector("#scrollableShadowTree");
scrollable.addEventListener("wheel",
function(event) {{
window.wheelEvents.push({{
"deltaX": event.deltaX,
"deltaY": event.deltaY,
"target": event.target.id
}});
}}
);
return scrollable;
}}
""",
arguments=[shadow_root],
target=ContextTarget(top_context["context"]),
await_promise=False,
)
actions = Actions()
actions.add_wheel().scroll(
x=0,
y=0,
delta_x=5,
delta_y=10,
origin=get_element_origin(scrollable),
)
await bidi_session.input.perform_actions(
actions=actions, context=top_context["context"]
)
events = await get_object_from_context(
bidi_session, top_context["context"], "window.wheelEvents"
)
assert len(events) == 1
assert events[0]["deltaX"] >= 5
assert events[0]["deltaY"] >= 10
assert events[0]["target"] == "scrollableShadowTreeContent"

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

@ -1,31 +1,3 @@
def assert_pointer_events(session, expected_events, target, pointer_type):
events = session.execute_script("return window.recordedEvents;")
assert len(events) == len(expected_events)
event_types = [e["type"] for e in events]
assert expected_events == event_types
for e in events:
assert e["target"] == target
assert e["pointerType"] == pointer_type
def record_pointer_events(session, element):
# Record basic mouse / pointer events on a given element.
session.execute_script(
"""
window.recordedEvents = [];
function onPointerEvent(event) {
window.recordedEvents.push({
"pointerType": event.pointerType,
"target": event.target.id,
"type": event.type,
});
}
arguments[0].addEventListener("pointerdown", onPointerEvent);
arguments[0].addEventListener("pointerup", onPointerEvent);
""",
args=(element,),
)
def perform_actions(session, actions):
return session.transport.send(
"POST",

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

@ -36,27 +36,3 @@ def test_backspace_erases_keys(session, key_reporter, key_chain):
.perform()
assert get_keys(key_reporter) == "ef"
@pytest.mark.parametrize("mode", ["open", "closed"])
@pytest.mark.parametrize("nested", [False, True], ids=["outer", "inner"])
def test_element_in_shadow_tree(session, get_test_page, key_chain, mode, nested):
session.url = get_test_page(
shadow_doc="<div><input type=text></div>",
shadow_root_mode=mode,
nested_shadow_dom=nested,
)
shadow_root = session.find.css("custom-element", all=False).shadow_root
if nested:
shadow_root = shadow_root.find_element(
"css selector", "inner-custom-element"
).shadow_root
input_el = shadow_root.find_element("css selector", "input")
input_el.click()
key_chain.key_down("a").key_up("a").perform()
assert input_el.property("value") == "a"

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

@ -13,8 +13,6 @@ from tests.support.asserts import assert_move_to_coordinates
from tests.support.helpers import filter_dict
from tests.support.sync import Poll
from . import assert_pointer_events, record_pointer_events
def test_null_response_value(session, mouse_chain):
value = mouse_chain.click().perform()
@ -103,36 +101,6 @@ def test_click_element_center(session, test_actions_page, mouse_chain):
assert e["target"] == "outer"
@pytest.mark.parametrize("mode", ["open", "closed"])
@pytest.mark.parametrize("nested", [False, True], ids=["outer", "inner"])
def test_click_element_in_shadow_tree(
session, get_test_page, mouse_chain, mode, nested
):
session.url = get_test_page(
shadow_doc="""
<div id="pointer-target"
style="width: 10px; height: 10px; background-color:blue;">
</div>""",
shadow_root_mode=mode,
nested_shadow_dom=nested,
)
shadow_root = session.find.css("custom-element", all=False).shadow_root
if nested:
shadow_root = shadow_root.find_element("css selector", "inner-custom-element").shadow_root
target = shadow_root.find_element("css selector", "#pointer-target")
record_pointer_events(session, target)
mouse_chain.click(element=target).perform()
assert_pointer_events(
session,
expected_events=["pointerdown", "pointerup"],
target="pointer-target",
pointer_type="mouse",
)
def test_click_navigation(session, url, inline):
destination = url("/webdriver/tests/support/html/test_actions.html")
start = inline("<a href=\"{}\" id=\"link\">destination</a>".format(destination))

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

@ -10,8 +10,6 @@ from tests.classic.perform_actions.support.mouse import (
)
from tests.classic.perform_actions.support.refine import get_events
from . import assert_pointer_events, record_pointer_events
def test_null_response_value(session, pen_chain):
value = pen_chain.click().perform()
@ -36,44 +34,6 @@ def test_stale_element_reference(session, stale_element, pen_chain, as_frame):
pen_chain.click(element=element).perform()
@pytest.mark.parametrize("mode", ["open", "closed"])
@pytest.mark.parametrize("nested", [False, True], ids=["outer", "inner"])
def test_pen_pointer_in_shadow_tree(
session, get_test_page, pen_chain, mode, nested
):
session.url = get_test_page(
shadow_doc="""
<div id="pointer-target"
style="width: 10px; height: 10px; background-color:blue;">
</div>""",
shadow_root_mode=mode,
nested_shadow_dom=nested,
)
shadow_root = session.find.css("custom-element", all=False).shadow_root
if nested:
shadow_root = shadow_root.find_element(
"css selector", "inner-custom-element"
).shadow_root
target = shadow_root.find_element("css selector", "#pointer-target")
record_pointer_events(session, target)
pen_chain.pointer_move(0, 0, origin=target) \
.pointer_down() \
.pointer_up() \
.perform()
assert_pointer_events(
session,
expected_events=["pointerdown", "pointerup"],
target="pointer-target",
pointer_type="pen",
)
def test_pen_pointer_properties(session, test_actions_pointer_page, pen_chain):
pointerArea = session.find.css("#pointerArea", all=False)
center = get_inview_center(pointerArea.rect, get_viewport_rect(session))

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

@ -9,7 +9,6 @@ from tests.classic.perform_actions.support.mouse import (
)
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()
@ -34,41 +33,6 @@ def test_stale_element_reference(session, stale_element, touch_chain, as_frame):
touch_chain.click(element=element).perform()
@pytest.mark.parametrize("mode", ["open", "closed"])
@pytest.mark.parametrize("nested", [False, True], ids=["outer", "inner"])
def test_touch_pointer_in_shadow_tree(
session, get_test_page, touch_chain, mode, nested
):
session.url = get_test_page(
shadow_doc="""
<div id="pointer-target"
style="width: 10px; height: 10px; background-color:blue;">
</div>""",
shadow_root_mode=mode,
nested_shadow_dom=nested,
)
shadow_root = session.find.css("custom-element", all=False).shadow_root
if nested:
shadow_root = shadow_root.find_element(
"css selector", "inner-custom-element"
).shadow_root
target = shadow_root.find_element("css selector", "#pointer-target")
record_pointer_events(session, target)
touch_chain.pointer_move(0, 0, origin=target).pointer_down().pointer_up().perform()
assert_pointer_events(
session,
expected_events=["pointerdown", "pointerup"],
target="pointer-target",
pointer_type="touch",
)
def test_touch_pointer_properties(session, test_actions_pointer_page, touch_chain):
pointerArea = session.find.css("#pointerArea", all=False)
center = get_inview_center(pointerArea.rect, get_viewport_rect(session))

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

@ -64,56 +64,6 @@ def test_wheel_scroll_iframe(session, test_actions_scroll_page, wheel_chain):
assert events[0]["target"] == "iframeContent"
@pytest.mark.parametrize("mode", ["open", "closed"])
@pytest.mark.parametrize("nested", [False, True], ids=["outer", "inner"])
def test_wheel_scroll_shadow_tree(session, get_test_page, wheel_chain, mode, nested):
session.url = get_test_page(
shadow_doc="""
<div id="scrollableShadowTree"
style="width: 100px; height: 100px; overflow: auto;">
<div
id="scrollableShadowTreeContent"
style="width: 600px; height: 1000px; background-color:blue"></div>
</div>""",
shadow_root_mode=mode,
nested_shadow_dom=nested,
)
shadow_root = session.find.css("custom-element", all=False).shadow_root
if nested:
shadow_root = shadow_root.find_element(
"css selector", "inner-custom-element"
).shadow_root
scrollable = shadow_root.find_element("css selector", "#scrollableShadowTree")
# Add a simplified event recorder to track events in the test ShadowRoot.
session.execute_script(
"""
window.wheelEvents = [];
arguments[0].addEventListener("wheel",
function(event) {
window.wheelEvents.push({
"deltaX": event.deltaX,
"deltaY": event.deltaY,
"target": event.target.id
});
}
);
""",
args=(scrollable,),
)
wheel_chain.scroll(0, 0, 5, 10, origin=scrollable).perform()
events = session.execute_script("return window.wheelEvents;") or []
assert len(events) == 1
assert events[0]["deltaX"] >= 5
assert events[0]["deltaY"] >= 10
assert events[0]["target"] == "scrollableShadowTreeContent"
@pytest.mark.parametrize("missing", ["x", "y", "deltaX", "deltaY"])
def test_wheel_missing_prop(session, test_actions_scroll_page, wheel_chain, missing):
session.execute_script("document.scrollingElement.scrollTop = 0")