aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorPu Xingyu <pu.stshine@gmail.com>2016-11-18 12:38:12 +0800
committerPu Xingyu <pu.stshine@gmail.com>2016-11-18 12:38:12 +0800
commitfb6cc15208690acb4c66445b71f2ff8d1dcfcf73 (patch)
tree0e67376d119545407368ebdbad83ff542fd49cfa /components/script
parent986314904341fafa7caa1d32ee9d992d7c45282e (diff)
downloadservo-fb6cc15208690acb4c66445b71f2ff8d1dcfcf73.tar.gz
servo-fb6cc15208690acb4c66445b71f2ff8d1dcfcf73.zip
Implement Location.replace
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/location.rs12
-rw-r--r--components/script/dom/webidls/Location.webidl3
-rw-r--r--components/script/dom/window.rs1
3 files changed, 14 insertions, 2 deletions
diff --git a/components/script/dom/location.rs b/components/script/dom/location.rs
index 576a1d1b005..cc2c064f4b8 100644
--- a/components/script/dom/location.rs
+++ b/components/script/dom/location.rs
@@ -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
diff --git a/components/script/dom/webidls/Location.webidl b/components/script/dom/webidls/Location.webidl
index 93ab3dabba2..431ab87d5e5 100644
--- a/components/script/dom/webidls/Location.webidl
+++ b/components/script/dom/webidls/Location.webidl
@@ -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;
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 6e946fe3eac..64e06bf8811 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -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,