From d273bac4226053785f7f96c25a4bffe726f5d52a Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Tue, 17 Dec 2024 15:31:58 +0000 Subject: [PATCH] [wdspec] Add tests for invalid types and values for the "format" argument in the "browsingContext.captureScreenshot" command. Differential Revision: https://phabricator.services.mozilla.com/D229441 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1861737 gecko-commit: 34c0ad83ab4ed8e868c90aa8d0bacea8fffe1c39 gecko-reviewers: whimboo, webdriver-reviewers --- .../capture_screenshot/invalid.py | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/webdriver/tests/bidi/browsing_context/capture_screenshot/invalid.py b/webdriver/tests/bidi/browsing_context/capture_screenshot/invalid.py index 6fef42a48f0152..2e466c645c3d8a 100644 --- a/webdriver/tests/bidi/browsing_context/capture_screenshot/invalid.py +++ b/webdriver/tests/bidi/browsing_context/capture_screenshot/invalid.py @@ -142,8 +142,42 @@ async def test_params_origin_invalid_value(bidi_session, top_context): ) +@pytest.mark.parametrize("value", [True, 42, "foo", []]) +async def test_params_format_invalid_type(bidi_session, top_context, value): + with pytest.raises(error.InvalidArgumentException): + await bidi_session.browsing_context.capture_screenshot( + context=top_context["context"], format=value + ) + + async def test_params_format_invalid_value(bidi_session, top_context): with pytest.raises(error.InvalidArgumentException): await bidi_session.browsing_context.capture_screenshot( - context=top_context["context"], format=FormatOptions(type="image/invalid") + context=top_context["context"], format={} + ) + + +@pytest.mark.parametrize("value", [None, True, 42, [], {}]) +async def test_params_format_type_invalid_type(bidi_session, top_context, value): + with pytest.raises(error.InvalidArgumentException): + await bidi_session.browsing_context.capture_screenshot( + context=top_context["context"], format=FormatOptions(type=value) + ) + + +@pytest.mark.parametrize("value", [True, "foo", [], {}]) +async def test_params_format_quality_invalid_type(bidi_session, top_context, value): + with pytest.raises(error.InvalidArgumentException): + await bidi_session.browsing_context.capture_screenshot( + context=top_context["context"], format=FormatOptions( + type="image/jpeg", quality=value) + ) + + +@pytest.mark.parametrize("value", [-0.1, 1.1]) +async def test_params_format_quality_invalid_value(bidi_session, top_context, value): + with pytest.raises(error.InvalidArgumentException): + await bidi_session.browsing_context.capture_screenshot( + context=top_context["context"], format=FormatOptions( + type="image/jpeg", quality=value) )