Changeset 181888 in webkit


Ignore:
Timestamp:
Mar 23, 2015 11:47:40 PM (9 years ago)
Author:
yoav@yoav.ws
Message:

Update empty image canvas tests and fix a related bug
https://bugs.webkit.org/show_bug.cgi?id=142694

Reviewed by Chris Dumez.

Source/WebCore:

During the work on https://bugs.webkit.org/show_bug.cgi?id=142677
we encountered an issue with canvas tests related to empty image handling
when drawn or used as a pattern. After updating these tests, an issue with
pattern handling was encountered.

The spec, as well as Chrome's implementation, say that when an empty image
is used as a pattern, createPattern should return null. See
https://html.spec.whatwg.org/multipage/scripting.html#fill-and-stroke-styles:check-the-usability-of-the-image-argument
Instead, createPattern returned an exception in this case.
This patch fixes that and makes sure that it returns a null when image loading hasn't started.

Tests: canvas/philip/tests/2d.drawImage.incomplete.emptysrc.html

canvas/philip/tests/2d.drawImage.incomplete.nosrc.html
canvas/philip/tests/2d.drawImage.incomplete.removedsrc.html
canvas/philip/tests/2d.pattern.image.incomplete.emptysrc.html
canvas/philip/tests/2d.pattern.image.incomplete.removedsrc.html

  • html/canvas/CanvasRenderingContext2D.cpp:

(WebCore::CanvasRenderingContext2D::createPattern): Return "null" if image is not fully decodeable.

LayoutTests:

Tests below imported from https://github.com/w3c/web-platform-tests/tree/master/2dcontext/drawing-images-to-the-canvas

  • canvas/philip/tests/2d.drawImage.incomplete-expected.txt: Removed.
  • canvas/philip/tests/2d.drawImage.incomplete.emptysrc-expected.txt: Added.
  • canvas/philip/tests/2d.drawImage.incomplete.emptysrc.html: Added.
  • canvas/philip/tests/2d.drawImage.incomplete.html: Removed.
  • canvas/philip/tests/2d.drawImage.incomplete.nosrc-expected.txt: Added.
  • canvas/philip/tests/2d.drawImage.incomplete.nosrc.html: Added.
  • canvas/philip/tests/2d.drawImage.incomplete.removedsrc-expected.txt: Added.
  • canvas/philip/tests/2d.drawImage.incomplete.removedsrc.html: Added.

Tests below imported from https://github.com/w3c/web-platform-tests/tree/master/2dcontext/fill-and-stroke-styles

  • canvas/philip/tests/2d.pattern.image.incomplete-expected.txt: Removed.
  • canvas/philip/tests/2d.pattern.image.incomplete.empty-expected.txt: Removed.
  • canvas/philip/tests/2d.pattern.image.incomplete.empty.html: Removed.
  • canvas/philip/tests/2d.pattern.image.incomplete.emptysrc-expected.txt: Added.
  • canvas/philip/tests/2d.pattern.image.incomplete.emptysrc.html: Added.
  • canvas/philip/tests/2d.pattern.image.incomplete.html: Removed.
  • canvas/philip/tests/2d.pattern.image.incomplete.omitted-expected.txt: Removed.
  • canvas/philip/tests/2d.pattern.image.incomplete.omitted.html: Removed.
  • canvas/philip/tests/2d.pattern.image.incomplete.removedsrc-expected.txt: Added.

This test currently fails and will be fixed in https://bugs.webkit.org/show_bug.cgi?id=142677

  • canvas/philip/tests/2d.pattern.image.incomplete.removedsrc.html: Added.

Test below imported from https://chromium.googlesource.com/chromium/blink/+/master/LayoutTests/fast/canvas/

  • fast/canvas/canvas-empty-image-pattern.html: Aligned with spec/Chrome.
  • fast/canvas/canvas-empty-image-pattern-expected.txt: Aligned with spec/Chrome.
  • TestExpectations: Added 2d.pattern.image.incomplete.removedsrc.html as an expected failure.
Location:
trunk
Files:
10 added
9 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r181886 r181888  
     12015-03-23  Yoav Weiss  <yoav@yoav.ws>
     2
     3        Update empty image canvas tests and fix a related bug
     4        https://bugs.webkit.org/show_bug.cgi?id=142694
     5
     6        Reviewed by Chris Dumez.
     7
     8        Tests below imported from https://github.com/w3c/web-platform-tests/tree/master/2dcontext/drawing-images-to-the-canvas
     9        * canvas/philip/tests/2d.drawImage.incomplete-expected.txt: Removed.
     10        * canvas/philip/tests/2d.drawImage.incomplete.emptysrc-expected.txt: Added.
     11        * canvas/philip/tests/2d.drawImage.incomplete.emptysrc.html: Added.
     12        * canvas/philip/tests/2d.drawImage.incomplete.html: Removed.
     13        * canvas/philip/tests/2d.drawImage.incomplete.nosrc-expected.txt: Added.
     14        * canvas/philip/tests/2d.drawImage.incomplete.nosrc.html: Added.
     15        * canvas/philip/tests/2d.drawImage.incomplete.removedsrc-expected.txt: Added.
     16        * canvas/philip/tests/2d.drawImage.incomplete.removedsrc.html: Added.
     17
     18        Tests below imported from https://github.com/w3c/web-platform-tests/tree/master/2dcontext/fill-and-stroke-styles
     19        * canvas/philip/tests/2d.pattern.image.incomplete-expected.txt: Removed.
     20        * canvas/philip/tests/2d.pattern.image.incomplete.empty-expected.txt: Removed.
     21        * canvas/philip/tests/2d.pattern.image.incomplete.empty.html: Removed.
     22        * canvas/philip/tests/2d.pattern.image.incomplete.emptysrc-expected.txt: Added.
     23        * canvas/philip/tests/2d.pattern.image.incomplete.emptysrc.html: Added.
     24        * canvas/philip/tests/2d.pattern.image.incomplete.html: Removed.
     25        * canvas/philip/tests/2d.pattern.image.incomplete.omitted-expected.txt: Removed.
     26        * canvas/philip/tests/2d.pattern.image.incomplete.omitted.html: Removed.
     27        * canvas/philip/tests/2d.pattern.image.incomplete.removedsrc-expected.txt: Added.
     28        This test currently fails and will be fixed in https://bugs.webkit.org/show_bug.cgi?id=142677
     29        * canvas/philip/tests/2d.pattern.image.incomplete.removedsrc.html: Added.
     30
     31        Test below imported from https://chromium.googlesource.com/chromium/blink/+/master/LayoutTests/fast/canvas/
     32        * fast/canvas/canvas-empty-image-pattern.html: Aligned with spec/Chrome.
     33        * fast/canvas/canvas-empty-image-pattern-expected.txt: Aligned with spec/Chrome.
     34        * TestExpectations: Added 2d.pattern.image.incomplete.removedsrc.html as an expected failure.
     35
    1362015-03-23  Filip Pizlo  <fpizlo@apple.com>
    237
  • trunk/LayoutTests/TestExpectations

    r181783 r181888  
    494494# contentfiltering/block-after-add-data.html times out unexpectedly
    495495webkit.org/b/142894 contentfiltering/block-after-add-data.html [ Skip ]
     496webkit.org/b/142677 canvas/philip/tests/2d.pattern.image.incomplete.removedsrc.html [ Failure ]
  • trunk/LayoutTests/fast/canvas/canvas-empty-image-pattern-expected.txt

    r168400 r181888  
    1 CONSOLE MESSAGE: line 9: InvalidStateError: DOM Exception 11: An attempt was made to use an object that is not, or is no longer, usable.
     1TEST PASSED
    22
  • trunk/LayoutTests/fast/canvas/canvas-empty-image-pattern.html

    r120683 r181888  
    11<!DOCTYPE HTML>
    22<title>Canvas test: filling a pattern with an empty image should not crash.</title>
     3<div id="console"></div>
    34<canvas id="canvas" class="output" width="100" height="100"><p class="fallback">FAIL (fallback content)</p></canvas>
    45<script>
     
    78
    89var canvas = document.getElementById("canvas").getContext("2d");
    9 canvas.fillStyle = canvas.createPattern(new Image, "repeat")
    10 canvas.fillRect(0,0,1,1)
     10var pattern = canvas.createPattern(new Image, "repeat")
     11if (pattern)
     12    document.getElementById("console").innerHTML = "TEST FAILED";
     13else
     14    document.getElementById("console").innerHTML = "TEST PASSED";
    1115</script>
  • trunk/Source/WebCore/ChangeLog

    r181883 r181888  
     12015-03-23 Yoav Weiss  <yoav@yoav.ws>
     2
     3        Update empty image canvas tests and fix a related bug
     4        https://bugs.webkit.org/show_bug.cgi?id=142694
     5
     6        Reviewed by Chris Dumez.
     7
     8        During the work on https://bugs.webkit.org/show_bug.cgi?id=142677
     9        we encountered an issue with canvas tests related to empty image handling
     10        when drawn or used as a pattern. After updating these tests, an issue with
     11        pattern handling was encountered.
     12
     13        The spec, as well as Chrome's implementation, say that when an empty image
     14        is used as a pattern, createPattern should return null. See
     15        https://html.spec.whatwg.org/multipage/scripting.html#fill-and-stroke-styles:check-the-usability-of-the-image-argument
     16        Instead, createPattern returned an exception in this case.
     17        This patch fixes that and makes sure that it returns a null when image loading hasn't started.
     18
     19        Tests: canvas/philip/tests/2d.drawImage.incomplete.emptysrc.html
     20               canvas/philip/tests/2d.drawImage.incomplete.nosrc.html
     21               canvas/philip/tests/2d.drawImage.incomplete.removedsrc.html
     22               canvas/philip/tests/2d.pattern.image.incomplete.emptysrc.html
     23               canvas/philip/tests/2d.pattern.image.incomplete.removedsrc.html
     24
     25        * html/canvas/CanvasRenderingContext2D.cpp:
     26        (WebCore::CanvasRenderingContext2D::createPattern): Return "null" if image is not fully decodeable.
     27
    1282015-03-23  Alex Christensen  <achristensen@webkit.org>
    229
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r180839 r181888  
    17521752        return nullptr;
    17531753
    1754     if (!image->complete())
     1754    CachedImage* cachedImage = image->cachedImage();
     1755    // If the image loading hasn't started or the image is not complete, it is not fully decodable.
     1756    if (!cachedImage || !image->complete())
    17551757        return nullptr;
    17561758
    1757     CachedImage* cachedImage = image->cachedImage();
    1758     if (!cachedImage || cachedImage->status() == CachedResource::LoadError) {
     1759    if (cachedImage->status() == CachedResource::LoadError) {
    17591760        ec = INVALID_STATE_ERR;
    17601761        return nullptr;
Note: See TracChangeset for help on using the changeset viewer.