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

Correctly gets and sets rel content attributes in linkelement #13311

Merged
merged 1 commit into from Sep 23, 2016

Conversation

@cynicaldevil
Copy link
Contributor

cynicaldevil commented Sep 18, 2016


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #12799 .

This change is Reviewable

@highfive
Copy link

highfive commented Sep 18, 2016

Heads up! This PR modifies the following files:

  • @KiChjang: components/script/dom/htmllinkelement.rs
@highfive
Copy link

highfive commented Sep 18, 2016

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!
Copy link
Member

KiChjang left a comment

We still need a WPT test for this. I believe in the original issue, @jdm has a test case which you can use.
We also still need to change the RelList function and remove the rel_list field on the link element.

@@ -357,10 +357,21 @@ impl HTMLLinkElementMethods for HTMLLinkElement {
make_setter!(SetHref, "href");

// https://html.spec.whatwg.org/multipage/#dom-link-rel
make_getter!(Rel, "rel");
fn Rel(&self) -> DOMString {
let atomVec: Vec<Atom> = self.upcast::<Element>().get_tokenlist_attribute(&atom!("rel"));

This comment has been minimized.

@KiChjang

KiChjang Sep 18, 2016

Member

No need for type annotation here and atomVec should really be atom_vec.

for data in &atomVec {
let dataStr = String::from(data as &str);
string_concat = string_concat + " " + &dataStr;
}

This comment has been minimized.

@KiChjang

KiChjang Sep 18, 2016

Member

Instead of doing this in imperative style, I think you can do something fancy with iterators:

DOMString::from(atom_vec.iter().map(|a| &*a).join(" "))
@cynicaldevil
Copy link
Contributor Author

cynicaldevil commented Sep 18, 2016

@KiChjang +1 on the test part, but don't you think the RelList thing is different from this issue? IMO it would be better to open a separate PR for that.

@KiChjang
Copy link
Member

KiChjang commented Sep 18, 2016

It is not. The issue is to fix the crash that happens when you use that test case, and your current PR doesn't actually fix it yet.

@cynicaldevil
Copy link
Contributor Author

cynicaldevil commented Sep 18, 2016

@KiChjang alright.

@Ms2ger
Copy link
Contributor

Ms2ger commented Sep 19, 2016

I'm afraid everything @KiChjang said here was wrong. The rel_list field should remain as it is. The Rel function is unfortunately incorrect; it should just call get_string_attribute, so any existing whitespace in the string is returned as-is.

r? @Ms2ger

@bors-servo try

@highfive highfive assigned Ms2ger and unassigned KiChjang Sep 19, 2016
bors-servo added a commit that referenced this pull request Sep 19, 2016
Correctly gets and sets rel content attributes in linkelement

<!-- Please describe your changes on the following line: -->
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #12799 .

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13311)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Sep 19, 2016

Trying commit c7f7e2e with merge 01be8c4...

@bors-servo
Copy link
Contributor

bors-servo commented Sep 19, 2016

💔 Test failed - linux-rel

@KiChjang
Copy link
Member

KiChjang commented Sep 19, 2016

@Ms2ger I'm not sure what the point is to keep a rel_list field when the rel content attribute already contains a token list. Also, the spec does say that the relList IDL attribute should reflect the rel content attribute.

@Ms2ger
Copy link
Contributor

Ms2ger commented Sep 19, 2016

@KiChjang you're confusing different types of objects... Please read the code more carefully.

@jdm jdm mentioned this pull request Sep 21, 2016
@cynicaldevil
Copy link
Contributor Author

cynicaldevil commented Sep 21, 2016

@KiChjang @Ms2ger I'm not sure how I should proceed, should I amend the PR with the minor changes that @KiChjang suggested and then modify the tests so that they pass?

@KiChjang
Copy link
Member

KiChjang commented Sep 21, 2016

No, @msger is correct here, you need to use make_getter! on the Rel function, and then update the tests accordingly.

@cynicaldevil
Copy link
Contributor Author

cynicaldevil commented Sep 22, 2016

@KiChjang I pushed the changes onto PR branch.

@bors-servo
Copy link
Contributor

bors-servo commented Sep 22, 2016

💔 Test failed - linux-rel

@highfive
Copy link

highfive commented Sep 22, 2016

  ▶ OK [expected CRASH] /fetch/nosniff/stylesheet.html

  ▶ OK [expected CRASH] /html/semantics/document-metadata/the-link-element/link-style-error-01.html
@cynicaldevil
Copy link
Contributor Author

cynicaldevil commented Sep 22, 2016

@KiChjang Is this a good thing? Because the report is telling that it expected a crash but my PR fixed it...?

@KiChjang
Copy link
Member

KiChjang commented Sep 22, 2016

Indeed, this is pretty good! Great work here!

@jdm
Copy link
Member

jdm commented Sep 22, 2016

They used to crash because of the panic that this PR fixes.

@KiChjang
Copy link
Member

KiChjang commented Sep 22, 2016

Next step is to change the test expectations and mark those tests as passing.

@cynicaldevil
Copy link
Contributor Author

cynicaldevil commented Sep 23, 2016

If I understood this right, I have to change the respective .ini files to expect a PASS instead of a CRASH. But these files are missing in this branch, while they are present in other branches. What am I missing?

@Ms2ger
Copy link
Contributor

Ms2ger commented Sep 23, 2016

The expected crashes were only added in #12493; you'll need to rebase.

Also, you should be able to remove those files; "pass" is the default expectation.

@cynicaldevil
Copy link
Contributor Author

cynicaldevil commented Sep 23, 2016

Thanks, I've updated the PR now.

@Ms2ger
Copy link
Contributor

Ms2ger commented Sep 23, 2016

Could you just squash the two commits? Should be good to go then.

@cynicaldevil cynicaldevil force-pushed the cynicaldevil:linkelement branch from 9f2b9b9 to 9d378ce Sep 23, 2016
@cynicaldevil
Copy link
Contributor Author

cynicaldevil commented Sep 23, 2016

@Ms2ger Done.

@Ms2ger
Copy link
Contributor

Ms2ger commented Sep 23, 2016

Thanks!

@bors-servo r+

@bors-servo
Copy link
Contributor

bors-servo commented Sep 23, 2016

📌 Commit 9d378ce has been approved by Ms2ger

@bors-servo
Copy link
Contributor

bors-servo commented Sep 23, 2016

Testing commit 9d378ce with merge f243d98...

bors-servo added a commit that referenced this pull request Sep 23, 2016
Correctly gets and sets rel content attributes in linkelement

<!-- Please describe your changes on the following line: -->
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #12799 .

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13311)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Sep 23, 2016

@bors-servo bors-servo merged commit 9d378ce into servo:master Sep 23, 2016
2 of 3 checks passed
2 of 3 checks passed
continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Removed .ini files expecting crashes
@cynicaldevil cynicaldevil deleted the cynicaldevil:linkelement branch Sep 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

7 participants
You can’t perform that action at this time.