@@ -405,6 +405,12 @@ void shouldClickAButtonInScrollingContainerWithOffset() {
405405 assertEquals (isWebKit () ? 1910 + 8 : 1910 , page .evaluate ("offsetY" ));
406406 }
407407
408+ private static void expectCloseTo (double expected , double actual ) {
409+ if (Math .abs (expected - actual ) > 2 )
410+ fail ("Expected: " + expected + ", received: " + actual );
411+ }
412+
413+
408414 @ Test
409415 @ DisabledIf (value ="com.microsoft.playwright.TestBase#isFirefox" , disabledReason ="skip" )
410416 void shouldClickTheButtonWithOffsetWithPageScale () {
@@ -419,28 +425,10 @@ void shouldClickTheButtonWithOffsetWithPageScale() {
419425 "}" );
420426 page .click ("button" , new Page .ClickOptions ().setPosition (20 , 10 ));
421427 assertEquals ("Clicked" , page .evaluate ("result" ));
422- // 20;10 + 8px of border in each direction
423- int expectedX = 28 ;
424- int expectedY = 18 ;
425-
426- if (isWebKit ()) {
427- // WebKit for macOS 12 has different expectations starting r1829.
428- if (isMac && Utils .osVersion () < 12 ) {
429- // WebKit rounds up during css -> dip -> css conversion.
430- expectedX = 26 ;
431- expectedY = 17 ;
432- } else {
433- expectedX = 29 ;
434- expectedY = 19 ;
435- }
436- } else if (isChromium () && !headful ) {
437- // Headless Chromium rounds down during css -> dip -> css conversion.
438- expectedX = 27 ;
439- expectedY = 18 ;
440- }
441-
442- assertEquals (expectedX , Math .round ((Integer ) page .evaluate ("pageX" ) + 0.01 ));
443- assertEquals (expectedY , Math .round ((Integer ) page .evaluate ("pageY" ) + 0.01 ));
428+ // Expect 20;10 + 8px of border in each direction. Allow some delta as different
429+ // browsers round up or down differently during css -> dip -> css conversion.
430+ expectCloseTo (28 , (Integer ) page .evaluate ("pageX" ));
431+ expectCloseTo (18 , (Integer ) page .evaluate ("pageY" ));
444432 context .close ();
445433 }
446434
0 commit comments