Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(564)

Unified Diff: sky/framework/xmlhttprequest.sky

Issue 729913003: Teach XHR how to handle relative urls. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sky/tests/services/xhr-relative.sky » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
});
};
« no previous file with comments | « no previous file | sky/tests/services/xhr-relative.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698