prototype: Add support for per-request onCreate callbacks to Ajax.Request. Closes #8011.

This commit is contained in:
Sam Stephenson 2007-04-24 03:58:34 +00:00
parent 4174060d5b
commit 7a324b859c
3 changed files with 11 additions and 0 deletions

View File

@ -1,5 +1,7 @@
*SVN*
* Add support for per-request onCreate callbacks to Ajax.Request. Closes #8011. [Andrew Dupont]
* Don't call evalResponse() when an Ajax response has no Content-type header. Closes #7827. [Tobie Langel]
* Automatically strip security delimiter comments from JSON strings before evaling them. The default delimiter is '/*-secure- ... */' or you can specify your own with the Prototype.JSONFilter regular expression. If you wrap your JSON response bodies in this delimiter on the server side, rogue external sites can't hijack potentially sensitive data via <script> tags. Closes #7910. [Tobie Langel]

View File

@ -101,6 +101,7 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
}
try {
if (this.options.onCreate) this.options.onCreate(this.transport);
Ajax.Responders.dispatch('onCreate', this, this.transport);
this.transport.open(this.method.toUpperCase(), this.url,

View File

@ -165,6 +165,14 @@
assertEqual('application/bogus; charset=UTF-8', response.responseText);
}
});
}},
testOnCreateCallback: function() {with(this) {
new Ajax.Request("fixtures/content.html", {
asynchronous: false,
onCreate: function(transport) { assertEqual(0, transport.readyState) },
onComplete: function(transport) { assertNotEqual(0, transport.readyState) }
});
}}
}, 'testlog');