tests: the dropdown test waits for the trusted mouseup and click that the page gets after a release the parent handled alone
A release that the parent handles in chrome (the select dropdown is open) is answered without the content ack. On retail the page then gets a trusted mouseup and click on the select, dispatched by SelectChild after the parent's Forms:MouseUp, asynchronously. The pages of the stays-open test record both on the select, and the test waits for them in the page's own log with the deadline of the file (never assuming they arrived when the call returned), in the top document and in the frame of another site. What the tests already assert is unchanged. The negative control (popup hidden between the press and the release) does not wait for them.
This commit is contained in:
1 parent
66a682cfe6
commit
d7b0cb8638
1 file changed
+18
-3
@@ -9,6 +9,10 @@ the pointer moves to the centre of the select, the button goes down, the test wa
|
||||
a condition with a deadline), the button goes up, and the state is read over the next second (``observe``, the one bounded look of ``_window_origin``) and must have been ``open`` at every look and
|
||||
never anything else. Then the popup is closed from chrome and the wait is for ``closed``.
|
||||
|
||||
The page also sees the release. A release that the parent handles in chrome (the dropdown is open) is answered without waiting for the content process, and on retail the page then gets a trusted ``mouseup`` and
|
||||
``click`` on the ``<select>``, dispatched by ``SelectChild`` after the parent's ``Forms:MouseUp``, asynchronously. The pages record both on the select (``RECORD``), and the test WAITS for them as a page observes them
|
||||
(``wait_for`` on the page's own log, the deadline of the file): they are never assumed to have arrived by the time ``page.mouse.up()`` returned.
|
||||
|
||||
The negative control, per place: the same flow with a chrome ``hidePopup`` between the press and the release must read ``closed`` after the release, so the reader is shown to see a closed popup (a
|
||||
reader that answered ``open`` whatever the popup did would pass the first test for nothing).
|
||||
|
||||
@@ -38,6 +42,9 @@ pytestmark = pytest.mark.e2e
|
||||
CASE = "1920x1080-dpr1.0"
|
||||
#: How long the state is watched after the release.
|
||||
WATCH_S = 1.0
|
||||
#: What each page (the top document and the frame) records on its ``<select>``: the events of the release, as the page sees them, in the order they came, with whether they are trusted.
|
||||
RECORD = """<script>window.__log = [];
|
||||
for (const type of ['mouseup', 'click']) document.getElementById('s').addEventListener(type, e => window.__log.push([type, e.isTrusted]));</script>"""
|
||||
|
||||
|
||||
def _centre(name: str) -> Tuple[float, float]:
|
||||
@@ -54,8 +61,8 @@ def _page(firefox_binary: str, monkeypatch) -> Iterator[Tuple[Any, Chrome, Playw
|
||||
"""Our browser on ``CASE`` with the pages of the select twin served: ``(page, chrome, driver, sites)``, on the A page."""
|
||||
monkeypatch.setenv("MOZ_REMOTE_ALLOW_SYSTEM_ACCESS", "1") # the chrome-scope reads
|
||||
with Sites() as sites, launch_case(firefox_binary, CASE, extra_args=MARIONETTE_ARGS, extra_prefs={"marionette.port": 0}) as browser:
|
||||
sites.route("A", "/page", lambda handler: TOP % sites.url("B", "/select"))
|
||||
sites.route("B", "/select", FRAME)
|
||||
sites.route("A", "/page", lambda handler: TOP % sites.url("B", "/select") + RECORD)
|
||||
sites.route("B", "/select", FRAME + RECORD)
|
||||
page = browser.new_page() # first: the window the chrome session waits for
|
||||
chrome = Chrome(page)
|
||||
try:
|
||||
@@ -69,7 +76,7 @@ def _page(firefox_binary: str, monkeypatch) -> Iterator[Tuple[Any, Chrome, Playw
|
||||
def _flow(firefox_binary: str, monkeypatch, name: str, hide_between: bool) -> Dict[str, Any]:
|
||||
"""Press on the select, wait for ``open``, optionally hide the popup from chrome, release, and read the state for ``WATCH_S``. What was seen, step by step."""
|
||||
x, y = _centre(name)
|
||||
with _page(firefox_binary, monkeypatch) as (page, chrome, driver, _):
|
||||
with _page(firefox_binary, monkeypatch) as (page, chrome, driver, sites):
|
||||
page.mouse.move(x, y)
|
||||
page.mouse.down()
|
||||
opened = _wait_state(driver, "open")
|
||||
@@ -80,6 +87,12 @@ def _flow(firefox_binary: str, monkeypatch, name: str, hide_between: bool) -> Di
|
||||
page.mouse.up()
|
||||
looks: List[Any] = observe(page, lambda: _state(driver), WATCH_S)
|
||||
seen["after_release"] = looks
|
||||
if not hide_between:
|
||||
# The release was answered by the parent alone; the page's mouseup and click come later, from the content process, so they are waited for in the page's own log
|
||||
# (never assumed to be there when the call returned).
|
||||
document = page.main_frame if name == "top" else next(f for f in page.frames if f.url == sites.url("B", "/select"))
|
||||
seen["page_events_arrived"] = wait_for(page, lambda: len(document.evaluate("window.__log")) >= 2, DEADLINE_S)
|
||||
seen["page_events"] = [tuple(row) for row in document.evaluate("window.__log")]
|
||||
if looks[-1] == "open":
|
||||
chrome.script(CLOSE_JS)
|
||||
seen["after_close"] = _wait_state(driver, "closed")["state"]
|
||||
@@ -93,6 +106,8 @@ def test_a_dropdown_opened_by_a_press_stays_open_after_the_release(firefox_binar
|
||||
assert seen["after_release"] == ["open"], (
|
||||
"the dropdown of the %s document did not stay open after the button went up (every look over %s s must read open, in the order seen): %r" % (name, WATCH_S, seen))
|
||||
assert seen["after_close"] == "closed", "the popup did not close when chrome hid it: %r" % seen
|
||||
assert seen["page_events_arrived"] and seen["page_events"] == [("mouseup", True), ("click", True)], (
|
||||
"the page of the %s document did not see a trusted mouseup and click on the select after the release (waited %s s for both): %r" % (name, DEADLINE_S, seen))
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name", sorted(SELECTS))
|
||||
|
||||
Reference in new issue
Block a user