Changeset 168400 in webkit


Ignore:
Timestamp:
May 6, 2014 7:25:00 PM (10 years ago)
Author:
cabanier@adobe.com
Message:

Calling createPattern with a broken image must throw an invalidstate error
https://bugs.webkit.org/show_bug.cgi?id=132407

Reviewed by Darin Adler.

Source/WebCore:
Updated createPattern so it throws an invalidState exception
if you pass it an image that is in the broken state.

Tests:

  • canvas/philip/tests/2d.pattern.image.broken.html:
  • canvas/philip/tests/2d.pattern.image.incomplete.empty.html:
  • fast/canvas/canvas-empty-image-pattern.html:
  • html/canvas/CanvasRenderingContext2D.cpp:

(WebCore::CanvasRenderingContext2D::createPattern):

LayoutTests:

  • canvas/philip/tests/2d.pattern.image.broken-expected.txt:
  • canvas/philip/tests/2d.pattern.image.broken.html:
  • canvas/philip/tests/2d.pattern.image.incomplete.empty-expected.txt:
  • canvas/philip/tests/2d.pattern.image.incomplete.empty.html:
  • fast/canvas/canvas-empty-image-pattern-expected.txt:
  • fast/dom/gc-9-expected.txt:
  • fast/dom/gc-9.html:
  • platform/mac/canvas/philip/tests/2d.pattern.image.broken-expected.txt: Removed.
  • platform/mac/canvas/philip/tests/2d.pattern.image.incomplete.empty-expected.txt: Removed.
Location:
trunk
Files:
2 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r168390 r168400  
     12014-05-06  Rik Cabanier  <cabanier@adobe.com>
     2
     3        Calling createPattern with a broken image must throw an invalidstate error
     4        https://bugs.webkit.org/show_bug.cgi?id=132407
     5
     6        Reviewed by Darin Adler.
     7
     8        * canvas/philip/tests/2d.pattern.image.broken-expected.txt:
     9        * canvas/philip/tests/2d.pattern.image.broken.html:
     10        * canvas/philip/tests/2d.pattern.image.incomplete.empty-expected.txt:
     11        * canvas/philip/tests/2d.pattern.image.incomplete.empty.html:
     12        * fast/canvas/canvas-empty-image-pattern-expected.txt:
     13        * fast/dom/gc-9-expected.txt:
     14        * fast/dom/gc-9.html:
     15        * platform/mac/canvas/philip/tests/2d.pattern.image.broken-expected.txt: Removed.
     16        * platform/mac/canvas/philip/tests/2d.pattern.image.incomplete.empty-expected.txt: Removed.
     17
    1182014-05-06  Christophe Dumez  <ch.dumez@samsung.com>
    219
  • trunk/LayoutTests/canvas/philip/tests/2d.pattern.image.broken-expected.txt

    r71481 r168400  
    11Passed
     2
  • trunk/LayoutTests/canvas/philip/tests/2d.pattern.image.broken.html

    r71481 r168400  
    1414
    1515var img = document.getElementById('broken.png');
    16 _assertSame(img.complete, false, "img.complete", "false");
    17 _assertSame(ctx.createPattern(img, 'repeat'), null, "ctx.createPattern(img, 'repeat')", "null");
     16_assertSame(img.complete, true, "img.complete", "true");
     17var _thrown = undefined;
     18try{
     19  ctx.createPattern(img, 'repeat');
     20}catch(e) {
     21  _thrown = e;
     22}
     23_assert(_thrown && _thrown.name == "InvalidStateError" && _thrown.code == DOMException.INVALID_STATE_ERR, "should throw InvalidStateError");
    1824
    1925
    2026});
    2127</script>
    22 <img src="../images/broken.png" id="broken.png" class="resource">
     28<img src="missing.png" id="broken.png" class="resource">
    2329
  • trunk/LayoutTests/canvas/philip/tests/2d.pattern.image.incomplete.empty-expected.txt

    r71481 r168400  
    11Passed
     2
  • trunk/LayoutTests/canvas/philip/tests/2d.pattern.image.incomplete.empty.html

    r71481 r168400  
    1515var img = document.getElementById('green.png');
    1616img.src = "";
    17 _assertSame(ctx.createPattern(img, 'repeat'), null, "ctx.createPattern(img, 'repeat')", "null");
    18 
     17var _thrown = undefined;
     18try{
     19  ctx.createPattern(img, 'repeat');
     20}catch(e) {
     21  _thrown = e;
     22}
     23_assert(_thrown && _thrown.name == "InvalidStateError" && _thrown.code == DOMException.INVALID_STATE_ERR, "should throw InvalidStateError");
    1924
    2025});
  • trunk/LayoutTests/fast/canvas/canvas-empty-image-pattern-expected.txt

    r82521 r168400  
     1CONSOLE MESSAGE: line 9: InvalidStateError: DOM Exception 11: An attempt was made to use an object that is not, or is no longer, usable.
    12
  • trunk/LayoutTests/fast/dom/gc-9-expected.txt

    r112038 r168400  
    1313PASS: document.getElementsByTagName('canvas')[0].getContext('2d').myCustomProperty should be 1 and is.
    1414PASS: document.getElementsByTagName('canvas')[0].getContext('2d').createLinearGradient(0, 0, 0, 0).myCustomProperty should be undefined and is.
    15 PASS: document.getElementsByTagName('canvas')[0].getContext('2d').createPattern(new Image(), 'no-repeat').myCustomProperty should be undefined and is.
    1615PASS: document.getElementsByTagName('select')[0].options.myCustomProperty should be 1 and is.
    1716PASS: document.body.childNodes.myCustomProperty should be 1 and is.
     
    4948PASS: document.getElementsByTagName('canvas')[0].getContext('2d').myCustomProperty should be 1 and is.
    5049PASS: document.getElementsByTagName('canvas')[0].getContext('2d').createLinearGradient(0, 0, 0, 0).myCustomProperty should be undefined and is.
    51 PASS: document.getElementsByTagName('canvas')[0].getContext('2d').createPattern(new Image(), 'no-repeat').myCustomProperty should be undefined and is.
    5250PASS: document.getElementsByTagName('select')[0].options.myCustomProperty should be 1 and is.
    5351PASS: document.body.childNodes.myCustomProperty should be 1 and is.
  • trunk/LayoutTests/fast/dom/gc-9.html

    r120792 r168400  
    122122    [ "document.getElementsByTagName('canvas')[0].getContext('2d')", "allow custom" ], // CanvasRenderingContext2D
    123123    [ "document.getElementsByTagName('canvas')[0].getContext('2d').createLinearGradient(0, 0, 0, 0)" ], // CanvasGradient
    124     [ "document.getElementsByTagName('canvas')[0].getContext('2d').createPattern(new Image(), 'no-repeat')" ], // CanvasPattern
    125124    [ "document.getElementsByTagName('select')[0].options", "allow custom" ],
    126125    [ "document.body.childNodes", "allow custom" ],
  • trunk/Source/WebCore/ChangeLog

    r168399 r168400  
     12014-05-06  Rik Cabanier  <cabanier@adobe.com>
     2
     3        Calling createPattern with a broken image must throw an invalidstate error
     4        https://bugs.webkit.org/show_bug.cgi?id=132407
     5
     6        Reviewed by Darin Adler.
     7
     8        Updated createPattern so it throws an invalidState exception
     9        if you pass it an image that is in the broken state.
     10
     11        Tests:
     12        * canvas/philip/tests/2d.pattern.image.broken.html:
     13        * canvas/philip/tests/2d.pattern.image.incomplete.empty.html:
     14        * fast/canvas/canvas-empty-image-pattern.html:
     15
     16        * html/canvas/CanvasRenderingContext2D.cpp:
     17        (WebCore::CanvasRenderingContext2D::createPattern):
     18
    1192014-05-06  Jer Noble  <jer.noble@apple.com>
    220
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r168092 r168400  
    17541754
    17551755    CachedImage* cachedImage = image->cachedImage();
    1756     if (!cachedImage || !image->cachedImage()->imageForRenderer(image->renderer()))
     1756    if (!cachedImage || cachedImage->status() == CachedResource::LoadError) {
     1757        ec = INVALID_STATE_ERR;
     1758        return 0;
     1759    }
     1760
     1761    if (!image->cachedImage()->imageForRenderer(image->renderer()))
    17571762        return CanvasPattern::create(Image::nullImage(), repeatX, repeatY, true);
    17581763
Note: See TracChangeset for help on using the changeset viewer.