return result.result;
}
}, function() {
- console.error("JsonRPC communication error", _.toArray(arguments));
+ //console.error("JsonRPC communication error", _.toArray(arguments));
var def = $.Deferred();
return def.reject.apply(def, ["communication"].concat(_.toArray(arguments)));
});
});
// append the iframe to the DOM (will trigger the first load)
$form.after($iframe);
+ if (settings.timeout) {
+ realSetTimeout(function() {
+ deferred.reject({});
+ }, settings.timeout);
+ }
return deferred;
}
});
};
+var realSetTimeout = function(fct, millis) {
+ var finished = new Date().getTime() + millis;
+ var wait = function() {
+ var current = new Date().getTime();
+ if (current < finished) {
+ setTimeout(wait, finished - current);
+ } else {
+ fct();
+ }
+ };
+ setTimeout(wait, millis);
+};
+
openerp.Session = openerp.Class.extend(openerp.PropertiesMixin, {
triggers: {
'request': 'Request sent',
notEqual(result, origin_tmp, "Values in the different sessions should be different");
});
});*/
+ test('timeout-jsonrpc', {asserts: 1}, function () {
+ var session = new openerp.Session();
+ return session.rpc("/gen_session_id", {}, {timeout: 1}).then(function() {
+ ok(false, "the request incorrectly succeeded");
+ return $.when();
+ }, function(a, e) {
+ e.preventDefault();
+ ok(true, "the request correctly failed");
+ return $.when();
+ });
+ });
+ test('timeout-jsonprpc', {asserts: 1}, function () {
+ var session = new openerp.Session();
+ session.origin_server = false;
+ return session.rpc("/gen_session_id", {}, {timeout: 1}).then(function() {
+ ok(false, "the request incorrectly succeeded");
+ return $.when();
+ }, function(a, e) {
+ e.preventDefault();
+ ok(true, "the request correctly failed");
+ return $.when();
+ });
+ });
+ // desactivated because the phantomjs runner crash
+ test('timeout-jsonprpc2', {asserts: 1}, function () {
+ var session = new openerp.Session();
+ session.origin_server = false;
+ return session.rpc("/gen_session_id", {}, {force2step: true, timeout: 1}).then(function() {
+ ok(false, "the request incorrectly succeeded");
+ return $.when();
+ }, function(a, e) {
+ e.preventDefault();
+ ok(true, "the request correctly failed");
+ return $.when();
+ });
+ });
});
var login = "admin";