Changeset 59582 in webkit


Ignore:
Timestamp:
May 16, 2010 2:46:10 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-05-16 Andreas Kling <andreas.kling@nokia.com>

Reviewed by Kenneth Rohde Christiansen.

Add a test to verify proper handling of invalid arguments to getImageData().
Updated old putImageData() test with correct expectations.

https://bugs.webkit.org/show_bug.cgi?id=39175

Spec link:
http://www.whatwg.org/specs/web-apps/current-work/#pixel-manipulation

  • fast/canvas/canvas-getImageData-invalid-expected.txt: Added.
  • fast/canvas/canvas-getImageData-invalid.html: Added.
  • fast/canvas/canvas-putImageData-expected.txt:
  • fast/canvas/canvas-putImageData.js:
  • fast/canvas/script-tests/canvas-getImageData-invalid.js: Added.

2010-05-16 Andreas Kling <andreas.kling@nokia.com>

Reviewed by Kenneth Rohde Christiansen.

Properly handle invalid arguments to CanvasRenderingContext2D's getImageData() and putImageData().
Both should throw NOT_SUPPORTED_ERR when called with nonfinite arguments.
getImageData() should throw INDEX_SIZE_ERR if either width or height is 0.

https://bugs.webkit.org/show_bug.cgi?id=39175

Spec link:
http://www.whatwg.org/specs/web-apps/current-work/#pixel-manipulation

Test: fast/canvas/canvas-getImageData-invalid.html

  • html/canvas/CanvasRenderingContext2D.cpp: (WebCore::CanvasRenderingContext2D::createImageData): (WebCore::CanvasRenderingContext2D::getImageData): (WebCore::CanvasRenderingContext2D::putImageData):
Location:
trunk
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r59581 r59582  
     12010-05-16  Andreas Kling  <andreas.kling@nokia.com>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        Add a test to verify proper handling of invalid arguments to getImageData().
     6        Updated old putImageData() test with correct expectations.
     7
     8        https://bugs.webkit.org/show_bug.cgi?id=39175
     9
     10        Spec link:
     11        http://www.whatwg.org/specs/web-apps/current-work/#pixel-manipulation
     12
     13        * fast/canvas/canvas-getImageData-invalid-expected.txt: Added.
     14        * fast/canvas/canvas-getImageData-invalid.html: Added.
     15        * fast/canvas/canvas-putImageData-expected.txt:
     16        * fast/canvas/canvas-putImageData.js:
     17        * fast/canvas/script-tests/canvas-getImageData-invalid.js: Added.
     18
    1192010-05-16  Andreas Kling  <andreas.kling@nokia.com>
    220
  • trunk/LayoutTests/fast/canvas/canvas-putImageData-expected.txt

    r30700 r59582  
    147147PASS getPixel(9,9) is [0,128,0,255]
    148148PASS context.putImageData({}, 0, 0) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    149 PASS context.putImageData(buffer, NaN, 0, 0, 0, 0, 0) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
    150 PASS context.putImageData(buffer, 0, NaN, 0, 0, 0, 0) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
    151 PASS context.putImageData(buffer, 0, 0, NaN, 0, 0, 0) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
    152 PASS context.putImageData(buffer, 0, 0, 0, NaN, 0, 0) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
    153 PASS context.putImageData(buffer, 0, 0, 0, 0, NaN, 0) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
    154 PASS context.putImageData(buffer, 0, 0, 0, 0, 0, NaN) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
    155 PASS context.putImageData(buffer, Infinity, 0, 0, 0, 0, 0) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
    156 PASS context.putImageData(buffer, 0, Infinity, 0, 0, 0, 0) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
    157 PASS context.putImageData(buffer, 0, 0, Infinity, 0, 0, 0) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
    158 PASS context.putImageData(buffer, 0, 0, 0, Infinity, 0, 0) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
    159 PASS context.putImageData(buffer, 0, 0, 0, 0, Infinity, 0) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
    160 PASS context.putImageData(buffer, 0, 0, 0, 0, 0, Infinity) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
    161 PASS context.putImageData(buffer, undefined, 0, 0, 0, 0, 0) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
    162 PASS context.putImageData(buffer, 0, undefined, 0, 0, 0, 0) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
    163 PASS context.putImageData(buffer, 0, 0, undefined, 0, 0, 0) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
    164 PASS context.putImageData(buffer, 0, 0, 0, undefined, 0, 0) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
    165 PASS context.putImageData(buffer, 0, 0, 0, 0, undefined, 0) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
    166 PASS context.putImageData(buffer, 0, 0, 0, 0, 0, undefined) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
     149PASS context.putImageData(buffer, NaN, 0, 0, 0, 0, 0) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
     150PASS context.putImageData(buffer, 0, NaN, 0, 0, 0, 0) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
     151PASS context.putImageData(buffer, 0, 0, NaN, 0, 0, 0) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
     152PASS context.putImageData(buffer, 0, 0, 0, NaN, 0, 0) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
     153PASS context.putImageData(buffer, 0, 0, 0, 0, NaN, 0) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
     154PASS context.putImageData(buffer, 0, 0, 0, 0, 0, NaN) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
     155PASS context.putImageData(buffer, Infinity, 0, 0, 0, 0, 0) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
     156PASS context.putImageData(buffer, 0, Infinity, 0, 0, 0, 0) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
     157PASS context.putImageData(buffer, 0, 0, Infinity, 0, 0, 0) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
     158PASS context.putImageData(buffer, 0, 0, 0, Infinity, 0, 0) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
     159PASS context.putImageData(buffer, 0, 0, 0, 0, Infinity, 0) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
     160PASS context.putImageData(buffer, 0, 0, 0, 0, 0, Infinity) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
     161PASS context.putImageData(buffer, undefined, 0, 0, 0, 0, 0) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
     162PASS context.putImageData(buffer, 0, undefined, 0, 0, 0, 0) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
     163PASS context.putImageData(buffer, 0, 0, undefined, 0, 0, 0) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
     164PASS context.putImageData(buffer, 0, 0, 0, undefined, 0, 0) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
     165PASS context.putImageData(buffer, 0, 0, 0, 0, undefined, 0) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
     166PASS context.putImageData(buffer, 0, 0, 0, 0, 0, undefined) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
    167167PASS successfullyParsed is true
    168168
  • trunk/LayoutTests/fast/canvas/canvas-putImageData.js

    r30710 r59582  
    203203
    204204shouldThrow("context.putImageData({}, 0, 0)", "'Error: TYPE_MISMATCH_ERR: DOM Exception 17'");
    205 shouldThrow("context.putImageData(buffer, NaN, 0, 0, 0, 0, 0)", "'Error: INDEX_SIZE_ERR: DOM Exception 1'");
    206 shouldThrow("context.putImageData(buffer, 0, NaN, 0, 0, 0, 0)", "'Error: INDEX_SIZE_ERR: DOM Exception 1'");
    207 shouldThrow("context.putImageData(buffer, 0, 0, NaN, 0, 0, 0)", "'Error: INDEX_SIZE_ERR: DOM Exception 1'");
    208 shouldThrow("context.putImageData(buffer, 0, 0, 0, NaN, 0, 0)", "'Error: INDEX_SIZE_ERR: DOM Exception 1'");
    209 shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, NaN, 0)", "'Error: INDEX_SIZE_ERR: DOM Exception 1'");
    210 shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, 0, NaN)", "'Error: INDEX_SIZE_ERR: DOM Exception 1'");
    211 shouldThrow("context.putImageData(buffer, Infinity, 0, 0, 0, 0, 0)", "'Error: INDEX_SIZE_ERR: DOM Exception 1'");
    212 shouldThrow("context.putImageData(buffer, 0, Infinity, 0, 0, 0, 0)", "'Error: INDEX_SIZE_ERR: DOM Exception 1'");
    213 shouldThrow("context.putImageData(buffer, 0, 0, Infinity, 0, 0, 0)", "'Error: INDEX_SIZE_ERR: DOM Exception 1'");
    214 shouldThrow("context.putImageData(buffer, 0, 0, 0, Infinity, 0, 0)", "'Error: INDEX_SIZE_ERR: DOM Exception 1'");
    215 shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, Infinity, 0)", "'Error: INDEX_SIZE_ERR: DOM Exception 1'");
    216 shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, 0, Infinity)", "'Error: INDEX_SIZE_ERR: DOM Exception 1'");
    217 shouldThrow("context.putImageData(buffer, undefined, 0, 0, 0, 0, 0)", "'Error: INDEX_SIZE_ERR: DOM Exception 1'");
    218 shouldThrow("context.putImageData(buffer, 0, undefined, 0, 0, 0, 0)", "'Error: INDEX_SIZE_ERR: DOM Exception 1'");
    219 shouldThrow("context.putImageData(buffer, 0, 0, undefined, 0, 0, 0)", "'Error: INDEX_SIZE_ERR: DOM Exception 1'");
    220 shouldThrow("context.putImageData(buffer, 0, 0, 0, undefined, 0, 0)", "'Error: INDEX_SIZE_ERR: DOM Exception 1'");
    221 shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, undefined, 0)", "'Error: INDEX_SIZE_ERR: DOM Exception 1'");
    222 shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, 0, undefined)", "'Error: INDEX_SIZE_ERR: DOM Exception 1'");
     205shouldThrow("context.putImageData(buffer, NaN, 0, 0, 0, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");
     206shouldThrow("context.putImageData(buffer, 0, NaN, 0, 0, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");
     207shouldThrow("context.putImageData(buffer, 0, 0, NaN, 0, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");
     208shouldThrow("context.putImageData(buffer, 0, 0, 0, NaN, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");
     209shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, NaN, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");
     210shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, 0, NaN)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");
     211shouldThrow("context.putImageData(buffer, Infinity, 0, 0, 0, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");
     212shouldThrow("context.putImageData(buffer, 0, Infinity, 0, 0, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");
     213shouldThrow("context.putImageData(buffer, 0, 0, Infinity, 0, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");
     214shouldThrow("context.putImageData(buffer, 0, 0, 0, Infinity, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");
     215shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, Infinity, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");
     216shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, 0, Infinity)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");
     217shouldThrow("context.putImageData(buffer, undefined, 0, 0, 0, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");
     218shouldThrow("context.putImageData(buffer, 0, undefined, 0, 0, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");
     219shouldThrow("context.putImageData(buffer, 0, 0, undefined, 0, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");
     220shouldThrow("context.putImageData(buffer, 0, 0, 0, undefined, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");
     221shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, undefined, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");
     222shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, 0, undefined)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");
    223223
    224224// Ensure we don't mess up bounds clipping checks
  • trunk/WebCore/ChangeLog

    r59581 r59582  
     12010-05-16  Andreas Kling  <andreas.kling@nokia.com>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        Properly handle invalid arguments to CanvasRenderingContext2D's getImageData() and putImageData().
     6        Both should throw NOT_SUPPORTED_ERR when called with nonfinite arguments.
     7        getImageData() should throw INDEX_SIZE_ERR if either width or height is 0.
     8
     9        https://bugs.webkit.org/show_bug.cgi?id=39175
     10
     11        Spec link:
     12        http://www.whatwg.org/specs/web-apps/current-work/#pixel-manipulation
     13
     14        Test: fast/canvas/canvas-getImageData-invalid.html
     15
     16        * html/canvas/CanvasRenderingContext2D.cpp:
     17        (WebCore::CanvasRenderingContext2D::createImageData):
     18        (WebCore::CanvasRenderingContext2D::getImageData):
     19        (WebCore::CanvasRenderingContext2D::putImageData):
     20
    1212010-05-16  Andreas Kling  <andreas.kling@nokia.com>
    222
  • trunk/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r59561 r59582  
    13461346{
    13471347    ec = 0;
     1348    if (!sw || !sh) {
     1349        ec = INDEX_SIZE_ERR;
     1350        return 0;
     1351    }
    13481352    if (!isfinite(sw) || !isfinite(sh)) {
    13491353        ec = NOT_SUPPORTED_ERR;
    1350         return 0;
    1351     }
    1352     if (!sw || !sh) {
    1353         ec = INDEX_SIZE_ERR;
    13541354        return 0;
    13551355    }
     
    13711371        return 0;
    13721372    }
    1373    
     1373    if (!sw || !sh) {
     1374        ec = INDEX_SIZE_ERR;
     1375        return 0;
     1376    }
     1377    if (!isfinite(sx) || !isfinite(sy) || !isfinite(sw) || !isfinite(sh)) {
     1378        ec = NOT_SUPPORTED_ERR;
     1379        return 0;
     1380    }
     1381
    13741382    FloatRect unscaledRect(sx, sy, sw, sh);
    13751383    IntRect scaledRect = canvas()->convertLogicalToDevice(unscaledRect);
     
    14021410    if (!isfinite(dx) || !isfinite(dy) || !isfinite(dirtyX) ||
    14031411        !isfinite(dirtyY) || !isfinite(dirtyWidth) || !isfinite(dirtyHeight)) {
    1404         ec = INDEX_SIZE_ERR;
     1412        ec = NOT_SUPPORTED_ERR;
    14051413        return;
    14061414    }
Note: See TracChangeset for help on using the changeset viewer.