Bug 132407 - Calling createPattern with a broken image must throw an invalidstate error
Summary: Calling createPattern with a broken image must throw an invalidstate error
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Canvas (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Rik Cabanier
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-30 16:14 PDT by Rik Cabanier
Modified: 2014-05-06 19:26 PDT (History)
7 users (show)

See Also:


Attachments
Patch (4.14 KB, patch)
2014-04-30 16:19 PDT, Rik Cabanier
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from webkit-ews-13 for mac-mountainlion-wk2 (584.63 KB, application/zip)
2014-04-30 18:49 PDT, Build Bot
no flags Details
Patch (8.11 KB, patch)
2014-04-30 20:31 PDT, Rik Cabanier
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from webkit-ews-10 for mac-mountainlion-wk2 (628.86 KB, application/zip)
2014-04-30 21:37 PDT, Build Bot
no flags Details
Archive of layout-test-results from webkit-ews-09 for mac-mountainlion-wk2 (625.75 KB, application/zip)
2014-04-30 22:31 PDT, Build Bot
no flags Details
Patch (10.73 KB, patch)
2014-04-30 23:27 PDT, Rik Cabanier
no flags Details | Formatted Diff | Diff
Patch (9.54 KB, patch)
2014-05-06 16:44 PDT, Rik Cabanier
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Comment 1 Rik Cabanier 2014-04-30 16:19:40 PDT
Created attachment 230534 [details]
Patch
Comment 2 Build Bot 2014-04-30 18:49:51 PDT
Comment on attachment 230534 [details]
Patch

Attachment 230534 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/6656302818263040

New failing tests:
canvas/philip/tests/2d.pattern.image.incomplete.empty.html
fast/canvas/canvas-empty-image-pattern.html
fast/dom/gc-9.html
Comment 3 Build Bot 2014-04-30 18:49:54 PDT
Created attachment 230554 [details]
Archive of layout-test-results from webkit-ews-13 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-13  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.5
Comment 4 Rik Cabanier 2014-04-30 20:31:20 PDT
Created attachment 230557 [details]
Patch
Comment 5 Build Bot 2014-04-30 21:37:26 PDT
Comment on attachment 230557 [details]
Patch

Attachment 230557 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/4690787807789056

New failing tests:
fast/dom/gc-9.html
Comment 6 Build Bot 2014-04-30 21:37:29 PDT
Created attachment 230559 [details]
Archive of layout-test-results from webkit-ews-10 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-10  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.5
Comment 7 Build Bot 2014-04-30 22:31:07 PDT
Comment on attachment 230557 [details]
Patch

Attachment 230557 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/5324877452017664

New failing tests:
fast/dom/gc-9.html
Comment 8 Build Bot 2014-04-30 22:31:13 PDT
Created attachment 230562 [details]
Archive of layout-test-results from webkit-ews-09 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-09  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.5
Comment 9 Rik Cabanier 2014-04-30 23:27:18 PDT
Created attachment 230564 [details]
Patch
Comment 10 Andreas Kling 2014-05-01 12:23:34 PDT
Comment on attachment 230564 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=230564&action=review

> Source/WebCore/ChangeLog:13
> +        * canvas/philip/tests/2d.pattern.image.broken.html:
> +        * canvas/philip/tests/2d.pattern.image.incomplete.empty.html:

This is an imported test suite; do your changes match upstream?
Comment 11 Rik Cabanier 2014-05-01 13:20:52 PDT
(In reply to comment #10)
> (From update of attachment 230564 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=230564&action=review
> 
> > Source/WebCore/ChangeLog:13
> > +        * canvas/philip/tests/2d.pattern.image.broken.html:
> > +        * canvas/philip/tests/2d.pattern.image.incomplete.empty.html:
> 
> This is an imported test suite; do your changes match upstream?

yes,this test suite is now maintained by the w3c. I updated this test yesterday but it needs to be regenerated.
see http://www.w3c-test.org/2dcontext/fill-and-stroke-styles/2d.pattern.image.broken.html 

I'm looking over the cases where WK is not spec compliant
Comment 12 Dirk Schulze 2014-05-01 14:27:22 PDT
Comment on attachment 230564 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=230564&action=review

> LayoutTests/fast/canvas/canvas-empty-image-pattern.html:2
> +<title>Canvas test: filling a pattern with an empty image should throw an exception.</title>

This is a crash test, why do you change it?

> LayoutTests/fast/dom/gc-9-expected.txt:-15
> -PASS: document.getElementsByTagName('canvas')[0].getContext('2d').createPattern(new Image(), 'no-repeat').myCustomProperty should be undefined and is.

Why do the pass messages disappear?

> LayoutTests/fast/dom/gc-9.html:-124
> -    [ "document.getElementsByTagName('canvas')[0].getContext('2d').createPattern(new Image(), 'no-repeat')" ], // CanvasPattern

Why did you remove this test?
Comment 13 Rik Cabanier 2014-05-01 15:01:02 PDT
Comment on attachment 230564 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=230564&action=review

>> LayoutTests/fast/canvas/canvas-empty-image-pattern.html:2
>> +<title>Canvas test: filling a pattern with an empty image should throw an exception.</title>
> 
> This is a crash test, why do you change it?

Not sure if I follow. The test will now throw an exception. Should I remove it completely?

>> LayoutTests/fast/dom/gc-9-expected.txt:-15
>> -PASS: document.getElementsByTagName('canvas')[0].getContext('2d').createPattern(new Image(), 'no-repeat').myCustomProperty should be undefined and is.
> 
> Why do the pass messages disappear?

because I removed the test that creates an empty image.

>> LayoutTests/fast/dom/gc-9.html:-124
>> -    [ "document.getElementsByTagName('canvas')[0].getContext('2d').createPattern(new Image(), 'no-repeat')" ], // CanvasPattern
> 
> Why did you remove this test?

createPattern(new Image()) will throw an exception as per the spec so this test no longer works.
Comment 14 Dirk Schulze 2014-05-06 01:49:28 PDT
Comment on attachment 230564 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=230564&action=review

recover canvas-empty-image-pattern.html and I am r+ the patch.

> LayoutTests/canvas/philip/tests/2d.pattern.image.incomplete.empty.html:23
> +var _thrown = undefined;
> +try{
> +  ctx.createPattern(img, 'repeat');
> +}catch(e) {
> +  _thrown = e;
> +}
> +_assert(_thrown && _thrown.name == "InvalidStateError" && _thrown.code == DOMException.INVALID_STATE_ERR, "should throw InvalidStateError");

You assured before that these changes were made in the official test suite as well, right? Then I am fine with the changes.

>>> LayoutTests/fast/canvas/canvas-empty-image-pattern.html:2
>>> +<title>Canvas test: filling a pattern with an empty image should throw an exception.</title>
>> 
>> This is a crash test, why do you change it?
> 
> Not sure if I follow. The test will now throw an exception. Should I remove it completely?

Not, just leave the comment unchanged.

> LayoutTests/fast/canvas/canvas-empty-image-pattern.html:4
> +<script src="../../resources/js-test-pre.js"></script>

don't include more things. crash tests are done to demonstrate that we do not fail again under the same circumstances.

> LayoutTests/fast/canvas/canvas-empty-image-pattern.html:16
> +var _thrown = undefined;
> +try {
> +  canvas.fillStyle = canvas.createPattern(new Image, "repeat")
> +} catch(e) {
> +  _thrown = e;
> +}
> +shouldBe('_thrown && _thrown.name == "InvalidStateError" && _thrown.code == DOMException.INVALID_STATE_ERR', 'true');

Just let it throw and update the expected file.

> LayoutTests/fast/canvas/canvas-empty-image-pattern.html:19
> +<script src="../../resources/js-test-post.js"></script>

Ditto.

>>> LayoutTests/fast/dom/gc-9.html:-124
>>> -    [ "document.getElementsByTagName('canvas')[0].getContext('2d').createPattern(new Image(), 'no-repeat')" ], // CanvasPattern
>> 
>> Why did you remove this test?
> 
> createPattern(new Image()) will throw an exception as per the spec so this test no longer works.

Ok.
Comment 15 Rik Cabanier 2014-05-06 16:44:34 PDT
Created attachment 230949 [details]
Patch
Comment 16 Darin Adler 2014-05-06 17:58:56 PDT
Comment on attachment 230949 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=230949&action=review

> Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp:1756
> +    if (!cachedImage || cachedImage->status() == CachedResource::LoadError) {

Does the test case cover the "!cachedImage" case or only the LoadError case?
Comment 17 Rik Cabanier 2014-05-06 18:53:36 PDT
Comment on attachment 230949 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=230949&action=review

>> Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp:1756
>> +    if (!cachedImage || cachedImage->status() == CachedResource::LoadError) {
> 
> Does the test case cover the "!cachedImage" case or only the LoadError case?

Just the LoadError.
When is there no cachedImage?
Comment 18 WebKit Commit Bot 2014-05-06 19:26:49 PDT
Comment on attachment 230949 [details]
Patch

Clearing flags on attachment: 230949

Committed r168400: <http://trac.webkit.org/changeset/168400>
Comment 19 WebKit Commit Bot 2014-05-06 19:26:54 PDT
All reviewed patches have been landed.  Closing bug.