X-Git-Url: http://git.asbjorn.biz/?p=jquery.git;a=blobdiff_plain;f=build%2Fruntest%2Fenv.js;h=b2a94ff061dbd6b1288fa155f43f2e6ed5af613a;hp=23ffaedddbedbd06e4406623b7f5c09dad545ac8;hb=d776dc9d5c5322e81b56272728325990ed6892bb;hpb=de71a046e619884292b122ddcf1401ad9932a5c7 diff --git a/build/runtest/env.js b/build/runtest/env.js index 23ffaed..b2a94ff 100644 --- a/build/runtest/env.js +++ b/build/runtest/env.js @@ -17,17 +17,21 @@ var window = this; } }; + var curLocation = (new java.io.File("./")).toURL(); + window.__defineSetter__("location", function(url){ + curLocation = new java.net.URL( curLocation, url ); + window.document = new DOMDocument( new Packages.org.xml.sax.InputSource( new java.io.InputStreamReader( - new java.io.FileInputStream(url)))); + new java.io.FileInputStream( url )))); }); window.__defineGetter__("location", function(url){ return { get protocol(){ - return "file:"; + return curLocation.getProtocol() + ":"; } }; }); @@ -490,28 +494,30 @@ var window = this; }, getResponseHeader: function(header){ }, send: function(data){ + var self = this; + function makeRequest(){ - var url = new java.net.URL(this.url), + var url = new java.net.URL(curLocation, self.url), connection = url.openConnection(); // Add headers to Java connection - for (var header in this.headers) - connection.addRequestProperty(header, this.headers[header]); + for (var header in self.headers) + connection.addRequestProperty(header, self.headers[header]); connection.connect(); // Stick the response headers into responseHeaders - for (i=0; ; i++) { + for (var i=0; ; i++) { var headerName = connection.getHeaderFieldKey(i); var headerValue = connection.getHeaderField(i); if (!headerName && !headerValue) break; if (headerName) - this.responseHeaders[headerName] = headerValue; + self.responseHeaders[headerName] = headerValue; } - this.readyState = 4; - this.status = parseInt(connection.responseCode); - this.statusText = connection.responseMessage; + self.readyState = 4; + self.status = parseInt(connection.responseCode); + self.statusText = connection.responseMessage; var stream = new java.io.InputStreamReader( connection.getInputStream()), @@ -519,15 +525,20 @@ var window = this; line; while ((line = buffer.readLine()) != null) - this.responseText += line; + self.responseText += line; + + self.responseXML = null; - try { - this.responseXML = new DOMDocument(this.responseText); - } catch(e) { - this.responseXML = null; + if ( self.responseText.match(/^\s*