Implement Location.replace

This commit is contained in:
Pu Xingyu 2016-11-18 12:38:12 +08:00
parent 9863149043
commit fb6cc15208
3 changed files with 14 additions and 2 deletions

View file

@ -62,6 +62,18 @@ impl LocationMethods for Location {
fn Reload(&self) {
self.window.load_url(self.get_url(), true, true, None);
}
// https://html.spec.whatwg.org/multipage/#dom-location-replace
fn Replace(&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, true, false, None);
Ok(())
} else {
Err(Error::Syntax)
}
}
// https://html.spec.whatwg.org/multipage/#dom-location-hash

View file

@ -16,7 +16,8 @@
[Throws]
void assign(USVString url);
//void replace(USVString url);
[Throws]
void replace(USVString url);
void reload();
//[SameObject] readonly attribute USVString[] ancestorOrigins;

View file

@ -1589,7 +1589,6 @@ impl Window {
js_runtime: DOMRefCell::new(Some(runtime.clone())),
bluetooth_thread: bluetooth_thread,
page_clip_rect: Cell::new(max_rect()),
fragment_name: DOMRefCell::new(None),
resize_event: Cell::new(None),
layout_chan: layout_chan,
layout_rpc: layout_rpc,