|
51 | 51 | function selectText(ev) { |
52 | 52 | // Selection API must run inside a real user-gesture handler so that |
53 | 53 | // CEF fires OnTextSelectionChanged (Chrome 130+ requirement). |
54 | | - var el = ev.target; |
| 54 | + // Always target the h1 directly so any click on the page works. |
| 55 | + var el = document.querySelector('h1'); |
55 | 56 | var range = document.createRange(); |
56 | 57 | range.selectNodeContents(el); |
57 | 58 | var sel = window.getSelection(); |
|
64 | 65 | } |
65 | 66 | </script> |
66 | 67 | </head> |
67 | | -<body> |
| 68 | +<body onclick="selectText(event)"> |
68 | 69 | <!-- FrameSourceVisitor hash = 747ef3e6011b6a61e6b3c6e54bdd2dee --> |
69 | | - <h1 onclick="selectText(event)">Off-screen rendering test</h1> |
| 70 | + <h1>Off-screen rendering test</h1> |
70 | 71 | <div id="console"></div> |
71 | 72 | <div id="OnTextSelectionChanged">Test selection.</div> |
72 | 73 | </body> |
@@ -265,17 +266,17 @@ def _OnAccessibilityLocationChange(self, **_): |
265 | 266 |
|
266 | 267 |
|
267 | 268 | def _click_h1_to_select(browser): |
268 | | - """Send a real click to the h1 element after layout is complete. |
| 269 | + """Send a real click anywhere in the viewport after layout is complete. |
269 | 270 |
|
270 | 271 | Chrome 130+ requires the Selection API to run inside a real user-gesture |
271 | | - event handler for OnTextSelectionChanged to fire. The h1 has an onclick |
272 | | - handler (selectText) that selects the element's text via the Selection API. |
273 | | - h1 position: body margin 8px + h1 margin-block-start ~20px ≈ y=28 top, |
274 | | - h1 font-size ~29px ≈ y=57px bottom; click center at y=43. |
| 272 | + event handler for OnTextSelectionChanged to fire. The body has an onclick |
| 273 | + handler (selectText) that selects the h1 text via the Selection API. |
| 274 | + Click at the center of the 800x600 viewport — guaranteed to land on the |
| 275 | + body regardless of font metrics or CI rendering differences. |
275 | 276 | """ |
276 | | - browser.SendMouseClickEvent(200, 43, cef.MOUSEBUTTON_LEFT, |
| 277 | + browser.SendMouseClickEvent(400, 300, cef.MOUSEBUTTON_LEFT, |
277 | 278 | mouseUp=False, clickCount=1) |
278 | | - browser.SendMouseClickEvent(200, 43, cef.MOUSEBUTTON_LEFT, |
| 279 | + browser.SendMouseClickEvent(400, 300, cef.MOUSEBUTTON_LEFT, |
279 | 280 | mouseUp=True, clickCount=1) |
280 | 281 | browser.Invalidate(cef.PET_VIEW) |
281 | 282 | subtest_message("_click_h1_to_select() ok") |
|
0 commit comments