-
Notifications
You must be signed in to change notification settings - Fork 67
Description
- WPT repository issue:
webdriver/tests/bidi/browsing_context/print /margin.py:test_margin_same_as_page_dimensionimplementation is problematic with Chromium web-platform-tests/wpt#40870 - WPT repository PR: [wdspec] bidi: print: add tests for content area with less than 1x1 point web-platform-tests/wpt#40872
The test_margin_same_as_page_dimension test in webdriver/tests/bidi/browsing_context/print /margin.py in WPT currently emits a PDF and checks that it has empty content:
@pytest.mark.parametrize(
"margin",
[
{"top": 27.94},
{"left": 21.59},
{"right": 21.59},
{"bottom": 27.94},
{"top": 27.94, "left": 21.59, "right": 21.59, "bottom": 27.94},
],
ids=[
"top",
"left",
"right",
"bottom",
"all",
],
)
async def test_margin_same_as_page_dimension(
bidi_session,
top_context,
inline,
assert_pdf_content,
margin,
):
page = inline("Text")
await bidi_session.browsing_context.navigate(
context=top_context["context"], url=page, wait="complete"
)
print_value = await bidi_session.browsing_context.print(
context=top_context["context"],
shrink_to_fit=False,
margin=margin,
)
# Check that content is out of page dimensions.
await assert_pdf_content(print_value, [{"type": "string", "value": ""}])For context, this happens to works on Firefox, but it does not work on Chromium, but this is not the point (the spec should be browser agnostic). On Chromium, it throws webdriver.bidi.error.UnknownErrorException: unknown error (invalid print parameters: content area is empty), which is technically correct. Chromium cannot handle printing an empty content area.
Putting vendors aside, the purpose of this issue is to question the validity of printing a page in either of these scenarios, which all produce an empty content area:
widthis zeroheightis zero- left margin plus right margin is greater than or equal to
width(=effectively zero width) - top margin plus bottom margin is greater than or equal to
height(=effectively zero height)
My understanding is that currently the BiDi spec implicitly allows this condition (@whimboo seems to agree).
That said, with further investigation...
Hm, looks like that I may be wrong here. Searching for a 0-sized PDF it looks like that the minimum valid size for a PDF page is 1 point, which is equivalent to approximately 0.353 mm or 0.0139 inches. Sadly I cannot find any download which is free of charge. As such I would propose to file a BiDi spec issue first for further discussion.
A comment that I cannot verify:
In Section 14.11.2 of the PDF specification, it states that the width and height of a page in a PDF document shall be specified as positive numbers, and values of zero or less are considered invalid. This implies that a PDF page must have dimensions greater than zero.
Hereby my proposal is to amend https://w3c.github.io/webdriver-bidi/#command-browsingContext-print with the following change (exact wording TBD, not sure how to express this in the precise way the spec requires):
If the content area is effectively empty (by the means of an effective width or height equal to zero), send an error response with code invalid argument.
Then we could change the WPT test accordingly.
Thoughts?