mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Make Assign throw error on invalid url
This commit is contained in:
parent
d00639c55f
commit
096c0362fe
3 changed files with 6 additions and 5 deletions
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::LocationBinding;
|
use dom::bindings::codegen::Bindings::LocationBinding;
|
||||||
use dom::bindings::codegen::Bindings::LocationBinding::LocationMethods;
|
use dom::bindings::codegen::Bindings::LocationBinding::LocationMethods;
|
||||||
|
use dom::bindings::error::{Error, ErrorResult};
|
||||||
use dom::bindings::global::GlobalRef;
|
use dom::bindings::global::GlobalRef;
|
||||||
use dom::bindings::js::{JS, Root};
|
use dom::bindings::js::{JS, Root};
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
|
@ -46,12 +47,15 @@ impl Location {
|
||||||
|
|
||||||
impl LocationMethods for Location {
|
impl LocationMethods for Location {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-location-assign
|
// 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
|
// TODO: per spec, we should use the _API base URL_ specified by the
|
||||||
// _entry settings object_.
|
// _entry settings object_.
|
||||||
let base_url = self.window.get_url();
|
let base_url = self.window.get_url();
|
||||||
if let Ok(url) = base_url.join(&url.0) {
|
if let Ok(url) = base_url.join(&url.0) {
|
||||||
self.window.load_url(url, false, None);
|
self.window.load_url(url, false, None);
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(Error::Syntax)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
attribute USVString search;
|
attribute USVString search;
|
||||||
attribute USVString hash;
|
attribute USVString hash;
|
||||||
|
|
||||||
|
[Throws]
|
||||||
void assign(USVString url);
|
void assign(USVString url);
|
||||||
//void replace(USVString url);
|
//void replace(USVString url);
|
||||||
void reload();
|
void reload();
|
||||||
|
|
|
@ -2,7 +2,3 @@
|
||||||
type: testharness
|
type: testharness
|
||||||
[location assign]
|
[location assign]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[URL that fails to parse]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue