[FIX] web: load async js modules as soon as possible

The module system allow modules to return a deferred.  When that
deferred resolves, the module is considered to have succesfully loaded,
and the result value is its value.  Then, the boot.js code used a
setTimeout (via _.defer) to load all its dependencies.

This is not wrong per se, but it empties the call stack, which give
other code the opportunity to interfere.  In particular, it is an issue
in phantomjs tests, because it causes a window between the
domcontentloaded event (which is a key event in website) and the actual
loading of all dependent modules.  This execution window can be used to
start some tours, but the code of those tours is waiting the next tick
to load, so horrible crashes happens.

This commit calls immediately process_jobs to avoid those issues.
This commit is contained in:
Géry Debongnie
2016-01-27 16:07:19 +01:00
parent d2f8485323
commit 36994a6616
+17 -12
View File
@@ -203,24 +203,29 @@
function process_job (job) {
var require = make_require(job);
var job_exec;
var def = $.Deferred();
try {
var def = $.Deferred();
$.when(job.factory.call(null, require)).then(
function (data) {
services[job.name] = data;
clearTimeout(time);
time = _.defer(odoo.process_jobs, jobs, services);
def.resolve();
}, function (e) {
job.rejected = e || true;
jobs.push(job);
def.resolve();
});
job_exec = job.factory.call(null, require);
jobs.splice(jobs.indexOf(job), 1);
job_deferred.push(def);
} catch (e) {
job.error = e;
}
if (!job.error) {
$.when(job_exec).then(
function (data) {
services[job.name] = data;
def.resolve();
odoo.process_jobs(jobs, services);
}, function (e) {
job.rejected = e || true;
jobs.push(job);
def.resolve();
}
);
}
}
function is_ready (job) {