w3c / w3c/webcodecs

Spec differentiates between ImageDecoder initialization with unsupported non-image MIME type and an unsupported image MIME type

Open
#794 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
1.3k
Forks
194
Avg merge
1d 13h
Merged PRs (30d)
3

Description

There is a WPT that checks for a NotSupportedError promise rejection when the MIME type "junk/type"
https://github.com/web-platform-tests/wpt/blob/53a1437dcfc754a3dc8ffe0bd34f9a6524e49fcf/webcodecs/image-decoder.https.any.js#L163

This conflicts with a strict reading of the spec:

From https://w3c.github.io/webcodecs/#imagedecoder-constructor:
"If init is not valid ImageDecoderInit, throw a TypeError."

From https://w3c.github.io/webcodecs/#valid-imagedecoderinit:
"1. If type is not a valid image MIME type, return false."

From https://w3c.github.io/webcodecs/#valid-image-mime-type:
"A valid image MIME type is a string that is a valid MIME type string and for which the type, per Section 8.3.1 of [RFC9110], is image."

From https://w3c.github.io/webcodecs/#configure-the-image-decoder
"1. Let supported be the result of running the Check Type Support algorithm with init.type."
"2. If supported is false, run the Close ImageDecoder algorithm with a NotSupportedError DOMException and return "processed"."

If we put all this together, my reading of it says that if the MIME type supplied is anything besides "image/XXX", we should throw a TypeError in the ImageDecoder constructor. If we don't support XXX, then we should reject the ImageDecoder [[completed promise]] and ImageTrackList [[ready promise]] with NotSupportedError.

Is this what we want? I don't have any strong feelings either way, just want to understand if the test is wrong, or if this is an inconsistency in the spec that we want to correct.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the ImageDecoder constructor, valid ImageDecoderInit, valid image MIME type, and Configure the ImageDecoder sections linked in the issue. Compare their stated errors with the WPT at image-decoder.https.any.js line 163. Done means reaching agreement on whether the specification or test needs correction and documenting the resolved behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
html
Domain
api, testing, web-dev
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.