diff --git a/playwright/src/main/java/com/microsoft/playwright/impl/Serialization.java b/playwright/src/main/java/com/microsoft/playwright/impl/Serialization.java index f5b44c96c..d32a034b6 100644 --- a/playwright/src/main/java/com/microsoft/playwright/impl/Serialization.java +++ b/playwright/src/main/java/com/microsoft/playwright/impl/Serialization.java @@ -152,7 +152,7 @@ private SerializedValue serializeValue(Object value) { result.v = "Infinity"; } else if (d == Double.NEGATIVE_INFINITY) { result.v = "-Infinity"; - } else if (d == -0) { + } else if (Double.compare(d, -0.0) == 0) { result.v = "-0"; } else if (Double.isNaN(d)) { result.v = "NaN"; diff --git a/playwright/src/test/java/com/microsoft/playwright/TestPageEvaluate.java b/playwright/src/test/java/com/microsoft/playwright/TestPageEvaluate.java index 01d49bc22..d7a9f2016 100644 --- a/playwright/src/test/java/com/microsoft/playwright/TestPageEvaluate.java +++ b/playwright/src/test/java/com/microsoft/playwright/TestPageEvaluate.java @@ -52,6 +52,13 @@ void shouldTransfer0() { assertEquals(Double.NEGATIVE_INFINITY, 1 / (Double) result); } + @Test + void shouldTransferPositive0() { + assertEquals(true, page.evaluate("a => Object.is(a, 0)", 0.0)); + Object result = page.evaluate("a => a", 0.0); + assertEquals(Double.POSITIVE_INFINITY, 1 / ((Number) result).doubleValue()); + } + @Test void shouldTransferInfinity() { Object result = page.evaluate("a => a", Double.POSITIVE_INFINITY);