From 2cf7c7f357200c2ee4c22d1eae38ecba59c51688 Mon Sep 17 00:00:00 2001 From: Romeo Fragomeli <rfr@odoo.com> Date: Wed, 24 Feb 2021 16:18:11 +0000 Subject: [PATCH] [FIX] web: TouchEvent doesn't exist in FireFox and Safari MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since commit odoo/odoo@c96e3b96f307685d03d240fac81fb0e83ca85f1d the TouchEvent constructor was added to the test utils. In FireFox (no touch mode) and Safari (desktop) this constructor doesn't exist and so the test suite won't start anymore. This commit, inserts TouchEvent constructor only when it's supported by the browser. So now we can run the tests in FireFox and Safari again. closes odoo/odoo#66846 X-original-commit: 296fd86ddf90cff8d5b8f095d0c51b1c5a8b59ca Signed-off-by: Géry Debongnie (ged) <ged@openerp.com> Signed-off-by: rfr-odoo <rfr-odoo@users.noreply.github.com> --- addons/web/static/tests/helpers/test_utils_dom.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/addons/web/static/tests/helpers/test_utils_dom.js b/addons/web/static/tests/helpers/test_utils_dom.js index f85fe9bec8b1..ded399572eea 100644 --- a/addons/web/static/tests/helpers/test_utils_dom.js +++ b/addons/web/static/tests/helpers/test_utils_dom.js @@ -81,17 +81,21 @@ odoo.define('web.test_utils_dom', function (require) { dragover: { constructor: DragEvent, processParameters: onlyBubble }, drop: { constructor: DragEvent, processParameters: onlyBubble }, - touchstart: { constructor: TouchEvent, processParameters: touchEventMapping }, - touchend: { constructor: TouchEvent, processParameters: touchEventMapping }, - touchmove: { constructor: TouchEvent, processParameters: touchEventMapping }, - touchcancel: { constructor: TouchEvent, processParameters: touchEventCancelMapping }, - input: { constructor: InputEvent, processParameters: onlyBubble }, compositionstart: { constructor: CompositionEvent, processParameters: onlyBubble }, compositionend: { constructor: CompositionEvent, processParameters: onlyBubble }, }; + if (typeof TouchEvent === 'function') { + Object.assign(EVENT_TYPES, { + touchstart: {constructor: TouchEvent, processParameters: touchEventMapping}, + touchend: {constructor: TouchEvent, processParameters: touchEventMapping}, + touchmove: {constructor: TouchEvent, processParameters: touchEventMapping}, + touchcancel: {constructor: TouchEvent, processParameters: touchEventCancelMapping}, + }); + } + /** * Check if an object is an instance of EventTarget. * -- GitLab