Skip to content

Commit

Permalink
[wdspec] Add tests for invalid types and values for the "format" argu…
Browse files Browse the repository at this point in the history
…ment 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
  • Loading branch information
liamdebeasi authored and moz-wptsync-bot committed Dec 17, 2024
1 parent 7089d29 commit d273bac
Showing 1 changed file with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)

0 comments on commit d273bac

Please sign in to comment.