diff --git a/webdriver/tests/bidi/script/__init__.py b/webdriver/tests/bidi/script/__init__.py index 901b412458b06a..5635a4bbfb0f02 100644 --- a/webdriver/tests/bidi/script/__init__.py +++ b/webdriver/tests/bidi/script/__init__.py @@ -68,7 +68,7 @@ def any_stack_frame(actual: Any) -> None: ("null", {"type": "null"}), ("'foobar'", {"type": "string", "value": "foobar"}), ("'2'", {"type": "string", "value": "2"}), - ("Number.NaN", {"type": "number", "value": "NaN"}), + ("NaN", {"type": "number", "value": "NaN"}), ("-0", {"type": "number", "value": "-0"}), ("Infinity", {"type": "number", "value": "Infinity"}), ("-Infinity", {"type": "number", "value": "-Infinity"}), diff --git a/webdriver/tests/bidi/script/call_function/arguments.py b/webdriver/tests/bidi/script/call_function/arguments.py index 32a4a6a2b8f22a..b1b188187ba8d5 100644 --- a/webdriver/tests/bidi/script/call_function/arguments.py +++ b/webdriver/tests/bidi/script/call_function/arguments.py @@ -23,7 +23,11 @@ async def test_default_arguments(bidi_session, top_context): async def test_primitive_value(bidi_session, top_context, argument, expected): result = await bidi_session.script.call_function( function_declaration=f"""(arg) => {{ - if (arg !== {expected}) {{ + if (typeof {expected} === "number" && isNaN({expected})) {{ + if (!isNaN(arg)) {{ + throw new Error(`Argument should be {expected}, but was ` + arg); + }} + }} else if (arg !== {expected}) {{ throw new Error(`Argument should be {expected}, but was ` + arg); }} return arg; @@ -36,24 +40,6 @@ async def test_primitive_value(bidi_session, top_context, argument, expected): recursive_compare(argument, result) -@pytest.mark.asyncio -async def test_primitive_value_NaN(bidi_session, top_context): - nan_remote_value = {"type": "number", "value": "NaN"} - result = await bidi_session.script.call_function( - function_declaration="""(arg) => { - if (!isNaN(arg)) { - throw new Error("Argument should be 'NaN', but was " + arg); - } - return arg; - }""", - arguments=[nan_remote_value], - await_promise=False, - target=ContextTarget(top_context["context"]), - ) - - recursive_compare(nan_remote_value, result) - - @pytest.mark.asyncio @pytest.mark.parametrize( "argument, expected_type",