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

Implement DOMTokenList.supports API #24965

Open
pshaughn opened this issue Nov 30, 2019 · 5 comments
Open

Implement DOMTokenList.supports API #24965

pshaughn opened this issue Nov 30, 2019 · 5 comments

Comments

@pshaughn
Copy link
Member

@pshaughn pshaughn commented Nov 30, 2019

html/semantics/embedded-content/the-iframe-element/sandbox-ascii-case-insensitive incidentally fails, separately from what it's trying to test, because there's no .supports on iframe.sandbox. It looks like Servo's IDL doesn't even mention it; https://dom.spec.whatwg.org/#interface-domtokenlist does.

@jdm jdm added the A-content/dom label Nov 30, 2019
@jdm jdm added this to To do in web-platform-test failures via automation Nov 30, 2019
@pshaughn
Copy link
Member Author

@pshaughn pshaughn commented Dec 4, 2019

html/semantics/document-metadata/the-link-element/link-rellist.html also wants .supports.

@pshaughn
Copy link
Member Author

@pshaughn pshaughn commented Jan 8, 2020

Every attribute that can be the associated attribute of a DOMTokenList defines a set of "supported tokens" for use in feature-sniffing, e.g. https://html.spec.whatwg.org/multipage/forms.html#attr-form-rel defines them for the rel attribute of a form and https://html.spec.whatwg.org/#attr-hyperlink-rel defines slightly different ones for the rel attribute of an anchor. Since the purpose is feature-sniffing, we're explicitly only supposed to include the ones the browser actually implements, not ones that we'd be ignoring; it might be desirable to have some well-defined way of keeping it in sync with implementation progress.

@jdm
Copy link
Member

@jdm jdm commented Jul 13, 2020

To represent the validation steps when there is a static list of supported keywords, we should add a new optional argument to DOMTokenList::new (&'static [&'static str]). Whenever DOMTokenList::new is called for the following token lists, the caller should provide the list as an argument.

  • HTMLAnchorElement.relList: keyword list ("noopener", "noreferrer", "opener")
  • HTMLLinkElement.relList: keyword list ("alternate", "stylesheet", "icon", "apple-touch-icon")
  • Element.classList: no list
  • HTMLAreaElement.relList: keyword list (empty list)
  • HMTLIFrameElement.sandbox: keyword list ("allow-same-origin", "allow-forms", "allow-pointer-lock", "allow-popups", "allow-scripts", "allow-top-navigation")

When implementing DOMTokenList::supports, if no list was provided then any we should compare the provided token against the tokens in the element's attribute. Otherwise, we should use the list of provided tokens from the constructor and compare the provided token against that.

Spec:

Code:

  • components/script/dom/webidls/DOMTokenList.webidl
  • components/script/dom/domtokenlist.rs

Tests:

  • ./mach test-wpt tests/wpt/web-platform-tests/html/semantics/rellist-feature-detection.html
  • ./mach test-wpt tests/wpt/web-platform-tests/html/dom/idlharness.https.html

We'll need to update the corresponding INI files (tests/wpt/metadata/html/semantics/rellist-feature-detection.html.ini, tests/wpt/metadata/html/dom/idlharness.https.html.ini) to remove the expected failures after fixing this.

@jdm jdm changed the title WPT expects DOMTokenList.supports Implement DOMTokenList.supports API Jul 13, 2020
@jdm
Copy link
Member

@jdm jdm commented Jul 13, 2020

This should also fix #27251 and #25769.

@Nicklas-Carpenter
Copy link

@Nicklas-Carpenter Nicklas-Carpenter commented Jul 19, 2020

I've looked into this issue a bit and would be willing pick it up.

@CYBAI CYBAI added the C-assigned label Jul 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.