[FIX] web: TouchEvent doesn't exist in FireFox and Safari

Since commit odoo/odoo@c96e3b96f3
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>
This commit is contained in:
Romeo Fragomeli
2021-02-25 13:27:53 +00:00
parent 28560f2cd5
commit 2cf7c7f357
@@ -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.
*