Changeset 95899 in webkit


Ignore:
Timestamp:
Sep 23, 2011 8:24:35 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

Source/WebCore: Unwarranted DOM Exception when canvas2D drawImage is called with src
rect out of bounds
https://bugs.webkit.org/show_bug.cgi?id=65709

Patch by Justin Novosad <junov@chromium.org> on 2011-09-23
Reviewed by Oliver Hunt.

  • html/canvas/CanvasRenderingContext2D.cpp:

(WebCore::CanvasRenderingContext2D::drawImage):
Return early without throwing an exception if source rectangle is out of
bounds to match the spec.

LayoutTests: Unwarranted DOM Exception when canvas2D drawImage is called with src
rect is out of bounds
https://bugs.webkit.org/show_bug.cgi?id=65709

Patch by Justin Novosad <junov@chromium.org> on 2011-09-23
Reviewed by Oliver Hunt.

  • fast/canvas/drawImage-with-invalid-args-expected.txt:
  • fast/canvas/drawImage-with-invalid-args.html:

This test covers (among other things) cases where the source rectangle is
_completely_ outside the bounds of the source image. It was modified to no
longer expect DOM exceptions

  • platform/chromium/test_expectations.txt:

Out-dated test canvas/philip/tests/2d.drawImage.outsidesource.html
is now expected to fail

  • platform/mac/Skipped:

Skipping canvas/philip/tests/2d.drawImage.outsidesource.html

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r95897 r95899  
     12011-09-23  Justin Novosad  <junov@chromium.org>
     2
     3        Unwarranted DOM Exception when canvas2D drawImage is called with src
     4        rect is out of bounds
     5        https://bugs.webkit.org/show_bug.cgi?id=65709
     6
     7        Reviewed by Oliver Hunt.
     8
     9        * fast/canvas/drawImage-with-invalid-args-expected.txt:
     10        * fast/canvas/drawImage-with-invalid-args.html:
     11        This test covers (among other things) cases where the source rectangle is
     12        _completely_ outside the bounds of the source image.  It was modified to no
     13        longer expect DOM exceptions
     14        * platform/chromium/test_expectations.txt:
     15        Out-dated test canvas/philip/tests/2d.drawImage.outsidesource.html
     16        is now expected to fail
     17        * platform/mac/Skipped:
     18        Skipping canvas/philip/tests/2d.drawImage.outsidesource.html
     19
    1202011-09-23  Mihai Parparita  <mihaip@chromium.org>
    221
  • trunk/LayoutTests/fast/canvas/drawImage-with-invalid-args-expected.txt

    r93359 r95899  
    1616PASS: null image, got exception as expected
    1717PASS: null image, got exception as expected
    18 PASS: imageRect does not contain sourceRect on the left side, got exception as expected
    19 PASS: imageRect does not contain sourceRect on the right side, got exception as expected
    20 PASS: imageRect does not contain sourceRect on top, got exception as expected
    21 PASS: imageRect does not contain sourceRect on bottom, got exception as expected
    22 PASS: sourceRect is bigger than imageSource on every side, got exception as expected
    23 PASS: negative size of source, imageRect does not contain sourceRect on the left side, got exception as expected
    24 PASS: negative size of source, imageRect does not contain sourceRect on the right side, got exception as expected
    25 PASS: negative size of source, imageRect does not contain sourceRect on top, got exception as expected
    26 PASS: negative size of source, imageRect does not contain sourceRect on bottom, got exception as expected
    27 PASS: negative size of source, imageRect does not contain sourceRect on every side, got exception as expected
     18PASS: imageRect does not contain sourceRect on the left side
     19PASS: imageRect does not contain sourceRect on the right side
     20PASS: imageRect does not contain sourceRect on top
     21PASS: imageRect does not contain sourceRect on bottom
     22PASS: sourceRect is bigger than imageSource on every side
     23PASS: negative size of source, imageRect does not contain sourceRect on the left side
     24PASS: negative size of source, imageRect does not contain sourceRect on the right side
     25PASS: negative size of source, imageRect does not contain sourceRect on top
     26PASS: negative size of source, imageRect does not contain sourceRect on bottom
     27PASS: negative size of source, imageRect does not contain sourceRect on every side
    2828Test complete.
    2929
  • trunk/LayoutTests/fast/canvas/drawImage-with-invalid-args.html

    r93359 r95899  
    115115        try{
    116116            ctx.drawImage(myImage, -10, 0, 52, 64, 0, 0, 20, 20);
     117            print("PASS: imageRect does not contain sourceRect on the left side");
     118        } catch (e) {
    117119            print("FAIL");
    118         } catch (e) {
    119             print("PASS: imageRect does not contain sourceRect on the left side, got exception as expected");
    120120        }
    121121        try{
    122122            ctx.drawImage(myImage, 10, 0, 52, 64, 0, 0, 20, 20);
     123            print("PASS: imageRect does not contain sourceRect on the right side");
     124        } catch (e) {
    123125            print("FAIL");
    124         } catch (e) {
    125             print("PASS: imageRect does not contain sourceRect on the right side, got exception as expected");
    126126        }
    127127        try{
    128128            ctx.drawImage(myImage, 0, -10, 52, 64, 0, 0, 20, 20);
     129            print("PASS: imageRect does not contain sourceRect on top");
     130        } catch (e) {
    129131            print("FAIL");
    130         } catch (e) {
    131             print("PASS: imageRect does not contain sourceRect on top, got exception as expected");
    132132        }
    133133        try{
    134134            ctx.drawImage(myImage, 0, 10, 52, 64, 0, 0, 20, 20);
     135            print("PASS: imageRect does not contain sourceRect on bottom");
     136        } catch (e) {
    135137            print("FAIL");
    136         } catch (e) {
    137             print("PASS: imageRect does not contain sourceRect on bottom, got exception as expected");
    138138        }
    139139        try{
    140140            ctx.drawImage(myImage, -10, -10, 72, 84, 0, 0, 20, 20);
     141            print("PASS: sourceRect is bigger than imageSource on every side");
     142        } catch (e) {
    141143            print("FAIL");
    142         } catch (e) {
    143             print("PASS: sourceRect is bigger than imageSource on every side, got exception as expected");
    144144        }
    145145        try{
    146146            ctx.drawImage(myImage, 42, 64, -52, -64, 0, 0, 20, 20);
     147            print("PASS: negative size of source, imageRect does not contain sourceRect on the left side");
     148        } catch (e) {
    147149            print("FAIL");
    148         } catch (e) {
    149             print("PASS: negative size of source, imageRect does not contain sourceRect on the left side, got exception as expected");
    150150        }
    151151        try{
    152152            ctx.drawImage(myImage, 62, 64, -52, -64, 0, 0, 20, 20);
     153            print("PASS: negative size of source, imageRect does not contain sourceRect on the right side");
     154        } catch (e) {
    153155            print("FAIL");
    154         } catch (e) {
    155             print("PASS: negative size of source, imageRect does not contain sourceRect on the right side, got exception as expected");
    156156        }
    157157        try{
    158158            ctx.drawImage(myImage, 52, 54, -52, -64, 0, 0, 20, 20);
     159            print("PASS: negative size of source, imageRect does not contain sourceRect on top");
     160        } catch (e) {
    159161            print("FAIL");
    160         } catch (e) {
    161             print("PASS: negative size of source, imageRect does not contain sourceRect on top, got exception as expected");
    162162        }
    163163        try{
    164164            ctx.drawImage(myImage, 52, 74, -52, -64, 0, 0, 20, 20);
     165            print("PASS: negative size of source, imageRect does not contain sourceRect on bottom");
     166        } catch (e) {
    165167            print("FAIL");
    166         } catch (e) {
    167             print("PASS: negative size of source, imageRect does not contain sourceRect on bottom, got exception as expected");
    168168        }
    169169        try{
    170170            ctx.drawImage(myImage, 62, 74, -72, -84, 0, 0, 20, 20);
     171            print("PASS: negative size of source, imageRect does not contain sourceRect on every side");
     172        } catch (e) {
    171173            print("FAIL");
    172         } catch (e) {
    173             print("PASS: negative size of source, imageRect does not contain sourceRect on every side, got exception as expected");
    174174        }
    175175        ctx.fillStyle = 'green';
  • trunk/LayoutTests/platform/chromium/test_expectations.txt

    r95892 r95899  
    234234// We don't let anyone set status in the browser.
    235235WONTFIX SKIP : plugins/set-status.html = TEXT
     236
     237// This test is out of date with respect to the latest version of the HTML5 spec
     238// Test had to be decommissioned to fix https://bugs.webkit.org/show_bug.cgi?id=65709
     239// We can re-enable the test when it gets changed upstream to become spec-compliant
     240WONTFIX : canvas/philip/tests/2d.drawImage.outsidesource.html = TEXT
    236241
    237242// We don't care about dashboard compatibility mode.
  • trunk/LayoutTests/platform/mac/Skipped

    r95752 r95899  
    163163canvas/philip/tests/2d.imageData.object.wrap.html
    164164
     165# This canvas test is skipped because it is out of date with respect to
     166# the current spec, and the fix for https://bugs.webkit.org/show_bug.cgi?id=65709
     167# which complies with the current spec, makes this test fail by no longer throwing
     168# exceptions that were previously expected
     169canvas/philip/tests/2d.drawImage.outsidesource.html
     170
    165171# IndexedDB is not yet enabled.
    166172storage/indexeddb
  • trunk/Source/WebCore/ChangeLog

    r95898 r95899  
     12011-09-23  Justin Novosad  <junov@chromium.org>
     2
     3        Unwarranted DOM Exception when canvas2D drawImage is called with src
     4        rect out of bounds
     5        https://bugs.webkit.org/show_bug.cgi?id=65709
     6
     7        Reviewed by Oliver Hunt.
     8
     9        * html/canvas/CanvasRenderingContext2D.cpp:
     10        (WebCore::CanvasRenderingContext2D::drawImage):
     11        Return early without throwing an exception if source rectangle is out of
     12        bounds to match the spec.
     13
    1142011-09-23  Lukasz Slachciak  <l.slachciak@samsung.com>
    215
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r95346 r95899  
    12721272
    12731273    FloatRect imageRect = FloatRect(FloatPoint(), size(image));
    1274     if (!imageRect.contains(normalizedSrcRect) || !srcRect.width() || !srcRect.height()) {
     1274    if (!srcRect.width() || !srcRect.height()) {
    12751275        ec = INDEX_SIZE_ERR;
    12761276        return;
    12771277    }
     1278    if (!imageRect.contains(normalizedSrcRect))
     1279        return;
    12781280
    12791281    GraphicsContext* c = drawingContext();
     
    13341336    }
    13351337
    1336     if (!srcCanvasRect.contains(normalizeRect(srcRect)) || !srcRect.width() || !srcRect.height()) {
     1338    if (!srcRect.width() || !srcRect.height()) {
    13371339        ec = INDEX_SIZE_ERR;
    13381340        return;
     
    13411343    ec = 0;
    13421344
    1343     if (!dstRect.width() || !dstRect.height())
     1345    if (!srcCanvasRect.contains(normalizeRect(srcRect)) || !dstRect.width() || !dstRect.height())
    13441346        return;
    13451347
     
    14151417
    14161418    FloatRect videoRect = FloatRect(FloatPoint(), size(video));
    1417     if (!videoRect.contains(normalizeRect(srcRect)) || !srcRect.width() || !srcRect.height()) {
     1419    if (!srcRect.width() || !srcRect.height()) {
    14181420        ec = INDEX_SIZE_ERR;
    14191421        return;
    14201422    }
    14211423
    1422     if (!dstRect.width() || !dstRect.height())
     1424    if (!videoRect.contains(normalizeRect(srcRect)) || !dstRect.width() || !dstRect.height())
    14231425        return;
    14241426
Note: See TracChangeset for help on using the changeset viewer.