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
Add comments linking to the steps of the specs in the checks on Location setters #25714
Closed
+33
−37
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9845249
only allow http/https protocols
braddunbar 3c8df69
host or hostname: abort if url cannot be a base
braddunbar 97e967c
port: abort if url cannot have username/password/port
braddunbar 3f2abcc
pathname: terminate if cannot-be-a-base
braddunbar 6c31813
remove failure expectations
braddunbar 05f7547
link to cannot have a username password spec
braddunbar 214fbc9
fix merge conflict
UxioAndrade ad31fde
add comments linking to steps of the specs
UxioAndrade ec77231
change scheme unwrap into syntax error
UxioAndrade File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
| @@ -165,7 +165,10 @@ impl LocationMethods for Location { | ||
| // https://html.spec.whatwg.org/multipage/#dom-location-host | ||
| fn SetHost(&self, value: USVString) -> ErrorResult { | ||
| self.check_same_origin_domain()?; | ||
| self.set_url_component(value, UrlHelper::SetHost); | ||
| // Step 4: If copyURL's cannot-be-a-base-URL flag is set, terminate these steps. | ||
| if !self.get_url().cannot_be_a_base() { | ||
| self.set_url_component(value, UrlHelper::SetHost); | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| @@ -184,7 +187,10 @@ impl LocationMethods for Location { | ||
| // https://html.spec.whatwg.org/multipage/#dom-location-hostname | ||
| fn SetHostname(&self, value: USVString) -> ErrorResult { | ||
| self.check_same_origin_domain()?; | ||
| self.set_url_component(value, UrlHelper::SetHostname); | ||
| // Step 4: If copyURL's cannot-be-a-base-URL flag is set, terminate these steps. | ||
| if !self.get_url().cannot_be_a_base() { | ||
| self.set_url_component(value, UrlHelper::SetHostname); | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| @@ -216,7 +222,10 @@ impl LocationMethods for Location { | ||
| // https://html.spec.whatwg.org/multipage/#dom-location-pathname | ||
| fn SetPathname(&self, value: USVString) -> ErrorResult { | ||
| self.check_same_origin_domain()?; | ||
| self.set_url_component(value, UrlHelper::SetPathname); | ||
| // Step 3: If copyURL's cannot-be-a-base-URL flag is set, terminate these steps. | ||
|
||
| if !self.get_url().cannot_be_a_base() { | ||
| self.set_url_component(value, UrlHelper::SetPathname); | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| @@ -229,7 +238,12 @@ impl LocationMethods for Location { | ||
| // https://html.spec.whatwg.org/multipage/#dom-location-port | ||
| fn SetPort(&self, value: USVString) -> ErrorResult { | ||
| self.check_same_origin_domain()?; | ||
| self.set_url_component(value, UrlHelper::SetPort); | ||
| let url = self.get_url(); | ||
| // Step 4: If copyURL cannot have a username/password/port, then return. | ||
| // https://url.spec.whatwg.org/#cannot-have-a-username-password-port | ||
| if url.has_host() && !url.cannot_be_a_base() && url.scheme() != "file" { | ||
| self.set_url_component(value, UrlHelper::SetPort); | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| @@ -242,9 +256,16 @@ impl LocationMethods for Location { | ||
| // https://html.spec.whatwg.org/multipage/#dom-location-protocol | ||
| fn SetProtocol(&self, value: USVString) -> ErrorResult { | ||
| self.check_same_origin_domain()?; | ||
| self.set_url_component(value, UrlHelper::SetProtocol); | ||
| Ok(()) | ||
| } | ||
| // Step 6: If copyURL's scheme is not an HTTP(S) scheme, then terminate these steps. | ||
| if let Ok(scheme) = value.split(':').next() { | ||
| if scheme.eq_ignore_ascii_case("http") || scheme.eq_ignore_ascii_case("https") { | ||
| self.set_url_component(value, UrlHelper::SetProtocol); | ||
| } | ||
| Ok(()) | ||
| } else { | ||
| Err(Error::Syntax) | ||
gterzian
Member
|
||
| } | ||
| } | ||
|
|
||
| // https://html.spec.whatwg.org/multipage/#dom-location-search | ||
| fn GetSearch(&self) -> Fallible<USVString> { | ||
This file was deleted.
Oops, something went wrong.
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Actually, can we put this comment, and all others, above the
Ok(())branch, because the comments all refer to the steps take when the condition is not met.