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

Implement various checks on the Location setters #23522

Closed
gterzian opened this issue Jun 6, 2019 · 13 comments
Closed

Implement various checks on the Location setters #23522

gterzian opened this issue Jun 6, 2019 · 13 comments

Comments

@gterzian
Copy link
Member

@gterzian gterzian commented Jun 6, 2019

Spec: https://html.spec.whatwg.org/multipage/history.html#location

See all attributes that say "Can be set, to navigate to the given URL.".

Code: See all the Set_ methods at

impl LocationMethods for Location {

As well as set_url_component which is used by those methods:

fn set_url_component(&self, value: USVString, setter: fn(&mut ServoUrl, USVString)) {

Currently failing tests(and maybe others):

And the actual tests are found in https://github.com/servo/servo/tree/master/tests/wpt/web-platform-tests/html/browsers/history/the-location-interface

A start was made at https://github.com/servo/servo/pull/23368/files#diff-45df5e6ab4c1d79fae956506be147b62R244

and https://github.com/servo/servo/pull/23368/files#diff-c1196726ff21e3563c663b049214dafeL21

Note the only gotcha is that the ServoUrl contains an Arc, so you can't manipulate it directly when you do the initial parse to then perform the check, as that will actually change the url of the window. So instead you'll need to get a copy, as is for example done at https://github.com/servo/servo/pull/23368/files#diff-45df5e6ab4c1d79fae956506be147b62R244 (or you need to perform the checks without manipulating the current url)

@gterzian
Copy link
Member Author

@gterzian gterzian commented Jun 7, 2019

As a bonus you can also return a security error when the spec says to, see for how that is done:

Err(Error::Security)

@braddunbar
Copy link

@braddunbar braddunbar commented Jun 8, 2019

I'll work on this!

@gterzian
Copy link
Member Author

@gterzian gterzian commented Jun 10, 2019

Thanks, let us know how it goes! @braddunbar

@gterzian
Copy link
Member Author

@gterzian gterzian commented Jun 24, 2019

@braddunbar How is this going? let us know if you have any questions, you can also just open the PR with a work in progress and ask questions from there...

@braddunbar
Copy link

@braddunbar braddunbar commented Jun 27, 2019

Good! I’ll send a pull this weekend.

@braddunbar braddunbar mentioned this issue Jul 1, 2019
3 of 4 tasks complete
bors-servo added a commit that referenced this issue Jul 1, 2019
Implement checks on Location setters

So, this is my first pull to servo. I've tried to follow all the directions, but I may have missed or forgotten some of them. If so, please let me know - I'll be happy to fix things up!

As described in #23522, this implements various checks on the Location setters. In particular, for the following components.

* protocol
* host
* hostname
* port
* pathname

I'd also like to add code for throwing a `SyntaxError` when appropriate, but I may do that separately.

I've removed the expectations for the protocol setter tests, but I haven't yet found any failing tests for the other components. Should I write tests for those? If so, should I add them here or is there an upstream that I should contribute to?

Let me know what you think!

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #23522
- [ ] There are tests for these changes

<!-- 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/23670)
<!-- Reviewable:end -->
@jdm
Copy link
Member

@jdm jdm commented Jan 6, 2020

There was a PR that was just missing some specification link comments in #23670, then the author stopped responding.

@UxioAndrade
Copy link

@UxioAndrade UxioAndrade commented Feb 9, 2020

@jdm Hi, I would like to work on this. Do you think this would be a nice issue for a first contribution?

@gterzian
Copy link
Member Author

@gterzian gterzian commented Feb 9, 2020

@UxioAndrade Absolutely! (Sorry for answering in lieu of @jdm)

If you look at #23670, you can see that most of the work has already been done by @braddunbar, and there are just a few last comments that need to be addressed.

If it's not clear what those last comments are, let us know.

@UxioAndrade
Copy link

@UxioAndrade UxioAndrade commented Feb 9, 2020

@gterzian Great, thank you!

@utsavoza
Copy link
Contributor

@utsavoza utsavoza commented Apr 17, 2020

Hey @gterzian @UxioAndrade, is it ok for me to take up this issue if we are not making progress on it currently?

@gterzian
Copy link
Member Author

@gterzian gterzian commented Apr 17, 2020

Yes it would be great to finally close this one, there is not much work left I think(see the open PR). Perhaps give @UxioAndrade a couple of days to respond? In any case, there is always more work to do on this project!

@utsavoza
Copy link
Contributor

@utsavoza utsavoza commented Apr 17, 2020

Sure.

@gterzian
Copy link
Member Author

@gterzian gterzian commented Apr 21, 2020

For posterity, I think the easy less label was a bit of an understatement, since the spec is actually rather complicated.

bors-servo added a commit that referenced this issue Apr 22, 2020
Implement various checks on the Location setters

Since there are no existing open PRs for the issue, I am raising one based on the work done by @UxioAndrade and @braddunbar in previous two PRs for the issue (#25714 and #23670) respectively.

- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #23522
- [x] There are tests for these changes
bors-servo added a commit that referenced this issue Apr 24, 2020
Implement various checks on the Location setters

Since there are no existing open PRs for the issue, I am raising one based on the work done by @UxioAndrade and @braddunbar in previous two PRs for the issue (#25714 and #23670) respectively.

- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #23522
- [x] There are tests for these changes
bors-servo added a commit that referenced this issue Apr 24, 2020
Implement various checks on the Location setters

Since there are no existing open PRs for the issue, I am raising one based on the work done by @UxioAndrade and @braddunbar in previous two PRs for the issue (#25714 and #23670) respectively.

- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #23522
- [x] There are tests for these changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.