[wpt-sync] Sync PR 50724 - Make generated canvas test parameters importable as Jinja templates
Categories
(Core :: Graphics: Canvas2D, task, P4)
Tracking
()
Tracking | Status | |
---|---|---|
firefox137 | --- | fixed |
People
(Reporter: wpt-sync, Unassigned)
References
()
Details
(Whiteboard: [wptsync downstream])
Sync web-platform-tests PR 50724 into mozilla-central (this bug is closed when the sync is complete).
PR: https://github.com/web-platform-tests/wpt/pull/50724
Details from upstream follow.
Jean-Philippe Gravel <jpgravel@chromium.org> wrote:
Make generated canvas test parameters importable as Jinja templates
In the Canvas WPT test generator, the test body can have Jinja tags
referring to other test parameters. For instance:
code: |
@assert pixel 50,25 == {{ expected_color }};
expected_color: 'rgba(0, 255, 0, {{ alpha }})'
alpha: 1.0Here, the
expected_color
parameter is first rendered, expanding the
{{ alpha }}
tag. This result is then inserted into thecode
template. This is useful to reuse values in multiple places. It however
doesn't allow reusing Jinja macros. Indeed, ifexpected_color
contained a{% macro ... %}
tag, that tag would get lost as the
expected_color
gets rendered (the macro itself is not part of the
rendering result).To be able to reuse macros, we would need to use an
{% import ... %}
tag. This CL makes this possible by registering the test parameters as
templates loadable by the Jinja environment. Thus, the following
becomes possible:macros: |
{% macro calculate_color(...) %}
...
{% endmacro %}
code: |
{% import 'macros' as m %}
@assert pixel 50,25 == {{ m.calculate_color(...) }};
expected: |
{% import 'macros' as m %}
size 100 50
cr.set_source_rgba({{ m.calculate_color(...) }})Bug: 40207206
Change-Id: Idff8495efffbcde1840256b5ac5bded1d7e6de55
Reviewed-on: https://chromium-review.googlesource.com/6204442
WPT-Export-Revision: c0c810564fa7336f19edf7d4825e310f6dee5676
Assignee | ||
Updated•10 days ago
|
Assignee | ||
Comment 1•10 days ago
|
||
Assignee | ||
Comment 3•6 days ago
|
||
Description
•