diff --git a/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp b/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp index bec4737836e..33e3a5b7e08 100644 --- a/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp +++ b/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -802,7 +803,9 @@ WebIDL::ExceptionOr check_usability_of_image(CanvasI auto usability = TRY(image.visit( // HTMLOrSVGImageElement [](GC::Root const& image_element) -> WebIDL::ExceptionOr> { - // FIXME: If image's current request's state is broken, then throw an "InvalidStateError" DOMException. + // If image's current request's state is broken, then throw an "InvalidStateError" DOMException. + if (image_element->current_request().state() == HTML::ImageRequest::State::Broken) + return WebIDL::InvalidStateError::create(image_element->realm(), "Image element state is broken"_utf16); // If image is not fully decodable, then return bad. if (!image_element->immutable_bitmap()) diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/drawing-images-to-the-canvas/2d.drawImage.nonexistent.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/drawing-images-to-the-canvas/2d.drawImage.nonexistent.txt new file mode 100644 index 00000000000..86efdc281d4 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/drawing-images-to-the-canvas/2d.drawImage.nonexistent.txt @@ -0,0 +1,6 @@ +Harness status: OK + +Found 1 tests + +1 Pass +Pass Canvas test: 2d.drawImage.nonexistent \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/fill-and-stroke-styles/2d.pattern.image.broken.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/fill-and-stroke-styles/2d.pattern.image.broken.txt new file mode 100644 index 00000000000..425c2009424 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/fill-and-stroke-styles/2d.pattern.image.broken.txt @@ -0,0 +1,6 @@ +Harness status: OK + +Found 1 tests + +1 Pass +Pass Canvas test: 2d.pattern.image.broken \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/fill-and-stroke-styles/2d.pattern.image.nonexistent.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/fill-and-stroke-styles/2d.pattern.image.nonexistent.txt new file mode 100644 index 00000000000..e63ac5a1ff4 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/fill-and-stroke-styles/2d.pattern.image.nonexistent.txt @@ -0,0 +1,6 @@ +Harness status: OK + +Found 1 tests + +1 Pass +Pass Canvas test: 2d.pattern.image.nonexistent \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/element/drawing-images-to-the-canvas/2d.drawImage.nonexistent.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/element/drawing-images-to-the-canvas/2d.drawImage.nonexistent.html new file mode 100644 index 00000000000..bb0f05c6bec --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/element/drawing-images-to-the-canvas/2d.drawImage.nonexistent.html @@ -0,0 +1,29 @@ + + + +Canvas test: 2d.drawImage.nonexistent + + + + + + +

2d.drawImage.nonexistent

+

+ + +

Actual output:

+

FAIL (fallback content)

+ +
    + + + diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/element/fill-and-stroke-styles/2d.pattern.image.broken.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/element/fill-and-stroke-styles/2d.pattern.image.broken.html new file mode 100644 index 00000000000..f5635626e20 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/element/fill-and-stroke-styles/2d.pattern.image.broken.html @@ -0,0 +1,29 @@ + + + +Canvas test: 2d.pattern.image.broken + + + + + + +

    2d.pattern.image.broken

    +

    + + +

    Actual output:

    +

    FAIL (fallback content)

    + +
      + + + diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/element/fill-and-stroke-styles/2d.pattern.image.nonexistent.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/element/fill-and-stroke-styles/2d.pattern.image.nonexistent.html new file mode 100644 index 00000000000..6caf5927d3f --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/element/fill-and-stroke-styles/2d.pattern.image.nonexistent.html @@ -0,0 +1,29 @@ + + + +Canvas test: 2d.pattern.image.nonexistent + + + + + + +

      2d.pattern.image.nonexistent

      +

      + + +

      Actual output:

      +

      FAIL (fallback content)

      + +
        + + + diff --git a/Tests/LibWeb/Text/input/wpt-import/images/broken.png b/Tests/LibWeb/Text/input/wpt-import/images/broken.png new file mode 100644 index 00000000000..2ff648a0490 Binary files /dev/null and b/Tests/LibWeb/Text/input/wpt-import/images/broken.png differ