Index: sky/framework/xmlhttprequest.sky |
diff --git a/sky/framework/xmlhttprequest.sky b/sky/framework/xmlhttprequest.sky |
index 3e79a4311f48af95f463a610a4aa9f58457eb45a..cef3252a82becbd1bc8a0a70a0db073644f68def 100644 |
--- a/sky/framework/xmlhttprequest.sky |
+++ b/sky/framework/xmlhttprequest.sky |
@@ -4,6 +4,9 @@ |
<import src="/mojo/services/public/interfaces/network/url_loader.mojom.sky" as="loader" /> |
<import src="shell.sky" as="shell" /> |
<script> |
+// XHR keeps itself alive. |
+var outstandingRequests = new Set(); |
esprehn
2014/11/18 02:06:24
Why do you need this? I thought the Mojo JS stuff
abarth-chromium
2014/11/18 02:11:59
It doesn't. :(
We can make the waiting callbacks
esprehn
2014/11/18 02:15:49
Fixing this with one off Sets seems like a mistake
|
+ |
function XMLHttpRequest() { |
this.networkService_ = shell.connectToService( |
"mojo:network_service", net.NetworkService); |
@@ -18,7 +21,7 @@ XMLHttpRequest.prototype.onerror = function(error) { }; |
XMLHttpRequest.prototype.open = function(method, url) { |
this.request_ = new loader.URLRequest(); |
- this.request_.url = url; |
+ this.request_.url = new URL(url, document.URL); |
this.request_.method = method; |
this.request_.auto_follow_redirects = true; |
this.headers_.clear(); |
@@ -41,12 +44,15 @@ XMLHttpRequest.prototype.send = function() { |
this.loader_ = shell.wrapHandle(pipe.handle0, loader.URLLoader); |
var self = this; |
+ outstandingRequests.add(this); |
this.loader_.start(this.request_).then(function(result) { |
return core.drainData(result.response.body).then(function(result) { |
+ outstandingRequests.delete(self); |
self.responseText = unicode.decodeUtf8String(new Uint8Array(result.buffer)); |
self.onload(); |
}); |
}).catch(function(error) { |
+ outstandingRequests.delete(self); |
self.onerror(error); |
}); |
}; |