Bug 162659 - Add support for DOMTokenList.supports()
Summary: Add support for DOMTokenList.supports()
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL: https://dom.spec.whatwg.org/#dom-domt...
Keywords: WebExposed
Depends on:
Blocks:
 
Reported: 2016-09-27 20:43 PDT by Chris Dumez
Modified: 2016-09-29 14:31 PDT (History)
12 users (show)

See Also:


Attachments
WIP Patch (12.40 KB, patch)
2016-09-27 22:06 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews102 for mac-yosemite (885.86 KB, application/zip)
2016-09-27 23:11 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews104 for mac-yosemite-wk2 (935.03 KB, application/zip)
2016-09-27 23:14 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews114 for mac-yosemite (1.38 MB, application/zip)
2016-09-27 23:19 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews123 for ios-simulator-elcapitan-wk2 (8.08 MB, application/zip)
2016-09-27 23:25 PDT, Build Bot
no flags Details
Patch (25.93 KB, patch)
2016-09-28 09:30 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (25.94 KB, patch)
2016-09-28 09:31 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (25.22 KB, patch)
2016-09-28 13:22 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (25.21 KB, patch)
2016-09-28 15:43 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (8.84 KB, patch)
2016-09-29 13:25 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2016-09-27 20:43:09 PDT
Add support for DOMTokenList.supports():
- https://dom.spec.whatwg.org/#dom-domtokenlist-supports

Firefox and Chrome already implement it.
Comment 1 Chris Dumez 2016-09-27 22:06:58 PDT
Created attachment 290057 [details]
WIP Patch
Comment 2 Build Bot 2016-09-27 23:11:22 PDT
Comment on attachment 290057 [details]
WIP Patch

Attachment 290057 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/2159548

New failing tests:
imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-rellist.html
Comment 3 Build Bot 2016-09-27 23:11:26 PDT
Created attachment 290059 [details]
Archive of layout-test-results from ews102 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews102  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 4 Build Bot 2016-09-27 23:14:22 PDT
Comment on attachment 290057 [details]
WIP Patch

Attachment 290057 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/2159551

New failing tests:
imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-rellist.html
Comment 5 Build Bot 2016-09-27 23:14:28 PDT
Created attachment 290060 [details]
Archive of layout-test-results from ews104 for mac-yosemite-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews104  Port: mac-yosemite-wk2  Platform: Mac OS X 10.10.5
Comment 6 Build Bot 2016-09-27 23:19:29 PDT
Comment on attachment 290057 [details]
WIP Patch

Attachment 290057 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/2159555

New failing tests:
imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-rellist.html
Comment 7 Build Bot 2016-09-27 23:19:34 PDT
Created attachment 290061 [details]
Archive of layout-test-results from ews114 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews114  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 8 Build Bot 2016-09-27 23:25:02 PDT
Comment on attachment 290057 [details]
WIP Patch

Attachment 290057 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/2159554

New failing tests:
imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-rellist.html
Comment 9 Build Bot 2016-09-27 23:25:08 PDT
Created attachment 290062 [details]
Archive of layout-test-results from ews123 for ios-simulator-elcapitan-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews123  Port: ios-simulator-elcapitan-wk2  Platform: Mac OS X 10.11.6
Comment 10 Chris Dumez 2016-09-28 09:30:25 PDT
Created attachment 290093 [details]
Patch
Comment 11 Chris Dumez 2016-09-28 09:31:45 PDT
Created attachment 290094 [details]
Patch
Comment 12 Alex Christensen 2016-09-28 11:24:34 PDT
Comment on attachment 290094 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=290094&action=review

> Source/WebCore/dom/SecurityContext.cpp:90
> +    static NeverDestroyed<Vector<AtomicString>> supportedPolicies = Vector<AtomicString>({

Is a Vector faster than a HashSet?

> Source/WebCore/html/HTMLAnchorElement.cpp:307
> +            return token == "noreferrer";

Should this be a case-sensitive comparison?  I don't see any tests with nOrEfErReR
Comment 13 Chris Dumez 2016-09-28 12:18:16 PDT
Comment on attachment 290094 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=290094&action=review

>> Source/WebCore/dom/SecurityContext.cpp:90
>> +    static NeverDestroyed<Vector<AtomicString>> supportedPolicies = Vector<AtomicString>({
> 
> Is a Vector faster than a HashSet?

This is only used by DOMTokenList.supports() and therefore, I don't think performance is a big issue. Also, given the small amount of values, I am not sure it is worth having a HashSet.

>> Source/WebCore/html/HTMLAnchorElement.cpp:307
>> +            return token == "noreferrer";
> 
> Should this be a case-sensitive comparison?  I don't see any tests with nOrEfErReR

Yes, because DOMTokenList always converts to ASCII Lowercase before calling this function. And yes, this is covered by my layout test.
Comment 14 Ryosuke Niwa 2016-09-28 12:45:55 PDT
Comment on attachment 290094 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=290094&action=review

>>> Source/WebCore/dom/SecurityContext.cpp:90
>>> +    static NeverDestroyed<Vector<AtomicString>> supportedPolicies = Vector<AtomicString>({
>> 
>> Is a Vector faster than a HashSet?
> 
> This is only used by DOMTokenList.supports() and therefore, I don't think performance is a big issue. Also, given the small amount of values, I am not sure it is worth having a HashSet.

Can't we just use an array or a Vector with 6 inline buffer instead?

> Source/WebCore/dom/SecurityContext.cpp:98
> +    });
> +    return supportedPolicies.get().contains(policy);

I got a feeling that having a series of if-else with equalLettersIgnoringASCIICase would be just as fast or faster and will be more readable.

>>> Source/WebCore/html/HTMLAnchorElement.cpp:307
>>> +            return token == "noreferrer";
>> 
>> Should this be a case-sensitive comparison?  I don't see any tests with nOrEfErReR
> 
> Yes, because DOMTokenList always converts to ASCII Lowercase before calling this function. And yes, this is covered by my layout test.

Perhaps we should rename token to tokenInLowerCase instead to make the semantics clear?

> Source/WebCore/html/LinkRelAttribute.cpp:93
> +    static NeverDestroyed<Vector<AtomicString>> supportedAttributes = Vector<AtomicString>({

Ditto about using an array or Vector with an inline buffer.
Comment 15 Chris Dumez 2016-09-28 13:22:53 PDT
Created attachment 290111 [details]
Patch
Comment 16 WebKit Commit Bot 2016-09-28 14:42:49 PDT
The commit-queue encountered the following flaky tests while processing attachment 290111 [details]:

The commit-queue is continuing to process your patch.
Comment 17 Darin Adler 2016-09-28 14:55:54 PDT
Comment on attachment 290094 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=290094&action=review

> Source/WebCore/dom/SecurityContext.cpp:101
> +// Keep SecurityContext::isSupportedSanboxPolicy() in sync when updating this function.

Typo: "Sanbox".

> Source/WebCore/dom/SecurityContext.h:78
> +    static bool isSupportedSanboxPolicy(const AtomicString&);

Same typo.
Comment 18 Chris Dumez 2016-09-28 14:57:12 PDT
(In reply to comment #17)
> Comment on attachment 290094 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=290094&action=review
> 
> > Source/WebCore/dom/SecurityContext.cpp:101
> > +// Keep SecurityContext::isSupportedSanboxPolicy() in sync when updating this function.
> 
> Typo: "Sanbox".
> 
> > Source/WebCore/dom/SecurityContext.h:78
> > +    static bool isSupportedSanboxPolicy(const AtomicString&);
> 
> Same typo.

Good catch, thanks. I'll fix before landing.
Comment 19 Chris Dumez 2016-09-28 15:43:30 PDT
Created attachment 290131 [details]
Patch
Comment 20 WebKit Commit Bot 2016-09-28 16:48:59 PDT
Comment on attachment 290131 [details]
Patch

Rejecting attachment 290131 [details] from commit-queue.

Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.webkit.org', '--bot-id=webkit-cq-03', 'land-attachment', '--force-clean', '--non-interactive', '--parent-command=commit-queue', 290131, '--port=mac']" exit_code: 2 cwd: /Volumes/Data/EWS/WebKit

Last 500 characters of output:
fs/remotes/origin/master/.rev_map.268f45cc-cd09-0410-ab3c-d52691b4dbfc ...
Currently at 206556 = 7da025ee623088d327a6ff456168a7648dce595b
r206558 = d73653b62c23324aac5711cdb695e63dbc5e6c27
r206559 = 7de3e4cfa0f76718beccfe355a38effec9beb5dd
r206560 = 83022e4582cceef3f2aa18a5d5e4962c74a655a2
Done rebuilding .git/svn/refs/remotes/origin/master/.rev_map.268f45cc-cd09-0410-ab3c-d52691b4dbfc
First, rewinding head to replay your work on top of it...
Fast-forwarded master to refs/remotes/origin/master.

Full output: http://webkit-queues.webkit.org/results/2164461
Comment 21 Chris Dumez 2016-09-28 16:52:14 PDT
Committed r206561: <http://trac.webkit.org/changeset/206561>
Comment 22 Darin Adler 2016-09-29 12:35:18 PDT
Comment on attachment 290131 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=290131&action=review

A couple post-landing comments.

> Source/WebCore/dom/SecurityContext.cpp:92
> +    static const char* supportedPolicies[] = {
> +        "allow-forms", "allow-same-origin", "allow-scripts", "allow-top-navigation", "allow-pointer-lock", "allow-popups"
> +    };

This should have one most const in it:

    static const char* const supportedPolicies[] = {
        // ...
    };

> Source/WebCore/dom/SecurityContext.h:78
> +    static bool isSupportedSandboxPolicy(const String&);

This should take a StringView instead of a String.

> Source/WebCore/html/DOMTokenList.h:52
> +    bool supports(const String& token, ExceptionCode&);

I think this should take a StringView instead of a String.

> Source/WebCore/html/DOMTokenList.h:77
> +    WTF::Function<bool(const String&)> m_isSupportedToken;

I think this function should take a StringView instead of a string.

> Source/WebCore/html/LinkRelAttribute.cpp:93
> +    static const char* supportedAttributes[] = {

Need another const here.

> Source/WebCore/html/LinkRelAttribute.h:56
> +    static bool isSupported(const String&);

StringView
Comment 23 Chris Dumez 2016-09-29 13:24:56 PDT
Reopening to attach new patch.
Comment 24 Chris Dumez 2016-09-29 13:25:00 PDT
Created attachment 290238 [details]
Patch
Comment 25 WebKit Commit Bot 2016-09-29 14:31:08 PDT
Comment on attachment 290238 [details]
Patch

Clearing flags on attachment: 290238

Committed r206616: <http://trac.webkit.org/changeset/206616>
Comment 26 WebKit Commit Bot 2016-09-29 14:31:15 PDT
All reviewed patches have been landed.  Closing bug.