Bug 160183 - DOMTokenList should be iterable
Summary: DOMTokenList should be iterable
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Bindings (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: WebExposed
Depends on:
Blocks:
 
Reported: 2016-07-25 19:49 PDT by Chris Dumez
Modified: 2016-07-26 11:02 PDT (History)
6 users (show)

See Also:


Attachments
Patch (18.96 KB, patch)
2016-07-26 09:29 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch for landing (19.53 KB, patch)
2016-07-26 10:31 PDT, youenn fablet
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-07-25 19:49:47 PDT
DOMTokenList should be iterable:
- https://dom.spec.whatwg.org/#interface-domtokenlist

Chrome agrees with the specification.
Comment 1 Chris Dumez 2016-07-25 19:50:46 PDT
@youennf: Feel free to take if you have time given that you know this better than I do. Otherwise, I'll do it when I find some time.
Comment 2 youenn fablet 2016-07-26 04:07:46 PDT
Patch should consist in one WebIDL line and plenty of testing lines I guess ;)
I'll try to write these.

I made a PR to simplify the testing of iterables in https://github.com/w3c/testharness.js/pull/201
Hopefully it will get merged at some point.
Comment 3 youenn fablet 2016-07-26 09:29:46 PDT
Created attachment 284598 [details]
Patch
Comment 4 Chris Dumez 2016-07-26 09:39:56 PDT
Comment on attachment 284598 [details]
Patch

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

r=me with comments.

> Source/WebCore/ChangeLog:7
> +

Please add a link to the specification.

> LayoutTests/fast/dom/domTokenListIterator.html:1
> +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">

<!DOCTYPE html>

> LayoutTests/fast/dom/domTokenListIterator.html:12
> +                testRunner.dumpAsText();

This should not be needed when you use js-test-pre.js

> LayoutTests/fast/dom/domTokenListIterator.html:17
> +            function checkItemType(item) {

There is a shouldBeType() function in js-test

> LayoutTests/fast/dom/iterable-tests.js:26
> +  shouldBe('end.done', 'true');

shouldBeTrue("end.done"); ?

> LayoutTests/fast/dom/iterable-tests.js:27
> +  shouldBe('end.value', 'undefined');

shouldBeUndefined("end.value"); ?

> LayoutTests/fast/dom/iterable-tests.js:34
> +shouldBeTrue('testedIterable.entries === entriesFunction');

shouldBe("testedIterable.entries", "entriesFunction"); ?

> LayoutTests/fast/dom/iterable-tests.js:35
> +shouldBeTrue('testedIterable.forEach === forEachFunction');

ditto

> LayoutTests/fast/dom/iterable-tests.js:36
> +shouldBeTrue('testedIterable.keys === keysFunction');

ditto

> LayoutTests/fast/dom/iterable-tests.js:37
> +shouldBeTrue('testedIterable.values === valuesFunction');

ditto

> LayoutTests/fast/dom/iterable-tests.js:117
> +    shouldBeTrue('checkItemType(v)');

shouldBeType() ?

> LayoutTests/fast/dom/iterable-tests.js:124
> +    shouldBeTrue('typeof k === "number"');

shouldBeType() ?

> LayoutTests/fast/dom/iterable-tests.js:131
> +    shouldBeTrue('typeof e[0] === "number"');

shouldBeType() ?

> LayoutTests/fast/dom/iterable-tests.js:132
> +    shouldBeTrue('e[1] === testedIterable[e[0]]');

shouldBe("e[1]", "testedIterable[e[0]]"); ?

> LayoutTests/fast/dom/nodeListIterator.html:21
> +            function checkItemType(item) {

shouldBeType() already exists in js-test-pre.js
Comment 5 Chris Dumez 2016-07-26 09:40:15 PDT
Thanks for working on this!
Comment 6 youenn fablet 2016-07-26 10:31:51 PDT
Created attachment 284602 [details]
Patch for landing
Comment 7 youenn fablet 2016-07-26 11:00:35 PDT
Thanks for the review.
I updated accordingly except for checkItemType which can handle Object and literal types.

> > LayoutTests/fast/dom/domTokenListIterator.html:17
> > +            function checkItemType(item) {
> 
> There is a shouldBeType() function in js-test


We need to handle Node items which use instanceof and string literals which use typeof.
I do not think DOMString mandates generating a String object.
Comment 8 WebKit Commit Bot 2016-07-26 11:02:09 PDT
Comment on attachment 284602 [details]
Patch for landing

Clearing flags on attachment: 284602

Committed r203728: <http://trac.webkit.org/changeset/203728>
Comment 9 WebKit Commit Bot 2016-07-26 11:02:15 PDT
All reviewed patches have been landed.  Closing bug.