Got some XHR tests to run, still some hanging threads (need to investigate). Started moving some Ajax tests away from using PHP (more portable this way). Fixed a number of XHR env bugs.
This commit is contained in:
parent
de71a046e6
commit
d776dc9d5c
6 changed files with 74 additions and 47 deletions
|
@ -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*</) ) {
|
||||
try {
|
||||
self.responseXML = new DOMDocument(
|
||||
new java.io.ByteArrayInputStream(
|
||||
(new java.lang.String(
|
||||
self.responseText)).getBytes("UTF8")));
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
this.onreadystatechange();
|
||||
self.onreadystatechange();
|
||||
}
|
||||
|
||||
if (this.async)
|
||||
|
|
|
@ -11,6 +11,7 @@ load(
|
|||
"src/selector/selectorTest.js",
|
||||
"src/event/eventTest.js",
|
||||
"src/fx/fxTest.js"
|
||||
//"src/ajax/ajaxTest.js"
|
||||
);
|
||||
|
||||
// Display the results
|
||||
|
|
|
@ -181,4 +181,17 @@ function triggerEvent( elem, type, event ) {
|
|||
elem.fireEvent("on"+type);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Add random number to url to stop IE from caching
|
||||
*
|
||||
* @example url("data/test.html")
|
||||
* @result "data/test.html?10538358428943"
|
||||
*
|
||||
* @example url("data/test.php?foo=bar")
|
||||
* @result "data/test.php?foo=bar&10538358345554"
|
||||
*/
|
||||
function url(value) {
|
||||
return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random()*100000);
|
||||
}
|
1
build/test/data/json_obj.js
Normal file
1
build/test/data/json_obj.js
Normal file
|
@ -0,0 +1 @@
|
|||
{ "data": {"lang": "en", "length": 25} }
|
1
build/test/data/name.html
Normal file
1
build/test/data/name.html
Normal file
|
@ -0,0 +1 @@
|
|||
ERROR <script type="text/javascript">ok( true, "name.html retrieved" );</script>
|
Loading…
Add table
Add a link
Reference in a new issue