diff options
| author | Géry Debongnie <ged@odoo.com> | 2016-01-26 16:06:29 +0100 |
|---|---|---|
| committer | Géry Debongnie <ged@odoo.com> | 2016-01-27 16:07:19 +0100 |
| commit | 36994a6616fae35b702c6bb9f1ed3779ece66fa6 (patch) | |
| tree | 8b7cb3d082ffeaf87023ee6b7570af28277ba48e /addons/web/static/src | |
| parent | d2f848532399874eae7af3dc8b8983a058566f25 (diff) | |
[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.
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/boot.js | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/addons/web/static/src/js/boot.js b/addons/web/static/src/js/boot.js index 77115499b46..34abca7ef03 100644 --- a/addons/web/static/src/js/boot.js +++ b/addons/web/static/src/js/boot.js @@ -203,23 +203,28 @@ 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( + 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; - clearTimeout(time); - time = _.defer(odoo.process_jobs, jobs, services); def.resolve(); + odoo.process_jobs(jobs, services); }, function (e) { job.rejected = e || true; jobs.push(job); def.resolve(); - }); - jobs.splice(jobs.indexOf(job), 1); - job_deferred.push(def); - } catch (e) { - job.error = e; + } + ); } } |
