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

Refactor follow_hyperlink and its callers #22771

Merged
merged 3 commits into from Jan 30, 2019

Conversation

@MaT1g3R
Copy link
Contributor

MaT1g3R commented Jan 27, 2019

Now they follow the new spec stated at:
https://html.spec.whatwg.org/multipage/links.html#following-hyperlinks-2

It seems like choosing a browsing context is already done in the
follow_hyperlink method, so I have removed the TODO in
activation_behavior for HTMLAreaElement.

The tests in tests/wpt/web-platform-tests/html/semantics/links/following-hyperlinks/
pass in release builds, but still don't pass in dev build,
since the timeout in
tests/wpt/web-platform-tests/html/semantics/links/following-hyperlinks/activation-behavior.window.js
seems to be too short for dev builds.

Navigating to error page on failed URL parsing is still not implemented.

There seem to be potential code duplication in activation_behavior
methods for both htmlanchorelement.rs and htmlareaelement.rs, in:

let referrer_policy = match self.RelList().Contains("noreferrer".into()) {
    true => Some(ReferrerPolicy::NoReferrer),
    false => None,
};

I didn't pull them out to a separate function since I don't know
where I would put that new function.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #22761 (GitHub issue number if applicable)
  • There are tests for these changes

This change is Reviewable

@highfive
Copy link

highfive commented Jan 27, 2019

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @avadacatavra (or someone else) soon.

@highfive
Copy link

highfive commented Jan 27, 2019

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/htmlareaelement.rs, components/script/dom/htmlanchorelement.rs
  • @KiChjang: components/script/dom/htmlareaelement.rs, components/script/dom/htmlanchorelement.rs
@highfive
Copy link

highfive commented Jan 27, 2019

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!
@jdm jdm assigned jdm and unassigned avadacatavra Jan 28, 2019
Copy link
Member

jdm left a comment

This looks good! I see one more simplification that we can make, then this should be good to merge.

@@ -575,15 +571,14 @@ impl Activatable for HTMLAnchorElement {
}
}

// Step 4.
//TODO: Download the link is `download` attribute is set.

// https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-delivery
let referrer_policy = match self.RelList().Contains("noreferrer".into()) {

This comment has been minimized.

Copy link
@jdm

jdm Jan 29, 2019

Member

We should remove this code and replace it by implementing the missing step 12 of follow_hyperlink. You can use the determine_policy_for_token helper function to get a ReferrerPolicy value from a string.

}
// Step 2
// TODO : We should be choosing a browsing context and navigating to it.
// Step 3
let referrer_policy = match self.RelList().Contains("noreferrer".into()) {

This comment has been minimized.

Copy link
@jdm

jdm Jan 29, 2019

Member

We can remove this code as well.

MaT1g3R added 3 commits Jan 27, 2019
Now they follow the new spec stated at:
https://html.spec.whatwg.org/multipage/links.html#following-hyperlinks-2

It seems like choosing a browsing context is already done in the
follow_hyperlink method, so I have removed the TODO in
activation_behavior for HTMLAreaElement.

The tests in tests/wpt/web-platform-tests/html/semantics/links/following-hyperlinks/
pass in release builds, but still don't pass in dev build,
since the timeout in
tests/wpt/web-platform-tests/html/semantics/links/following-hyperlinks/activation-behavior.window.js
seems to be too short for dev builds.

Navigating to error page on failed URL parsing is still not implemented.

There seem to be potential code duplication in activation_behavior
methods for both htmlanchorelement.rs and htmlareaelement.rs, in:

    let referrer_policy = match self.RelList().Contains("noreferrer".into()) {
        true => Some(ReferrerPolicy::NoReferrer),
        false => None,
    };

I didn't pull them out to a separate function since I don't know
where I would put that new function.
@MaT1g3R MaT1g3R force-pushed the MaT1g3R:refactor_follow_hyperlink branch from aa5517d to 0bafa61 Jan 30, 2019
@jdm
Copy link
Member

jdm commented Jan 30, 2019

@bors-servo r+
Thanks!

@bors-servo
Copy link
Contributor

bors-servo commented Jan 30, 2019

📌 Commit 0bafa61 has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Jan 30, 2019

Testing commit 0bafa61 with merge 65370f1...

bors-servo added a commit that referenced this pull request Jan 30, 2019
Refactor follow_hyperlink and its callers

Now they follow the new spec stated at:
https://html.spec.whatwg.org/multipage/links.html#following-hyperlinks-2

It seems like choosing a browsing context is already done in the
follow_hyperlink method, so I have removed the TODO in
activation_behavior for HTMLAreaElement.

The tests in `tests/wpt/web-platform-tests/html/semantics/links/following-hyperlinks/`
pass in release builds, but still don't pass in dev build,
since the timeout in
`tests/wpt/web-platform-tests/html/semantics/links/following-hyperlinks/activation-behavior.window.js`
seems to be too short for dev builds.

Navigating to error page on failed URL parsing is still not implemented.

There seem to be potential code duplication in activation_behavior
methods for both htmlanchorelement.rs and htmlareaelement.rs, in:

    let referrer_policy = match self.RelList().Contains("noreferrer".into()) {
        true => Some(ReferrerPolicy::NoReferrer),
        false => None,
    };

I didn't pull them out to a separate function since I don't know
where I would put that new function.

<!-- 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 #22761 (GitHub issue number if applicable)

<!-- Either: -->
- [X] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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/22771)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jan 30, 2019

@bors-servo bors-servo merged commit 0bafa61 into servo:master Jan 30, 2019
4 checks passed
4 checks passed
Taskcluster (pull_request) TaskGroup: success
Details
Travis CI - Pull Request Build Passed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
homu Test successful
Details
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.

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