@@ -482,15 +482,15 @@ async def test_click_the_button_with_offset_with_page_scale(
482
482
483
483
await page .click ("button" , position = {"x" : 20 , "y" : 10 })
484
484
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" ))
494
494
await context .close ()
495
495
496
496
@@ -676,7 +676,15 @@ async def click():
676
676
677
677
async def test_wait_for_select_to_be_enabled (page , server ):
678
678
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
+ """
680
688
)
681
689
done = []
682
690
0 commit comments