@@ -482,15 +482,15 @@ async def test_click_the_button_with_offset_with_page_scale(
482482
483483 await page .click ("button" , position = {"x" : 20 , "y" : 10 })
484484 assert await page .evaluate ("result" ) == "Clicked"
485- expected = { "x" : 28 , "y" : 18 }
486- if is_webkit :
487- # WebKit rounds up during css -> dip -> css conversion.
488- expected = { "x" : 26 , "y" : 17 }
489- elif is_chromium :
490- # Chromium rounds down during css -> dip -> css conversion.
491- expected = { "x" : 27 , "y" : 18 }
492- assert await page .evaluate ("pageX" ) == expected [ "x" ]
493- assert await page .evaluate ("pageY" ) == expected [ "y" ]
485+
486+ def _assert_close_to ( expected : int , actual : int ) -> None :
487+ if abs ( expected - actual ) > 2 :
488+ raise AssertionError ( f"Expected: { expected } , received: { actual } " )
489+
490+ # Expect 20;10 + 8px of border in each direction. Allow some delta as different
491+ # browsers round up or down differently during css -> dip -> css conversion.
492+ _assert_close_to ( 28 , await page .evaluate ("pageX" ))
493+ _assert_close_to ( 18 , await page .evaluate ("pageY" ))
494494 await context .close ()
495495
496496
@@ -676,7 +676,15 @@ async def click():
676676
677677async def test_wait_for_select_to_be_enabled (page , server ):
678678 await page .set_content (
679- '<select onclick="javascript:window.__CLICKED=true;" disabled><option selected>Hello</option></select>'
679+ """
680+ <select disabled><option selected>Hello</option></select>
681+ <script>
682+ document.querySelector('select').addEventListener('mousedown', event => {
683+ window.__CLICKED=true;
684+ event.preventDefault();
685+ });
686+ </script>
687+ """
680688 )
681689 done = []
682690
0 commit comments