2014-03-24 06:59:45 +01:00
|
|
|
if (location.protocol != "file:") {
|
|
|
|
module("tinymce.util.XHR");
|
|
|
|
|
|
|
|
asyncTest("Successful request", function() {
|
2014-08-09 22:55:34 +02:00
|
|
|
expect(5);
|
|
|
|
|
|
|
|
tinymce.util.XHR.on('beforeSend', function(e) {
|
|
|
|
e.xhr.test = 123;
|
|
|
|
e.settings.test = 456;
|
|
|
|
});
|
2014-03-24 06:59:45 +01:00
|
|
|
|
|
|
|
tinymce.util.XHR.send({
|
2014-08-09 22:55:34 +02:00
|
|
|
url: 'tinymce/util/json_rpc_ok.js',
|
2014-03-24 06:59:45 +01:00
|
|
|
success: function(data, xhr, input) {
|
|
|
|
equal(tinymce.trim(data), '{"result": "Hello JSON-RPC", "error": null, "id": 1}');
|
|
|
|
ok(!!xhr.status);
|
|
|
|
equal(input.url, 'tinymce/util/json_rpc_ok.js');
|
2014-08-09 22:55:34 +02:00
|
|
|
equal(xhr.test, 123);
|
|
|
|
equal(input.test, 456);
|
2014-03-24 06:59:45 +01:00
|
|
|
start();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
asyncTest("Unsuccessful request", function() {
|
|
|
|
expect(3);
|
|
|
|
|
|
|
|
tinymce.util.XHR.send({
|
2014-08-09 22:55:34 +02:00
|
|
|
url: 'tinymce/util/404.js',
|
2014-03-24 06:59:45 +01:00
|
|
|
error: function(type, xhr, input) {
|
|
|
|
equal(type, 'GENERAL');
|
|
|
|
ok(!!xhr.status);
|
|
|
|
equal(input.url, 'tinymce/util/404.js');
|
|
|
|
start();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|