2d.pattern.image.broken test seems to pass intermittently
Categories
(Core :: Graphics: Canvas2D, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox75 | --- | fixed |
People
(Reporter: jgraham, Assigned: bzbarsky)
Details
Attachments
(2 files)
| Assignee | ||
Comment 1•6 years ago
|
||
At this point, this test is just wrong. Per spec at https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createpattern a unusable image means null is returned, which is what we do.
Comment 2•6 years ago
|
||
This appears to be the portion of the HTML Standard which is being relied on for the expectation for an exception being thrown re "Broken" https://html.spec.whatwg.org/multipage/images.html#img-error (see https://bugzilla.mozilla.org/show_bug.cgi?id=1614225)
However, Firefox throws no such error. null is returned.
var img = new Image;
img.src = "data:,";
img.onerror = e => {
console.log(e);
const canvas = document.createElement("canvas");
const ctx = canvas.getContext("2d");
try {
console.dir(ctx.createPattern(img, "repeat"));
} catch (e) {
console.error(e);
}
}
Comment 3•6 years ago
|
||
The same code at Chromium 81 does throw an exception
DOMException: Failed to execute 'createPattern' on 'CanvasRenderingContext2D': Source image is in the 'broken' state.
at Image.img.onerror (<anonymous>:8:25)
Comment 4•6 years ago
|
||
The conclusion reached here is that
- the image used in WPT is not "Broken" enough to throw an error at modern browsers, though does log this error (
Fatal error reading PNG image file: IDAT: CRC error) at Ristretto Image Viewer at *nix. - Firefox returns
null, then stops. - Chromium does not return
nulland throws the exception per "Broken" part of the specification.
meaning the browsers, Firefox and Chromium, respectively, have some parts of implementation correct, yet not all parts, and the implementations are not consistent at all, making testing if not difficult, a trial and error to compose a single test that outputs the expected result for each browser.
If there is any ambiguity in the specification as to which part is controlling, or if the "Broken" part of specification is controlling at all
https://bugzilla.mozilla.org/show_bug.cgi?id=1614225#c7
It does not seem clear to me on the definition of broken image as it applies to this testcase for reasons I outlined in comment 3 (https://bugzilla.mozilla.org/show_bug.cgi?id=1614225#c3).
perhaps now is a time that can adjust both the specification and the televant test.
| Assignee | ||
Comment 5•6 years ago
|
||
Per spec, createPattern never throws InvalidStateError. It can return null if
the image is not usable (as here) or throw SyntaxError if the second arg is not
a recognized value, but that's it.
Updated•6 years ago
|
Comment 6•6 years ago
|
||
(In reply to Boris Zbarsky [:bzbarsky, bz on IRC] from comment #1)
At this point, this test is just wrong. Per spec at https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createpattern a unusable image means null is returned, which is what we do.
In fact, following the link from "checking the usability"
To check the usability of the image argument, where image is a CanvasImageSource object, run these steps:
Switch on image:
HTMLOrSVGImageElement
If image's current request's state is broken, then throw an "InvalidStateError" DOMException.
Firefox behaviour is not in conformance with the HTML Standard.
According to the processsing model at step 1. the InvalidStateError exception should be thrown before null is returned at step 2.
Comment 7•6 years ago
|
||
Searched for though did not locate this bug before filing https://bugzilla.mozilla.org/show_bug.cgi?id=1614225 which is probably a duplicate of this bug.
Comment 9•6 years ago
|
||
(In reply to Boris Zbarsky [:bzbarsky, bz on IRC] from comment #5)
Created attachment 9126974 [details]
Bug 1016482. Fix broken createPattern test.Per spec, createPattern never throws InvalidStateError. It can return null if
the image is not usable (as here) or throw SyntaxError if the second arg is not
a recognized value, but that's it.
This
_assertSame(ctx.createPattern(img, 'repeat'), null, "ctx.createPattern(img, 'repeat')", "null");
is wrong per the specification section that you are referring to.
If image's current request's state is broken, then throw an "InvalidStateError" DOMException.
Comment 10•6 years ago
|
||
The change at https://phabricator.services.mozilla.com/D63030 for WPT test essentially is hiding the Firefox bug for handling usability of the image at https://html.spec.whatwg.org/multipage/canvas.html#check-the-usability-of-the-image-argument. Not a viable resolution to the bug or the test.
| Assignee | ||
Comment 11•6 years ago
|
||
the image used in WPT is not "Broken" enough to throw an error at modern browsers
Ah, indeed. I was specifically talking about the image in question in this test, which does not lead to a "current request's state is broken" state, because the image has a valid header (including size information) and it's just the image data that's not decodable. So it falls into the "image is not fully decodable" case. See definitions of the states at https://html.spec.whatwg.org/multipage/images.html#img-req-state
So for this specific image, my test fix is correct. I will correct the commit message to make this clear.
For the 'data:,' case, I would have expected it to fall into the "broken" case. I'll take a look at that later, but it's not this bug, not this bug's testcase, and not a duplicate of this bug...
| Comment hidden (offtopic) |
| Comment hidden (offtopic) |
| Comment hidden (offtopic) |
Comment 15•6 years ago
|
||
| Comment hidden (offtopic) |
| Assignee | ||
Comment 19•6 years ago
|
||
I'll take a look at that later, but it's not this bug, not this bug's testcase, and not a duplicate of this bug...
And to be clear, I reopened bug 1614225 to track that.
Comment 20•6 years ago
|
||
| bugherder | ||
Description
•