Auto merge of #7064 - paulrouget:reload, r=Ms2ger

Implement location.reload()

This is a naive implementation of `window.location.reload()`.
I'd appreciate any feedback.

I was wondering if it'd be better to implement `ConstellationMsg::Reload` instead of using  `load_url`.

Also, what kind of test should I write?

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7064)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-09-21 09:03:42 -06:00
commit 4dc986bca3
5 changed files with 57 additions and 2 deletions

View file

@ -59,6 +59,11 @@ impl LocationMethods for Location {
}
}
// https://html.spec.whatwg.org/multipage/#dom-location-reload
fn Reload(&self) {
self.window.root().load_url(self.get_url());
}
// https://url.spec.whatwg.org/#dom-urlutils-hash
fn Hash(&self) -> USVString {
UrlHelper::Hash(&self.get_url())

View file

@ -7,6 +7,6 @@
/*[Unforgeable]*/ interface Location {
void assign(DOMString url);
//void replace(DOMString url);
//void reload();
void reload();
};
Location implements URLUtils;

View file

@ -29184,7 +29184,16 @@
},
"local_changes": {
"deleted": [],
"items": {},
"items": {
"testharness": {
"html/browsers/history/the-location-interface/location_reload.html": [
{
"path": "html/browsers/history/the-location-interface/location_reload.html",
"url": "/html/browsers/history/the-location-interface/location_reload.html"
}
]
}
},
"reftest_nodes": {}
},
"reftest_nodes": {

View file

@ -0,0 +1,4 @@
<script>
parent._ping(window.location.href)
location.reload();
</script>

View file

@ -0,0 +1,37 @@
<!DOCTYPE HTML>
<html>
<head>
<title>location_reload</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<iframe></iframe>
<script>
async_test(function(t) {
var url = new URL("./location_reload-iframe.html", window.location).href;
var pingCount = 0;
window._ping = t.step_func(function(innerURL) {
assert_equals(url, innerURL, "iframe url (" + pingCount + ")");
pingCount++;
if (pingCount == 5) {
t.done();
}
});
var iframe = document.querySelector("iframe");
iframe.src = url;
});
</script>
</body>
</html>