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

Why do we have super-permissive ExtendedAttribute grammar? #574

Closed
saschanaz opened this issue Jul 20, 2018 · 4 comments
Closed

Why do we have super-permissive ExtendedAttribute grammar? #574

saschanaz opened this issue Jul 20, 2018 · 4 comments

Comments

@saschanaz
Copy link
Member

Section 2.13 says that any real extended attributes are matched against the better-defined five ExtendedAttribute* grammars, but then why do we have ExtendedAttribute?

I mean, should [()] be allowed, as () is a valid ExtendedAttribute?

@tobie
Copy link
Collaborator

tobie commented Jul 20, 2018

I don't know why the grammar was designed that way, tbh. Is that causing an issue for implementors?

@saschanaz
Copy link
Member Author

saschanaz commented Jul 20, 2018

The Browser Extensions spec tried to add [Identifier="string"] style extended attribute which is grammatically allowed but not legal.

[CheckAnyPermissions="browserExt"]
interface BrowserExtGlobal {
    readonly attribute Browser browser;
};

This is causing a weird situation where webidl2.js somehow thinks it's legal and parses it, and then ReSpec throws because it doesn't know about that style.

@bzbarsky
Copy link
Collaborator

The grammar is permissive so people can add extended attributes with more complicated values as needed; the Web IDL spec is not the only thing that defines extended attributes. UAs definitely use extended attributes that don't fit into the five buckets defined in the Web IDL spec in their IDL for various purposes. For example, Gecko has https://developer.mozilla.org/en-US/docs/Mozilla/WebIDL_bindings#Func which expects a fully qualified C++ function name as the value (can contain : so not an identifier) and https://developer.mozilla.org/en-US/docs/Mozilla/WebIDL_bindings#Pref which expects a string containing . as the value and so forth.

Blink looks like it has a ReflectOnly extended attribute which takes a list of strings as a value. Typical usage looks like ReflectOnly=("","no-referrer","origin","no-referrer-when-downgrade","origin-when-cross-origin","unsafe-url"). They also have things like ReflectMissing="" and ReflectInvalid="" which don't fit into the five IDL spec buckets.

WebKit has things like CallWith=ScriptState&ScriptExecutionContext in their IDL.

@saschanaz
Copy link
Member Author

I see, it's to allow extensions with arbitrary syntax. Thank you for giving existing examples!

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

No branches or pull requests

3 participants