Debian Codegraph @

testing/web-platform/mozilla/tests/webdriver/classic/perform_actions/pointer_mouse.py

raw
1 import pytest
2
3 pytestmark = pytest.mark.asyncio
4
5
6 async def test_click_in_display_none_frame(session, inline):
7 frame_url = inline(
8 """
9 <button>click to hide</button>
10 <script type="text/javascript">
11 const btn = document.querySelector('button');
12 btn.addEventListener('click', ev => {
13 window.parent.postMessage("test");
14 });
15 </script>
16 """
17 )
18
19 url = inline(
20 f"""
21 <div id="content">
22 <iframe src='{frame_url}'></iframe>
23 </div>
24 <script>
25 window.addEventListener("message", ev => {{
26 document.querySelector("iframe").style.display = "none";
27 }}, false);
28 </script>
29 """
30 )
31
32 session.url = url
33
34 frame = session.find.css("iframe", all=False)
35 session.switch_frame(frame)
36 button = session.find.css("button", all=False)
37
38 mouse_chain = session.actions.sequence(
39 "pointer", "pointer_id", {"pointerType": "mouse"}
40 )
41
42 # Firefox bug:
43 # - the click will hide the iframe via display none
44 # - the last bit of performActions tries to wait for animationFrame in the
45 # iframe browsing context, but since it's hidden there won't be any and
46 # we never resolve
47 # Note that the pause(100) is not strictly necessary to reproduce the issue
48 # but it makes it fail consistently. Otherwise it's very much intermittent.
49 mouse_chain.pointer_move(0, 0, origin=button).pointer_down().pointer_up().pause(
50 100
51 ).perform()