jsonp-tests.js revision 021383d5b6e57dcc00cc55f7a4d715b3e8720ba2
name : "callbacks",
_should: {
ignore: {
// Get (v3.3) doesn't support onerror in recent webkit
"failure handler in callback object should execute": true
}
},
"callback function as second arg should be success handler": function () {
var self = this;
});
});
},
"success handler in callback object should execute": function () {
var self = this;
Y.jsonp("server/service.php?&callback={callback}", {
on: {
});
}
}
});
},
"failure handler in callback object should execute": function () {
var self = this;
Y.jsonp("server/404.php?&callback={callback}", {
on: {
});
},
failure: function () {
// Pass
}
}
});
},
"failure handler in callback object should not execute for successful io": function () {
var self = this;
Y.jsonp("server/service.php?&callback={callback}", {
on: {
// Pass
},
failure: function () {
});
}
}
});
}
// failure for bogus response data (not yet implemented)
// missing {callback} (not sure how to test. No callback would be attached.
// Maybe have the service create a property on YUI and have the test
// look for that after a time?)
// missing success handler (logs a warning)
// JSONPRequest + send
// JSONPRequest + send with config overrides (not yet implemented)
}));
name : "context and args"
}));
name : "format"
}));
name : "allowCache",
"allowCache should preserve the same callback": function () {
var test = this,
remaining = 2,
allowCache: true,
on: {
if (callback) {
});
} else if (--remaining) {
} else {
// Pass
});
}
} else {
}
}
}
});
this.wait();
},
"allowCache should not clear proxy if another send() is pending response":
function () {
var test = this,
callbacks = [],
allowCache: true,
on: {
});
});
}
}
}
});
this.wait();
}
}));
name : "timeout",
"timeout should not flush the global proxy": function () {
var test = this,
timeoutCalled = false,
timeout: 1000,
on: {
});
},
timeout: function () {
timeoutCalled = true;
}
}
}),
// Success is measured by the success callback NOT being executed,
// but we're in an async operation, so I need something to trigger
// a test.resume(..). So I'm finding the added script tag and
// hooking a separate onload handler to it, which would execute after
// the success handler if it is called due to callbacks executing in
// subscription order. Not pretty, but better than a longer setTimeout?
})[0];
Y.on('load', function () {
});
}, newScript);
}
/*
,
"timeout should not flush the global proxy across multiple send calls": function () {
// README
// Stubbed from the test above. This test needs to contact the
// serverat the same url, but get varying delays. This means to
// properly test, the server needs to behave randomly, and this test
// needs to iterate until that random behavior matches the expected
// test behavior. Which is icky.
var test = this,
timeoutCalled = false,
jsonp = new Y.JSONPRequest('server/service.php?wait=2&callback={callback}', {
timeout: 1000,
on: {
success: function (data) {
test.resume(function () {
Y.Assert.fail("Success callback executed after timeout");
});
},
timeout: function () {
timeoutCalled = true;
}
}
}),
scripts = Y.all('script')._nodes,
newScript;
jsonp.send();
newScript = Y.Array.filter(Y.all('script')._nodes, function (s) {
return Y.Array.indexOf(scripts, s) === -1;
})[0];
Y.on('load', function () {
test.resume(function () {
Y.Assert.isTrue(timeoutCalled);
});
}, newScript);
test.wait(3000);
}
*/
}));