jsonp-url-tests.js revision 021383d5b6e57dcc00cc55f7a4d715b3e8720ba2
0N/AYUI.add('jsonp-url-tests', function(Y) {
0N/A
0N/Avar suite = new Y.Test.Suite("Y.JSONPRequest and Y.jsonp");
0N/A
0N/Asuite.add(new Y.Test.Case({
0N/A name : "Callback in URL",
0N/A
0N/A "callback in URL should be executed": function () {
0N/A var self = this;
0N/A
0N/A Y.config.win.globalFunction = function (json) {
0N/A self.resume(function () {
0N/A Y.config.win.globalFunction = undefined;
0N/A Y.Assert.isObject(json);
0N/A });
0N/A };
0N/A Y.jsonp("server/service.php?&callback=globalFunction");
0N/A
0N/A self.wait();
0N/A },
1054N/A
1190N/A "inline callback should be replaced if function passed": function () {
1185N/A var self = this;
0N/A
0N/A Y.config.win.globalFunction = function (json) {
65N/A self.resume(function () {
125N/A Y.config.win.globalFunction = undefined;
125N/A Y.Assert.fail("inline function should not be used");
1185N/A });
58N/A };
77N/A
125N/A Y.jsonp("server/service.php?&callback=globalFunction", function (data) {
125N/A self.resume(function () {
125N/A Y.config.win.globalFunction = undefined;
1092N/A Y.Assert.isObject(data);
1016N/A });
125N/A });
1092N/A
261N/A self.wait();
261N/A },
583N/A
312N/A "inline callback should be replaced if success function provided in config": function () {
1062N/A var self = this;
312N/A
467N/A Y.config.win.globalFunction = function (json) {
428N/A self.resume(function () {
126N/A Y.config.win.globalFunction = undefined;
1088N/A Y.Assert.fail("inline function should not be used");
58N/A });
394N/A };
1185N/A
8N/A Y.jsonp("server/service.php?&callback=globalFunction", {
1185N/A on: {
1185N/A success: function (data) {
1185N/A self.resume(function () {
77N/A Y.config.win.globalFunction = undefined;
0N/A Y.Assert.isObject(data);
0N/A });
0N/A }
0N/A }
0N/A });
0N/A
491N/A self.wait();
439N/A },
491N/A
465N/A "complex nested callback in URL should be executed": function () {
465N/A var self = this;
491N/A
491N/A Y.config.win.deeply = [
491N/A null,
886N/A null,
886N/A {
886N/A nested: {
886N/A global: {
886N/A func: {
886N/A tion: function (json) {
491N/A self.resume(function () {
491N/A Y.config.win.deeply = undefined;
491N/A Y.Assert.isObject(json);
491N/A });
65N/A }
65N/A }
65N/A }
65N/A }
464N/A }
0N/A ];
58N/A
312N/A Y.jsonp('server/service.php?&callback=deeply[2].nested["global"].func["tion"]');
312N/A
1185N/A self.wait();
260N/A },
491N/A
428N/A "callback relative to Y should be executed": function () {
376N/A var self = this;
376N/A
0N/A Y.callbackFunction = function (json) {
11N/A self.resume(function () {
0N/A delete Y.callbackFunction;
240N/A Y.Assert.isObject(json);
1016N/A });
58N/A };
58N/A Y.jsonp("server/service.php?&callback=callbackFunction");
58N/A
58N/A self.wait();
77N/A },
207N/A
1185N/A "nested inline callback relative to Y should be executed": function () {
207N/A var self = this;
910N/A
1190N/A Y.deeply = [
77N/A null,
260N/A null,
112N/A {
77N/A nested: {
77N/A global: {
77N/A func: {
77N/A tion: function (json) {
260N/A self.resume(function () {
77N/A delete Y.deeply;
77N/A Y.Assert.isObject(json);
77N/A });
491N/A }
1088N/A }
77N/A }
491N/A }
111N/A }
111N/A ];
111N/A
111N/A Y.jsonp('server/service.php?&callback=deeply[2].nested["global"].func["tion"]');
1088N/A self.wait();
111N/A },
111N/A
111N/A "inline callback including 'Y.' should be executed": function () {
491N/A var self = this;
1088N/A
1088N/A Y.callbackFunction = function (json) {
1088N/A self.resume(function () {
1088N/A delete Y.callbackFunction;
1088N/A Y.Assert.isObject(json);
1088N/A });
886N/A };
111N/A Y.jsonp("server/service.php?&callback=Y.callbackFunction");
491N/A
77N/A self.wait();
77N/A },
1185N/A
491N/A "nested inline callback should be replaced if function passed": function () {
491N/A var self = this;
491N/A
77N/A Y.deeply = [
491N/A null,
1088N/A null,
1062N/A {
491N/A nested: {
491N/A global: {
1088N/A func: {
491N/A tion: function (json) {
491N/A self.resume(function () {
491N/A delete Y.deeply;
491N/A Y.Assert.fail("inline function should not be used");
491N/A });
491N/A }
491N/A }
491N/A }
1088N/A }
491N/A }
491N/A ];
491N/A
491N/A Y.jsonp('server/service.php?&callback=deeply[2].nested["global"].func["tion"]', function (data) {
491N/A self.resume(function () {
491N/A delete Y.deeply;
491N/A Y.Assert.isObject(data);
491N/A });
1088N/A });
491N/A
1088N/A self.wait();
491N/A },
491N/A
491N/A "nested inline callback should be replaced if success function provided in config": function () {
491N/A var self = this;
491N/A
491N/A Y.deeply = [
491N/A null,
491N/A null,
491N/A {
491N/A nested: {
491N/A global: {
491N/A func: {
1016N/A tion: function (json) {
1016N/A self.resume(function () {
1016N/A delete Y.deeply;
491N/A Y.Assert.fail("inline function should not be used");
491N/A });
491N/A }
491N/A }
491N/A }
491N/A }
491N/A }
491N/A ];
491N/A
799N/A Y.jsonp('server/service.php?&callback=deeply[2].nested["global"].func["tion"]', {
1088N/A on: {
799N/A success: function (data) {
886N/A self.resume(function () {
886N/A delete Y.deeply;
886N/A Y.Assert.isObject(data);
886N/A });
886N/A }
891N/A }
886N/A });
891N/A
886N/A self.wait();
886N/A }
886N/A
886N/A}));
886N/A
886N/AY.Test.Runner.add(suite);
491N/A
491N/A
491N/A}, '@VERSION@' ,{requires:['jsonp-url', 'test']});
1088N/A