diff --git a/Libraries/LibWeb/HTML/OffscreenCanvasRenderingContext2D.cpp b/Libraries/LibWeb/HTML/OffscreenCanvasRenderingContext2D.cpp index 43443e10680..007b5b811e7 100644 --- a/Libraries/LibWeb/HTML/OffscreenCanvasRenderingContext2D.cpp +++ b/Libraries/LibWeb/HTML/OffscreenCanvasRenderingContext2D.cpp @@ -232,10 +232,15 @@ float OffscreenCanvasRenderingContext2D::shadow_offset_x() const return drawing_state().shadow_offset_x; } -void OffscreenCanvasRenderingContext2D::set_shadow_offset_x(float offsetX) +// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-shadowoffsetx +void OffscreenCanvasRenderingContext2D::set_shadow_offset_x(float offset_x) { - // https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-shadowoffsetx - drawing_state().shadow_offset_x = offsetX; + // On setting, the attribute being set must be set to the new value, except if the value is infinite or NaN, + // in which case the new value must be ignored. + if (isinf(offset_x) || isnan(offset_x)) + return; + + drawing_state().shadow_offset_x = offset_x; } float OffscreenCanvasRenderingContext2D::shadow_offset_y() const @@ -243,10 +248,15 @@ float OffscreenCanvasRenderingContext2D::shadow_offset_y() const return drawing_state().shadow_offset_y; } -void OffscreenCanvasRenderingContext2D::set_shadow_offset_y(float offsetY) +// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-shadowoffsety +void OffscreenCanvasRenderingContext2D::set_shadow_offset_y(float offset_y) { - // https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-shadowoffsety - drawing_state().shadow_offset_y = offsetY; + // On setting, the attribute being set must be set to the new value, except if the value is infinite or NaN, + // in which case the new value must be ignored. + if (isinf(offset_y) || isnan(offset_y)) + return; + + drawing_state().shadow_offset_y = offset_y; } float OffscreenCanvasRenderingContext2D::shadow_blur() const diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.attributes.shadowOffset.invalid.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.attributes.shadowOffset.invalid.txt new file mode 100644 index 00000000000..b2ad0168e39 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.attributes.shadowOffset.invalid.txt @@ -0,0 +1,6 @@ +Harness status: OK + +Found 1 tests + +1 Pass +Pass OffscreenCanvas test: 2d.shadow.attributes.shadowOffset.invalid \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.attributes.shadowOffset.valid.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.attributes.shadowOffset.valid.txt new file mode 100644 index 00000000000..eb96b4db2b6 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.attributes.shadowOffset.valid.txt @@ -0,0 +1,6 @@ +Harness status: OK + +Found 1 tests + +1 Pass +Pass OffscreenCanvas test: 2d.shadow.attributes.shadowOffset.valid \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/shadows/2d.shadow.attributes.shadowOffset.invalid.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/shadows/2d.shadow.attributes.shadowOffset.invalid.html new file mode 100644 index 00000000000..303850633d2 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/shadows/2d.shadow.attributes.shadowOffset.invalid.html @@ -0,0 +1,68 @@ + + + +OffscreenCanvas test: 2d.shadow.attributes.shadowOffset.invalid + + + + +

2d.shadow.attributes.shadowOffset.invalid

+

+ + + diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/shadows/2d.shadow.attributes.shadowOffset.valid.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/shadows/2d.shadow.attributes.shadowOffset.valid.html new file mode 100644 index 00000000000..ef79a816594 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/shadows/2d.shadow.attributes.shadowOffset.valid.html @@ -0,0 +1,51 @@ + + + +OffscreenCanvas test: 2d.shadow.attributes.shadowOffset.valid + + + + +

2d.shadow.attributes.shadowOffset.valid

+

+ + +