aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-09-27 01:24:28 -0500
committerGitHub <noreply@github.com>2016-09-27 01:24:28 -0500
commitef1b594f4836a0ff9f82960c5bdcbd038f72f8f0 (patch)
treeb974e548d44827994a7da56a7d5ce7407515c30f
parent4ceea0426c933c853b3479acaa3e523c2b34a467 (diff)
parent096c0362fe88f7be6768489651a15fa0f926f43e (diff)
downloadservo-ef1b594f4836a0ff9f82960c5bdcbd038f72f8f0.tar.gz
servo-ef1b594f4836a0ff9f82960c5bdcbd038f72f8f0.zip
Auto merge of #13422 - SecurityInsanity:master, r=KiChjang
Make Assign throw error on invalid url Step 2 of: https://html.spec.whatwg.org/multipage/browsers.html#dom-location-assign says we should throw an error. This makes it do that. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #13420 (github issue number if applicable). - [x] 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/13422) <!-- Reviewable:end -->
-rw-r--r--components/script/dom/location.rs6
-rw-r--r--components/script/dom/webidls/Location.webidl1
-rw-r--r--tests/wpt/metadata/html/browsers/history/the-location-interface/location_assign.html.ini4
3 files changed, 6 insertions, 5 deletions
diff --git a/components/script/dom/location.rs b/components/script/dom/location.rs
index 550af503d53..ba835ada146 100644
--- a/components/script/dom/location.rs
+++ b/components/script/dom/location.rs
@@ -4,6 +4,7 @@
use dom::bindings::codegen::Bindings::LocationBinding;
use dom::bindings::codegen::Bindings::LocationBinding::LocationMethods;
+use dom::bindings::error::{Error, ErrorResult};
use dom::bindings::global::GlobalRef;
use dom::bindings::js::{JS, Root};
use dom::bindings::reflector::{Reflector, reflect_dom_object};
@@ -46,12 +47,15 @@ impl Location {
impl LocationMethods for Location {
// https://html.spec.whatwg.org/multipage/#dom-location-assign
- fn Assign(&self, url: USVString) {
+ fn Assign(&self, url: USVString) -> ErrorResult {
// TODO: per spec, we should use the _API base URL_ specified by the
// _entry settings object_.
let base_url = self.window.get_url();
if let Ok(url) = base_url.join(&url.0) {
self.window.load_url(url, false, None);
+ Ok(())
+ } else {
+ Err(Error::Syntax)
}
}
diff --git a/components/script/dom/webidls/Location.webidl b/components/script/dom/webidls/Location.webidl
index 8eea1a12c31..93ab3dabba2 100644
--- a/components/script/dom/webidls/Location.webidl
+++ b/components/script/dom/webidls/Location.webidl
@@ -14,6 +14,7 @@
attribute USVString search;
attribute USVString hash;
+ [Throws]
void assign(USVString url);
//void replace(USVString url);
void reload();
diff --git a/tests/wpt/metadata/html/browsers/history/the-location-interface/location_assign.html.ini b/tests/wpt/metadata/html/browsers/history/the-location-interface/location_assign.html.ini
index f3e2538746c..3193292cbe9 100644
--- a/tests/wpt/metadata/html/browsers/history/the-location-interface/location_assign.html.ini
+++ b/tests/wpt/metadata/html/browsers/history/the-location-interface/location_assign.html.ini
@@ -2,7 +2,3 @@
type: testharness
[location assign]
expected: FAIL
-
- [URL that fails to parse]
- expected: FAIL
-