aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorEric Coan <ecoan@instructure.com>2016-09-25 22:45:15 -0600
committerEric Coan <ecoan@instructure.com>2016-09-26 11:03:22 -0600
commit096c0362fe88f7be6768489651a15fa0f926f43e (patch)
tree27925104352bbf1c8ef8bbe422375a05fa81269e /components/script/dom
parentd00639c55f9a342765483d347a3c29d4647f7411 (diff)
downloadservo-096c0362fe88f7be6768489651a15fa0f926f43e.tar.gz
servo-096c0362fe88f7be6768489651a15fa0f926f43e.zip
Make Assign throw error on invalid url
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/location.rs6
-rw-r--r--components/script/dom/webidls/Location.webidl1
2 files changed, 6 insertions, 1 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();