Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented XMLHttpRequest.responseURL #9518

Merged
merged 1 commit into from Mar 22, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Bug 8830 - Implemented XMLHttpRequest.responseURL

  • Loading branch information
shinglyu committed Mar 22, 2016
commit f55b0765d17c06bccd7bf411563e3a404de0a56a
@@ -118,7 +118,7 @@ pub struct XMLHttpRequest {
timeout: Cell<u32>,
with_credentials: Cell<bool>,
upload: JS<XMLHttpRequestUpload>,
response_url: String,
response_url: DOMRefCell<String>,
status: Cell<u16>,
status_text: DOMRefCell<ByteString>,
response: DOMRefCell<ByteString>,
@@ -160,7 +160,7 @@ impl XMLHttpRequest {
timeout: Cell::new(0u32),
with_credentials: Cell::new(false),
upload: JS::from_rooted(&XMLHttpRequestUpload::new(global)),
response_url: String::from(""),
response_url: DOMRefCell::new(String::from("")),
status: Cell::new(0),
status_text: DOMRefCell::new(ByteString::new(vec!())),
response: DOMRefCell::new(ByteString::new(vec!())),
@@ -691,7 +691,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest {

// https://xhr.spec.whatwg.org/#the-responseurl-attribute
fn ResponseURL(&self) -> USVString {
USVString(self.response_url.clone())
USVString(self.response_url.borrow().clone())
}

// https://xhr.spec.whatwg.org/#the-status-attribute
@@ -876,6 +876,8 @@ impl XMLHttpRequest {
}
}

*self.response_url.borrow_mut() = metadata.final_url.serialize_no_fragment();

This comment has been minimized.

@shinglyu

shinglyu Mar 7, 2016

Author Member

I'm using metadata.final_url right now, but the wpt redirection test seems to be failing again.


// XXXManishearth Clear cache entries in case of a network error
self.process_partial_response(XHRProgress::HeadersReceived(gen_id,
metadata.headers,
@@ -980,6 +982,7 @@ impl XMLHttpRequest {

// Subsubsteps 5-7
self.send_flag.set(false);

self.change_ready_state(XMLHttpRequestState::Done);
return_if_fetch_was_terminated!();
// Subsubsteps 10-12
"deleted": [],
"items": {
"testharness": {
"XMLHttpRequest/responseurl.html": [
{
"path": "XMLHttpRequest/responseurl.html",
"url": "/XMLHttpRequest/responseurl.html"
}
],
"html/semantics/forms/textfieldselection/selection-after-content-change.html": [
{
"path": "html/semantics/forms/textfieldselection/selection-after-content-change.html",
@@ -3,12 +3,6 @@
[domain]
expected: FAIL

[URL]
expected: FAIL

[documentURI]
expected: FAIL

[referrer]

This comment has been minimized.

@jdm

jdm Feb 3, 2016

Member

Huh, I'm confused why this test result changed. The test doesn't use responseURL at all.

expected: FAIL

@@ -0,0 +1,37 @@
<!doctype html>
<html>
<head>
<title>XMLHttpRequest: responseURL test</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://xhr.spec.whatwg.org/#the-responseurl-attribute"/>
</head>
<body>
<div id="log"></div>
<script>
test(function() {

This comment has been minimized.

@jdm

jdm Feb 3, 2016

Member

We should also have a test that uses an HTTP redirect (resources/redirect.py) and ensures that responseURL shows the post-redirect URL.

var client = new XMLHttpRequest()
assert_equals(client.responseURL, "")

client.open("GET", "foo.html", false)
client.send()

expected = location.href.replace(/[^/]*$/, 'foo.html')
assert_equals(client.status, 404)
assert_equals(client.responseURL, expected)
}, "404 response has proper responseURL")
test(function() {
var client = new XMLHttpRequest()
assert_equals(client.responseURL, "")

target = "image.gif"

This comment has been minimized.

@shinglyu

shinglyu Mar 13, 2016

Author Member

It was a relative path issue, the redirect.py uses a base path of resources, so I have to change this from resources/image.gif to image.gif

client.open("GET", "resources/redirect.py?location=" + target, false)
client.send()

expected = location.href.replace(/[^/]*$/, "resources/" + target)
assert_equals(client.status, 200)
assert_equals(client.responseURL, expected)
}, "Redirected response has proper responseURL")
</script>
</body>
</html>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.