[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
This commit is contained in:
Antoine Guenet
2022-08-26 17:16:30 +02:00
parent 2b7b279218
commit d2200e1088
@@ -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.');