diff options
| author | MOENS Alexandre <mao@odoo.com> | 2018-08-21 12:00:49 +0200 |
|---|---|---|
| committer | len-odoo <35492570+len-odoo@users.noreply.github.com> | 2018-09-14 16:13:35 +0200 |
| commit | b83db271354ee8ecabf4a39c96f3a187dd5535d5 (patch) | |
| tree | 49b07c17770352e4c5f058fc6c96ea5315c95539 /addons/web/static/tests/fields/basic_fields_tests.js | |
| parent | 70ed882088401c093e6a1180746b5637fe96da32 (diff) | |
[FIX] web: JournalDashboardGraph widget crash Mk.II
Hardening of commit:995610c065bf0242cb5023cfad2940234395739e
The JournalDashboardGraph requires nv, which is lazyloaded.
However it requires nvd3.js which is loaded after nv.d3.js.
A function called in destroy is defined by nv.d3.js,
which can make the crashhappen with the right (wrong) timing.
opw 1873749
Diffstat (limited to 'addons/web/static/tests/fields/basic_fields_tests.js')
| -rw-r--r-- | addons/web/static/tests/fields/basic_fields_tests.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index fade0282f69..1133bed08b5 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -1902,6 +1902,45 @@ QUnit.module('basic_fields', { assert.verifySteps(['destroy']); }); + QUnit.test('graph dashboard widget can be destroyed when nv is partially loaded', function (assert) { + // this test ensures that the JournalDashboardGraph widget doesn't crash + // when being destroyed before nv has been completely loaded + assert.expect(2); + + testUtils.patch(basicFields.JournalDashboardGraph, { + destroy: function () { + assert.step('destroy'); + // nv is fully loaded only when nvd3.js has been loaded + // which happens sequentially after nv.d3.js + // we simulate this race condition with: + var offWindowResize = window.nv.utils.offWindowResize; + window.nv.utils.offWindowResize = undefined; + this._super.apply(this, arguments); + window.nv.utils.offWindowResize = offWindowResize; + }, + }); + + var kanban = createView({ + View: KanbanView, + model: 'partner', + data: this.data, + arch: '<kanban class="o_kanban_test">' + + '<field name="graph_type"/>' + + '<templates><t t-name="kanban-box">' + + '<div>' + + '<field name="graph_data" t-att-graph_type="record.graph_type.raw_value" widget="dashboard_graph"/>' + + '</div>' + + '</t>' + + '</templates></kanban>', + domain: [['id', 'in', [1]]], + }); + + kanban.destroy(); + testUtils.unpatch(basicFields.JournalDashboardGraph); + + assert.verifySteps(['destroy']); + }); + QUnit.module('AceEditor'); QUnit.test('ace widget on text fields works', function (assert) { |
