Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testlib: using b.mouse(..., ctrlKey=True) keeps the ctrl modifier active #21187

Open
tomasmatus opened this issue Oct 29, 2024 · 4 comments
Open
Labels

Comments

@tomasmatus
Copy link
Member

tomasmatus commented Oct 29, 2024

Explain what happens

When using b.mouse() with ctrl key modifier in Firefox the modifier is kept active for all future b.mouse() calls.

I am not sure if this is a bug in testlib or something in firefox bidi driver.

Relevant testing farm failure:
https://artifacts.dev.testing-farm.io/650d6b68-b518-414e-9ff2-d2b8f8d73939/

Relevant part of testNavigation:
First in the test ctrl modifier is used

        m.execute("touch /home/admin/newfile.txt")
        b.mouse("[data-item='newfile.txt']", "click", ctrlKey=True)
        b.wait_in_text(".files-footer-info", "2 files selected")
        b.mouse("[data-item='tmplink']", "click", ctrlKey=True)
        b.wait_in_text(".files-footer-info", "3 files selected")

and then later on in the test there is another use of b.mouse this time with ctrlKey=False (default). Testingfarm log shows the test fails here.

        # Navigating resets the current search filter
        b.set_input_text("input[placeholder='Filter directory']", "sys")
        self.browser.wait_js_cond("ph_count('#folder-view tbody tr') == 1")

        b.mouse("[data-item='sys']", "dblclick")
        self.assert_last_breadcrumb("sys")

problem also persists when explicitly setting it to false in the function call.

The bidi input action looks good to me.

INFO:bidi.command:← input.performActions({'context': '10737418243', 'actions': [{'id': 'pointer-390', 'type': 'pointer', 'parameters': {'pointerType': 'mouse'}, 'actions': [{'type': 'pointerMove', 'x': 0, 'y': 0, 'origin': {'type': 'element', 'element': {'type': 'node', 'sharedId': '603c86a6-fd58-448e-a526-157f182de9e6', 'value': {'nodeType': 1, 'localName': 'tr', 'namespaceURI': 'http://www.w3.org/1999/xhtml', 'childNodeCount': 5, 'attributes': {'class': 'pf-v5-c-table__tr folder', 'data-ouia-component-type': 'PF5/TableRow', 'data-ouia-safe': 'true', 'data-ouia-component-id': 'OUIA-Generated-TableRow-2', 'data-item': 'sys'}, 'shadowRoot': None}}}}, {'type': 'pointerDown', 'button': 0}, {'type': 'pointerUp', 'button': 0}, {'type': 'pointerDown', 'button': 0}, {'type': 'pointerUp', 'button': 0}]}]}) [id 390]

Version of Cockpit

327

Where is the problem in Cockpit?

None

Server operating system

None

Server operating system version

No response

What browsers are you using?

Firefox

System log

No response

@tomasmatus tomasmatus added the bug label Oct 29, 2024
@martinpitt
Copy link
Member

Can you reproduce this locally? If so, can you please paste a full run with --trace? I just checked def mouse(), and

        if ctrlKey:
            keys_pre.append(key("keyDown", "Control"))
            keys_post.append(key("keyUp", "Control"))

seems correct to me, I don't see typos. In the log I'd like to see that the "keyUp Control" is actually ran. If so, then it rather smells like a firefox bug. Do you know, is that only Control, or also affects Alt/Shift/Meta?

@jelly
Copy link
Member

jelly commented Oct 30, 2024

@martinpitt martinpitt added the question Further information is requested label Jan 8, 2025
@tomasmatus
Copy link
Member Author

Ok, this still happens. Running the following code in a test which selects 3 files. Then it single clicks on fourth file. What should happen is that the 3 selected files get deselected and this now clicked on file is selected (and the only selected one).
What instead happens is that all 4 files are selected.

        testlib.sit()

        # Select multiple files
        m.execute("touch /home/admin/newfile.txt /home/admin/morenewfile.txt")
        b.click("[data-item='newdir']")
        b.mouse("[data-item='newfile.txt']", "click", ctrlKey=True)
        b.wait_in_text(".files-footer-info", "2 files selected")
        b.mouse("[data-item='tmplink']", "click", ctrlKey=True)
        b.wait_in_text(".files-footer-info", "3 files selected")

        testlib.sit()

        b.mouse("[data-item='morenewfile.txt']", "click", ctrlKey=False)

        testlib.sit()

Looking at the events fired by clicking I can see that first click correctly has ctrlKey: false, second and third event correctly has ctrlKey: true. However they last event still has ctrlKey: true even though the mouse call explicitly sets it to False.

Here is the relevant part of trace which to me looks correct. First and last click doesn't have any modifiers, second and third does. So indeed it seems to be correct on our side and likely is a bug on the firefox side?

The modifier part is: 'actions': [{'type': 'keyDown', 'value': '\ue009'}]}
and the full trace:

Press RET to continue...

+ touch /home/admin/newfile.txt /home/admin/morenewfile.txt
INFO:bidi.command:← script.evaluate({'expression': 'ph_wait_cond(() => ph_is_present("[data-item=\'newdir\']:not([disabled]):not([aria-disabled=true])"), 15000, null)', 'awaitPromise': True, 'target': {'context': '12884901891'}}) [id 290]
INFO:bidi.command:→ {'realm': '934321c1-f1c0-4795-a819-8008fc5ff888', 'type': 'success', 'result': None}
INFO:bidi.command:← script.evaluate({'expression': 'ph_wait_cond(() => ph_is_visible("[data-item=\'newdir\']:not([disabled]):not([aria-disabled=true])"), 15000, null)', 'awaitPromise': True, 'target': {'context': '12884901891'}}) [id 291]
INFO:bidi.command:→ {'realm': '934321c1-f1c0-4795-a819-8008fc5ff888', 'type': 'success', 'result': None}
INFO:bidi.command:← script.evaluate({'expression': 'ph_find_scroll_into_view("[data-item=\'newdir\']:not([disabled]):not([aria-disabled=true])")', 'awaitPromise': True, 'target': {'context': '12884901891'}}) [id 292]
INFO:bidi.command:→ {'realm': '934321c1-f1c0-4795-a819-8008fc5ff888', 'type': 'success', 'result': {'type': 'node', 'sharedId': '1a2d6a23-65c3-457d-a88e-7929620cd1a9', 'value': {'nodeType': 1, 'localName': 'tr', 'namespaceURI': 'http://www.w3.org/1999/xhtml', 'childNodeCount': 5, 'attributes': {'class': 'pf-v5-c-table__tr folder', 'data-ouia-component-type': 'PF5/TableRow', 'data-ouia-safe': 'true', 'data-ouia-component-id': 'OUIA-Generated-TableRow-24', 'data-item': 'newdir'}, 'shadowRoot': None}}}
INFO:bidi.command:← input.performActions({'context': '12884901891', 'actions': [{'id': 'pointer-293', 'type': 'pointer', 'parameters': {'pointerType': 'mouse'}, 'actions': [{'type': 'pointerMove', 'x': 0, 'y': 0, 'origin': {'type': 'element', 'element': {'type': 'node', 'sharedId': '1a2d6a23-65c3-457d-a88e-7929620cd1a9', 'value': {'nodeType': 1, 'localName': 'tr', 'namespaceURI': 'http://www.w3.org/1999/xhtml', 'childNodeCount': 5, 'attributes': {'class': 'pf-v5-c-table__tr folder', 'data-ouia-component-type': 'PF5/TableRow', 'data-ouia-safe': 'true', 'data-ouia-component-id': 'OUIA-Generated-TableRow-24', 'data-item': 'newdir'}, 'shadowRoot': None}}}}, {'type': 'pointerDown', 'button': 0}, {'type': 'pointerUp', 'button': 0}]}]}) [id 293]
> info: [object PointerEvent]
INFO:bidi.command:→ {}
INFO:bidi.command:← script.evaluate({'expression': 'ph_wait_cond(() => ph_is_present("[data-item=\'newfile.txt\']"), 15000, null)', 'awaitPromise': True, 'target': {'context': '12884901891'}}) [id 294]
INFO:bidi.command:→ {'realm': '934321c1-f1c0-4795-a819-8008fc5ff888', 'type': 'success', 'result': None}
INFO:bidi.command:← script.evaluate({'expression': 'ph_wait_cond(() => ph_is_visible("[data-item=\'newfile.txt\']"), 15000, null)', 'awaitPromise': True, 'target': {'context': '12884901891'}}) [id 295]
INFO:bidi.command:→ {'realm': '934321c1-f1c0-4795-a819-8008fc5ff888', 'type': 'success', 'result': None}
INFO:bidi.command:← script.evaluate({'expression': 'ph_find_scroll_into_view("[data-item=\'newfile.txt\']")', 'awaitPromise': True, 'target': {'context': '12884901891'}}) [id 296]
INFO:bidi.command:→ {'realm': '934321c1-f1c0-4795-a819-8008fc5ff888', 'type': 'success', 'result': {'type': 'node', 'sharedId': '0730a794-fba1-4eac-841d-a794562dd01c', 'value': {'nodeType': 1, 'localName': 'tr', 'namespaceURI': 'http://www.w3.org/1999/xhtml', 'childNodeCount': 5, 'attributes': {'class': 'pf-v5-c-table__tr text-file', 'data-ouia-component-type': 'PF5/TableRow', 'data-ouia-safe': 'true', 'data-ouia-component-id': 'OUIA-Generated-TableRow-4', 'data-item': 'newfile.txt'}, 'shadowRoot': None}}}
INFO:bidi.command:← input.performActions({'context': '12884901891', 'actions': [{'type': 'key', 'id': 'pointer-297keyDown', 'actions': [{'type': 'keyDown', 'value': '\ue009'}]}, {'id': 'pointer-297', 'type': 'pointer', 'parameters': {'pointerType': 'mouse'}, 'actions': [{'type': 'pointerMove', 'x': 0, 'y': 0, 'origin': {'type': 'element', 'element': {'type': 'node', 'sharedId': '0730a794-fba1-4eac-841d-a794562dd01c', 'value': {'nodeType': 1, 'localName': 'tr', 'namespaceURI': 'http://www.w3.org/1999/xhtml', 'childNodeCount': 5, 'attributes': {'class': 'pf-v5-c-table__tr text-file', 'data-ouia-component-type': 'PF5/TableRow', 'data-ouia-safe': 'true', 'data-ouia-component-id': 'OUIA-Generated-TableRow-4', 'data-item': 'newfile.txt'}, 'shadowRoot': None}}}}, {'type': 'pointerDown', 'button': 0}, {'type': 'pointerUp', 'button': 0}]}, {'type': 'key', 'id': 'pointer-297keyUp', 'actions': [{'type': 'keyUp', 'value': '\ue009'}]}]}) [id 297]
> info: [object PointerEvent]
INFO:bidi.command:→ {}
INFO:bidi.command:← script.evaluate({'expression': 'ph_wait_cond(() => ph_is_present(".files-footer-info"), 15000, null)', 'awaitPromise': True, 'target': {'context': '12884901891'}}) [id 298]
INFO:bidi.command:→ {'realm': '934321c1-f1c0-4795-a819-8008fc5ff888', 'type': 'success', 'result': None}
INFO:bidi.command:← script.evaluate({'expression': 'ph_wait_cond(() => ph_is_visible(".files-footer-info"), 15000, null)', 'awaitPromise': True, 'target': {'context': '12884901891'}}) [id 299]
INFO:bidi.command:→ {'realm': '934321c1-f1c0-4795-a819-8008fc5ff888', 'type': 'success', 'result': None}
INFO:bidi.command:← script.evaluate({'expression': 'ph_wait_cond(() => ph_in_text(".files-footer-info","2 files selected"), 15000, () => \'actual text: \' + ph_text(".files-footer-info"))', 'awaitPromise': True, 'target': {'context': '12884901891'}}) [id 300]
INFO:bidi.command:→ {'realm': '934321c1-f1c0-4795-a819-8008fc5ff888', 'type': 'success', 'result': None}
INFO:bidi.command:← script.evaluate({'expression': 'ph_wait_cond(() => ph_is_present("[data-item=\'tmplink\']"), 15000, null)', 'awaitPromise': True, 'target': {'context': '12884901891'}}) [id 301]
INFO:bidi.command:→ {'realm': '934321c1-f1c0-4795-a819-8008fc5ff888', 'type': 'success', 'result': None}
INFO:bidi.command:← script.evaluate({'expression': 'ph_wait_cond(() => ph_is_visible("[data-item=\'tmplink\']"), 15000, null)', 'awaitPromise': True, 'target': {'context': '12884901891'}}) [id 302]
INFO:bidi.command:→ {'realm': '934321c1-f1c0-4795-a819-8008fc5ff888', 'type': 'success', 'result': None}
INFO:bidi.command:← script.evaluate({'expression': 'ph_find_scroll_into_view("[data-item=\'tmplink\']")', 'awaitPromise': True, 'target': {'context': '12884901891'}}) [id 303]
INFO:bidi.command:→ {'realm': '934321c1-f1c0-4795-a819-8008fc5ff888', 'type': 'success', 'result': {'type': 'node', 'sharedId': 'fddf105a-86d0-48a8-8df0-3cc262902a5c', 'value': {'nodeType': 1, 'localName': 'tr', 'namespaceURI': 'http://www.w3.org/1999/xhtml', 'childNodeCount': 5, 'attributes': {'class': 'pf-v5-c-table__tr folder symlink', 'data-ouia-component-type': 'PF5/TableRow', 'data-ouia-safe': 'true', 'data-ouia-component-id': 'OUIA-Generated-TableRow-25', 'data-item': 'tmplink'}, 'shadowRoot': None}}}
INFO:bidi.command:← input.performActions({'context': '12884901891', 'actions': [{'type': 'key', 'id': 'pointer-304keyDown', 'actions': [{'type': 'keyDown', 'value': '\ue009'}]}, {'id': 'pointer-304', 'type': 'pointer', 'parameters': {'pointerType': 'mouse'}, 'actions': [{'type': 'pointerMove', 'x': 0, 'y': 0, 'origin': {'type': 'element', 'element': {'type': 'node', 'sharedId': 'fddf105a-86d0-48a8-8df0-3cc262902a5c', 'value': {'nodeType': 1, 'localName': 'tr', 'namespaceURI': 'http://www.w3.org/1999/xhtml', 'childNodeCount': 5, 'attributes': {'class': 'pf-v5-c-table__tr folder symlink', 'data-ouia-component-type': 'PF5/TableRow', 'data-ouia-safe': 'true', 'data-ouia-component-id': 'OUIA-Generated-TableRow-25', 'data-item': 'tmplink'}, 'shadowRoot': None}}}}, {'type': 'pointerDown', 'button': 0}, {'type': 'pointerUp', 'button': 0}]}, {'type': 'key', 'id': 'pointer-304keyUp', 'actions': [{'type': 'keyUp', 'value': '\ue009'}]}]}) [id 304]
> info: [object PointerEvent]
INFO:bidi.command:→ {}
INFO:bidi.command:← script.evaluate({'expression': 'ph_wait_cond(() => ph_is_present(".files-footer-info"), 15000, null)', 'awaitPromise': True, 'target': {'context': '12884901891'}}) [id 305]
INFO:bidi.command:→ {'realm': '934321c1-f1c0-4795-a819-8008fc5ff888', 'type': 'success', 'result': None}
INFO:bidi.command:← script.evaluate({'expression': 'ph_wait_cond(() => ph_is_visible(".files-footer-info"), 15000, null)', 'awaitPromise': True, 'target': {'context': '12884901891'}}) [id 306]
INFO:bidi.command:→ {'realm': '934321c1-f1c0-4795-a819-8008fc5ff888', 'type': 'success', 'result': None}
INFO:bidi.command:← script.evaluate({'expression': 'ph_wait_cond(() => ph_in_text(".files-footer-info","3 files selected"), 15000, () => \'actual text: \' + ph_text(".files-footer-info"))', 'awaitPromise': True, 'target': {'context': '12884901891'}}) [id 307]
INFO:bidi.command:→ {'realm': '934321c1-f1c0-4795-a819-8008fc5ff888', 'type': 'success', 'result': None}
Press RET to continue...

INFO:bidi.command:← script.evaluate({'expression': 'ph_wait_cond(() => ph_is_present("[data-item=\'morenewfile.txt\']"), 15000, null)', 'awaitPromise': True, 'target': {'context': '12884901891'}}) [id 308]
INFO:bidi.command:→ {'realm': '934321c1-f1c0-4795-a819-8008fc5ff888', 'type': 'success', 'result': None}
INFO:bidi.command:← script.evaluate({'expression': 'ph_wait_cond(() => ph_is_visible("[data-item=\'morenewfile.txt\']"), 15000, null)', 'awaitPromise': True, 'target': {'context': '12884901891'}}) [id 309]
INFO:bidi.command:→ {'realm': '934321c1-f1c0-4795-a819-8008fc5ff888', 'type': 'success', 'result': None}
INFO:bidi.command:← script.evaluate({'expression': 'ph_find_scroll_into_view("[data-item=\'morenewfile.txt\']")', 'awaitPromise': True, 'target': {'context': '12884901891'}}) [id 310]
INFO:bidi.command:→ {'realm': '934321c1-f1c0-4795-a819-8008fc5ff888', 'type': 'success', 'result': {'type': 'node', 'sharedId': '8a390a3c-00bc-4904-ba5a-a0996326d845', 'value': {'nodeType': 1, 'localName': 'tr', 'namespaceURI': 'http://www.w3.org/1999/xhtml', 'childNodeCount': 5, 'attributes': {'class': 'pf-v5-c-table__tr text-file', 'data-ouia-component-type': 'PF5/TableRow', 'data-ouia-safe': 'true', 'data-ouia-component-id': 'OUIA-Generated-TableRow-3', 'data-item': 'morenewfile.txt'}, 'shadowRoot': None}}}
INFO:bidi.command:← input.performActions({'context': '12884901891', 'actions': [{'id': 'pointer-311', 'type': 'pointer', 'parameters': {'pointerType': 'mouse'}, 'actions': [{'type': 'pointerMove', 'x': 0, 'y': 0, 'origin': {'type': 'element', 'element': {'type': 'node', 'sharedId': '8a390a3c-00bc-4904-ba5a-a0996326d845', 'value': {'nodeType': 1, 'localName': 'tr', 'namespaceURI': 'http://www.w3.org/1999/xhtml', 'childNodeCount': 5, 'attributes': {'class': 'pf-v5-c-table__tr text-file', 'data-ouia-component-type': 'PF5/TableRow', 'data-ouia-safe': 'true', 'data-ouia-component-id': 'OUIA-Generated-TableRow-3', 'data-item': 'morenewfile.txt'}, 'shadowRoot': None}}}}, {'type': 'pointerDown', 'button': 0}, {'type': 'pointerUp', 'button': 0}]}]}) [id 311]
> info: [object PointerEvent]
INFO:bidi.command:→ {}
Press RET to continue...

@tomasmatus
Copy link
Member Author

tomasmatus commented Jan 15, 2025

and running the same code (without wait_in_text checks) with shift/alt/meta modifiers shows the same behavior

@martinpitt martinpitt removed the question Further information is requested label Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants