-
Notifications
You must be signed in to change notification settings - Fork 164
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
Don't use enums, because they throw #633
Comments
Are you thinking they need to be switched to strings with sets of known values defined in the spec? |
yes, exactly. |
that won't work for the enums we get from other specs like Orientation Lock and Service Workers, so we better find a way to handle the throws |
I don't have a good solution for this. I wouldn't really be in favor of modifying WebIDL to not throw for enums, so we might just have to maintain our own copy of supported values. |
I have been playing around with manifest parsing via WebIDL spec recently and may have some options that are hopefully useful to you. First off, for WebAppManifest as currently defined, I found the following situations which can potentially throw TypeErrors:
The first can be ignored for WebAppManifests as the values come from parsing JSON which should not be able to produce Symbols. The other two can arise and formally would invalidate the WebAppManifest, if WebIDL conversion is followed strictly. My suggestion:
There is also relevant discussion going in #710 currently, which probably should better be continued here? |
The problem is that we already have thousands of manifests in the wild that are depending on the fault-tolerant behavior.
I'm not sure that is true. In Gecko, we don't do any IDL conversion. Additionally, It's too much work to have a custom IDL implementation for this or other formats. It's just not a viable thing.
This doesn't sounds like it would lead to very interoperable behavior.
Probably :) |
Yeah I don't think letting error handling be up to user agents is a good idea. What I said on #710:
@marcoscaceres response:
I agree if we can avoid using JavaScript conversion at all for these JSON documents, that would be good. But I do think we want to declare a complex JSON document format in a declarative language, not as an algorithm, and WebIDL seems the most appropriate. We could also use JSON Schema which is specifically designed for this use case (but I'm not familiar with the details, and a quick scan of the documents doesn't seem to let us process a JSON object being lenient about invalid values; it's either valid or not). |
The JSON Schema allows for conditional subschemas which should make it possible to assign alternatives for cases where WebIDL throws. Referencing WebIDL definitions for use in the JSON schema outside of the specification may require some thought this way, but this looks good to me on first impression. |
We've tried schema languages in the past and they don't really work well on web scale - authors make too many mistakes, and we fall into a "the tools will save us" situation. I also don't want to maintain a JSON Schema (or similar) implementation in Gecko :( ... I know, I'm super lazy.
What we had originally wasn't bad - and quite fault tolerant. I think everyone is using a custom processor for Web Manifest, so that would most closely match reality. |
In 32b497c, I (finally) got rid of the IDL and converted the "processed manifest" to an (Infra) ordered map. |
We need to drop all the enums, as they throw.
The text was updated successfully, but these errors were encountered: