Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #864: don't reject createImageBitmap's promise with null #884

Merged
merged 1 commit into from Mar 23, 2016

Conversation

domenic
Copy link
Member

@domenic domenic commented Mar 15, 2016

We should file bugs (and ideally web-platform-tests) for this.

/cc @junov @xidachen

@@ -90531,7 +90540,8 @@ interface <dfn>ImageBitmapFactories</dfn> {

<li><p>If the image data is not in a supported file format (e.g. it's not actually an image at
all), or if the image data is corrupted in some fatal way such that the image dimensions cannot
be obtained, then reject the promise with null, and abort these steps.</p></li>
be obtained, then reject the promise with an <code>EncodingError</code>, and abort these
steps.</p></li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EncodingError was originally for the Encoding Standard's API, but I guess it's fine to use it for other things.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, "The encoding operation (either encoded or decoding) failed" seemed general enough.

@annevk
Copy link
Member

annevk commented Mar 22, 2016

The two exceptions should be followed by " exception" I think.

@domenic
Copy link
Member Author

domenic commented Mar 22, 2016

Fixed and also fixed a number of other places my regexp found.

@domenic
Copy link
Member Author

domenic commented Mar 22, 2016

Testing in Firefox they don't reject with null, but instead with one of those weird nonstandard Firefox exceptions: NS_ERROR_NOT_AVAILABLE.

http://jsbin.com/defusafobu/edit?html,console,output

@@ -90484,7 +90493,8 @@ interface <dfn>ImageBitmapFactories</dfn> {

<li><p>If the image data is not in a supported file format (e.g. it's not actually an image at
all), or if the image data is corrupted in some fatal way such that the image dimensions cannot
be obtained, then reject the promise with null, and abort these steps.</p></li>
be obtained, then reject the promise with an <code>EncodingError</code> exception, and abort
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would make sense to have more consistency between the handling of blobs and img elements (described above). Currently, with an img, when we encounter a file that is decodable but does not represent bitmap media, an InvalidStateError is thrown. Suggestion: perhaps we should separate these two cases: unsupported media type (e.g. vector graphics) -> InvalidStateError; undecodable media -> EncodingError

@domenic
Copy link
Member Author

domenic commented Mar 22, 2016

@junov rebased and separated out the two conditions.

graphic or it's not an image at all), then reject the promise with an
<code>InvalidStateError</code> exception, and abort these steps.</p></li>

<li><p>If the image data is corrupted in some fatal way such that the image dimensions cannot
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the section "If image is an img element", should we have something equivalent to this? Example: If the img is in the broken state (data-x="img-error"), the promise should be rejected with an EncodingError exception.

Right now, the the broken state case gets handled by a catch-all clause for handling imgs that are not in the completely available state. It rejects with an InvalidStateError.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. But won't broken also be the case for e.g. <img src="http://non-existent.com/non-existent-url">?

Maybe we should just collapse these all into InvalidStateError. (Including both of my newly-introduced NotReadableError and EncodingError instances.) I don't anticipate code being able to usefully branch on the type of the resulting error, and that seems simpler.

@domenic
Copy link
Member Author

domenic commented Mar 22, 2016

@junov pushed two commits representing two possibilities:

@junov
Copy link
Member

junov commented Mar 22, 2016

IMHO, not rejecting with null and using more specific exceptions are two separate issues, which should perhaps be dealt with separately. If we start using EncodingError in this spec, we should probably use it everywhere where it makes sense, and not just in the place we're looking at right now. WDYT?

@domenic
Copy link
Member Author

domenic commented Mar 22, 2016

That makes sense to me, and is probably a better way of phrasing my misgivings. So you think that the diff master...132cf49 which just switches from null to InvalidStateError is good?

@junov
Copy link
Member

junov commented Mar 22, 2016

yep, lgtm

@domenic
Copy link
Member Author

domenic commented Mar 22, 2016

Great! Will let @annevk give it a look-over to be sure.

@domenic domenic assigned annevk and unassigned junov Mar 22, 2016
As a drive-by fix, be more consistent about suffixing exception names.
occurs during reading of the object</span>, then reject the promise with null, and abort these
steps.</p></li>
occurs during reading of the object</span>, then reject the promise with a
<code>InvalidStateError</code> exception, and abort these steps.</p></li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an*, but I'll fix that.

@annevk annevk merged commit d09b045 into master Mar 23, 2016
@zcorpan zcorpan deleted the createimagebitmap-promise branch March 23, 2016 12:26
@smaug----
Copy link
Collaborator

smaug---- commented Aug 9, 2016

Testing in Firefox they don't reject with null, but instead with one of those weird nonstandard Firefox exceptions: NS_ERROR_NOT_AVAILABLE.

I wonder which version you've tested.
Nightly has rejected with null since end of January
https://bugzilla.mozilla.org/show_bug.cgi?id=1239300#c12

@domenic so, please use Nightly ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

4 participants