From d2200e10883ee042485571c17caa68576fe185ab Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Mon, 22 Aug 2022 14:56:36 +0000 Subject: [PATCH] [FIX] web_editor: trigger selectionchange in tests When the editor's test utils set the selection, they did not trigger the selectionchange event, which means the editor's listener didn't get called. Part-of: odoo/odoo#92200 --- .../web_editor/static/src/js/editor/odoo-editor/test/utils.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/test/utils.js b/addons/web_editor/static/src/js/editor/odoo-editor/test/utils.js index ad6571e5c98..de34e8a1e54 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/test/utils.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/test/utils.js @@ -156,6 +156,7 @@ export function setTestSelection(selection, doc = document) { } catch { // Firefox yells not happy when setting selection on elem with contentEditable=false. } + triggerEvent(selection.anchorNode, 'selectionchange'); } /** @@ -545,6 +546,7 @@ function getEventConstructor(win, type) { 'paste': win.ClipboardEvent, 'touchstart': win.TouchEvent, 'touchend': win.TouchEvent, + 'selectionchange': win.Event, }; if (!eventTypes[type]) { throw new Error('The event "' + type + '" is not implemented for the tests.');