Skip to content

Implement RadioNodeList - #9407

Merged
bors-servo merged 2 commits into
servo:masterfrom
KiChjang:radio-node-list
Jan 29, 2016
Merged

bors-servo merged 2 commits into
servo:masterfrom
KiChjang:radio-node-list

Conversation

@KiChjang

Copy link
Copy Markdown
Contributor

I also had to implement the NamedGetter for HTMLFormControlsCollection as well, since that's the only consumer of RadioNodeList and I wanted to see which wpt test passes.

Review on Reviewable

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jan 23, 2016
@KiChjang

Copy link
Copy Markdown
Contributor Author

@bors-servo try

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Trying commit 9d11ba4 with merge 6198da9...

bors-servo pushed a commit that referenced this pull request Jan 23, 2016
Implement RadioNodeList

I also had to implement the NamedGetter for HTMLFormControlsCollection as well, since that's the only consumer of RadioNodeList and I wanted to see which wpt test passes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could alternatively just return 1 or 0 in here and then just call sum() on the iterator

https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.sum

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe even better:

let count = self.collection.elements_iter().filter(|elem| {
    elem.get_string_attribute(&atom!("name")) == name
        || elem.get_string_attribute(&atom!("id")) == name
}).count()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would do that if the API is not unstable. Ideally, I would reuse this for the filter_map below, but .count() consumes the iterator so I had to repeat the entire mapping.

@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-dev

@highfive highfive added the S-tests-failed The changes caused existing tests to fail. label Jan 23, 2016
@highfive highfive removed the S-tests-failed The changes caused existing tests to fail. label Jan 23, 2016
@KiChjang

Copy link
Copy Markdown
Contributor Author
Ran 4553 tests finished in 229.0 seconds.
  • 4549 ran as expected. 1369 tests skipped.
  • 4 tests had unexpected subtest results

Tests with unexpected results:
  ▶ Unexpected subtest result in /html/infrastructure/common-dom-interfaces/collections/htmlformcontrolscollection.html:
  └ PASS [expected FAIL] The namedItem(name) must return RadioNodeList

  ▶ Unexpected subtest result in /html/infrastructure/common-dom-interfaces/collections/htmlformcontrolscollection.html:
  └ PASS [expected FAIL] The namedItem(name) must return the items with id or name attribute

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] HTMLFormControlsCollection interface: operation namedItem(DOMString)

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] RadioNodeList interface: existence and properties of interface object

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] RadioNodeList interface object length

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] RadioNodeList interface object name

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] RadioNodeList interface: existence and properties of interface prototype object

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] RadioNodeList interface: existence and properties of interface prototype object's "constructor" property

  ▶ Unexpected subtest result in /html/dom/interfaces.html:
  └ PASS [expected FAIL] RadioNodeList interface: attribute value

  ▶ Unexpected subtest result in /html/semantics/forms/the-form-element/form-elements-nameditem-01.html:
  └ PASS [expected FAIL] RadioNodeList should exist

  ▶ Unexpected subtest result in /_mozilla/mozilla/interfaces.html:
  │ FAIL [expected PASS] Interfaces exposed on the window
  │   → assert_true: If this is failing: DANGER, are you sure you want to expose the new interface RadioNodeList to all webpages as a property on the window? Do not make a change to this file without review from jdm or Ms2ger for that specific change! expected true got false
  │ 
  │ @http://web-platform.test:8000/_mozilla/mozilla/interfaces.html:253:1
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1381:20
  │ test@http://web-platform.test:8000/resources/testharness.js:495:9
  └ @http://web-platform.test:8000/_mozilla/mozilla/interfaces.html:247:1

Looking good here!

O Spiritus Sancti, in Nomine Patris, I summon @jdm or @Ms2ger to guide my hand in enabling the RadioNodeList interface.

@frewsxcv frewsxcv closed this Jan 23, 2016
@frewsxcv frewsxcv reopened this Jan 23, 2016
@nox

nox commented Jan 23, 2016

Copy link
Copy Markdown
Contributor

@KiChjang I allow you to add RadioNodeList to the list in interfaces.html.

@KiChjang
KiChjang force-pushed the radio-node-list branch 2 times, most recently from 6d75ca1 to d8102a0 Compare January 24, 2016 17:34
@KiChjang

Copy link
Copy Markdown
Contributor Author

I think this is ready to be re-reviewed, I've eliminated the extra iterator.

@nox

nox commented Jan 25, 2016

Copy link
Copy Markdown
Contributor

The code looks ok, but why are there still failing tests listed in htmlformcontrolscollection.html.ini?

@KiChjang

Copy link
Copy Markdown
Contributor Author

This is the test case that is failing:

test(function () {
  rdoList.value = "on";
  assert_equals(rdoList.value, document.getElementById("r2").value,
                "The value attribute should be the second radio input element's value.");
  assert_true(document.getElementById("r2").checked,
              "The second radio input element should be checked.");

  document.getElementById("r1").removeAttribute("value");
  rdoList.value = "on";
  assert_equals(rdoList.value, document.getElementById("r1").value,
                "The value attribute should be the first radio input element's value.");
  assert_true(document.getElementById("r1").checked,
              "The first radio input element should be checked.");
}, "Check the RadioNodeList.value on setting to 'on'");

In particular, it's the "The value attribute should be the first radio input element's value." assertion. Since the value attribute is removed from the r1 radio element, the rdoList.value assignment should have matched against r1 and set its checked value to true, but it did not.

I'm still trying to figure out whether it's a problem with the implementation of removeAttribute, or that the implementation in NodeList stores snapshots of the node instead of it being "live" references.

@nox

nox commented Jan 26, 2016

Copy link
Copy Markdown
Contributor

I see. You shouldn't include code for both ChildrenList and Simple, instead, there should be a specific variant of NodeList for that particular kind of collections, and you should just piggy-back that in RadioNodeList.

@KiChjang

Copy link
Copy Markdown
Contributor Author

Actually, something doesn't quite make sense in this test case... the line document.getElementById("r1").removeAttribute("value"); removes the value attribute from the r1 radio input element, yet when it was referenced again below in document.getElementById("r1").value, I get the value of 1 back! I think we may have an incomplete implementation of removeAttribute.

@KiChjang

Copy link
Copy Markdown
Contributor Author

Ok, ignore what I wrote... it's actually my implementation of SetValue that's funky.

@KiChjang

Copy link
Copy Markdown
Contributor Author

So I think I'm onto something here - HTMLInputElement::Value() doesn't actually return me the value of the value attribute on the element. I need to instead upcast the input element to an element first and then call get_attribute_by_name.

@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - mac-rel-wpt

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. S-tests-failed The changes caused existing tests to fail. and removed S-tests-failed The changes caused existing tests to fail. S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Jan 29, 2016
@KiChjang

Copy link
Copy Markdown
Contributor Author

@bors-servo retry

  • git snafu

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 4229b68 with merge 69d1dfe...

bors-servo pushed a commit that referenced this pull request Jan 29, 2016
Implement RadioNodeList

I also had to implement the NamedGetter for HTMLFormControlsCollection as well, since that's the only consumer of RadioNodeList and I wanted to see which wpt test passes.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9407)
<!-- Reviewable:end -->
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-tests-failed The changes caused existing tests to fail. labels Jan 29, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - mac-dev-unit

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Jan 29, 2016
@KiChjang

Copy link
Copy Markdown
Contributor Author

@bors-servo retry

  • git snafu again

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 4229b68 with merge 0c5591a...

bors-servo pushed a commit that referenced this pull request Jan 29, 2016
Implement RadioNodeList

I also had to implement the NamedGetter for HTMLFormControlsCollection as well, since that's the only consumer of RadioNodeList and I wanted to see which wpt test passes.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9407)
<!-- Reviewable:end -->
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-tests-failed The changes caused existing tests to fail. labels Jan 29, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - mac-rel-wpt

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Jan 29, 2016
@nox

nox commented Jan 29, 2016

Copy link
Copy Markdown
Contributor

@bors-servo retry

Git snafu.

@bors-servo

Copy link
Copy Markdown
Contributor

⚡ Previous build results for android, gonk, linux-dev, linux-rel, mac-dev-unit are reusable. Rebuilding only mac-rel-css, mac-rel-wpt...

@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - mac-rel-wpt

@highfive highfive added the S-tests-failed The changes caused existing tests to fail. label Jan 29, 2016
@nox

nox commented Jan 29, 2016

Copy link
Copy Markdown
Contributor

@bors-servo retry

git snafu

@bors-servo

Copy link
Copy Markdown
Contributor

⚡ Previous build results for android, gonk, linux-dev, linux-rel, mac-dev-unit, mac-rel-css are reusable. Rebuilding only mac-rel-wpt...

@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, gonk, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt

@bors-servo
bors-servo merged commit 4229b68 into servo:master Jan 29, 2016
@KiChjang
KiChjang deleted the radio-node-list branch January 29, 2016 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-tests-failed The changes caused existing tests to fail.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants