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

Make hostname state return early if a port is given #604

Merged
merged 1 commit into from
May 19, 2021

Conversation

TimothyGu
Copy link
Member

@TimothyGu TimothyGu commented May 17, 2021

Fixes #601.

(See WHATWG Working Mode: Changes for more details.)


Preview | Diff

TimothyGu added a commit to jsdom/whatwg-url that referenced this pull request May 17, 2021
@TimothyGu TimothyGu changed the title Make hostname setter return failure if a port is given Make hostname state return failure if a port is given May 17, 2021
@TimothyGu TimothyGu requested a review from annevk May 17, 2021 22:56
Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

Thanks!

(I wondered if this should be a validation error, but that doesn't seem to make sense for API-specific conditions.)

@annevk
Copy link
Member

annevk commented May 18, 2021

Could you also add a test for location.hostname throwing for the same input?

@TimothyGu
Copy link
Member Author

@annevk What do you mean? The setter steps don't seem to have any provision for throwing on URL parsing failure.

@annevk
Copy link
Member

annevk commented May 19, 2021

Oh, sorry, I somehow assumed Firefox's behavior was correct. It seems that Safari does navigate to the current URL. And Chrome ignores the : as per the current specification. So it does seem like something that ought to be tested, but the pass condition should probably match Safari?

@TimothyGu
Copy link
Member Author

TimothyGu commented May 19, 2021

@annevk I agree that more location tests would be useful, though to be fair, Chrome doesn't exactly follow the current spec:

Screenshot from 2021-05-19 04-58-59

And if the current URL doesn't have a port while the hostname has a port, the hostname's port is used.

In fact, all the Location properties could probably use some more setter tests.

(And yes, Safari is the one we would align to.)


By the way, I don't have write permissions to this repo, so you'll have to merge this PR.

@annevk
Copy link
Member

annevk commented May 19, 2021

I see, I had not tested Chrome when setting from a URL with a port. Alright, I guess we can merge this and consider the Location issue somewhat distinct. Could you file an issue to track that? Either against WPT or HTML?

@annevk
Copy link
Member

annevk commented May 19, 2021

Actually, I don't see why this needs to return failure. I think we only return failure at the moment if it's relevant for the caller. Otherwise we just return. (That's also why I thought the Location setter would throw.)

TimothyGu added a commit to jsdom/whatwg-url that referenced this pull request May 19, 2021
@TimothyGu
Copy link
Member Author

I guess we can merge this and consider the Location issue somewhat distinct. Could you file an issue to track that? Either against WPT or HTML?

There's already web-platform-tests/wpt#4103 to track Location stuff.

Actually, I don't see why this needs to return failure. I think we only return failure at the moment if it's relevant for the caller. Otherwise we just return.

Fixed.

@TimothyGu TimothyGu changed the title Make hostname state return failure if a port is given Make hostname state return early if a port is given May 19, 2021
@annevk annevk merged commit ec96993 into whatwg:main May 19, 2021
@annevk
Copy link
Member

annevk commented May 19, 2021

Thanks!

@TimothyGu TimothyGu deleted the colon-noop branch May 19, 2021 16:19
TimothyGu added a commit to web-platform-tests/wpt that referenced this pull request May 19, 2021
TimothyGu added a commit to TimothyGu/whatwg-url that referenced this pull request May 19, 2021
@rmisev
Copy link
Member

rmisev commented May 19, 2021

It seems a bit late now, but I think if host with port is given, then 2.2. step (added by this PR) must emit validation error.
Such practices are used in other steps (for example in 3.2.) when given value is not accepted.
If you agree, I can prepare PR.

@annevk
Copy link
Member

annevk commented May 19, 2021

@rmisev I considered that, but I thought we didn't do it for override cases?

@rmisev
Copy link
Member

rmisev commented May 19, 2021

Yeah, it seems the only case, when override emits validation error, is 3.2. step in the host & hostname state.

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request May 21, 2021
…ort is given, a=testonly

Automatic update from web-platform-tests
url: expect hostname setter no-op if a port is given (#29021)

Aligns with whatwg/url#604
--

wpt-commits: 67a580b4a11da1dca6c1195a2b670e361e4013c9
wpt-pr: 29021
domenic pushed a commit to jsdom/whatwg-url that referenced this pull request Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Should hostname setter no-op on colon (:)?
3 participants