[IMP] web_tour: observe characterData mutation

Prior to owl, dom changes is normally performed by removing an element in the
dom and replacing it with new one. This is not a problem for the tour service
even if the used mutation observer is only observing attributes and childList
changes.

However, using owl is now a different story because it can change even just a
text of a node when rendering. If after a step this is the only change that
happened in the dom and you are expecting in the next step that the text has
changed, then the tour fails in that next step, but you are given a screenshot
containing the value you are expecting in the failed step. This is a false
negative.

It means that observing only classList and attributes changes in the dom is
not enough, and it is now necessary to observe characterData changes in order
to avoid the false negatives in tour tests.

This change is expected to incur performance tradeoff so the delay in calling
the mutation callback is increased from 500 to 750ms.

closes odoo/odoo#53649

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
Joseph Caburnay
2020-06-25 11:18:48 +00:00
parent c39e92c9ea
commit 76700a4a1e
@@ -53,6 +53,10 @@ return session.is_bound.then(function () {
return false;
}
if (mutation.type === 'characterData') {
return true;
}
if (mutation.type === 'childList') {
// If it is a modification to the DOM hierarchy, only
// consider the addition/removal of tracked nodes.
@@ -130,7 +134,7 @@ return session.is_bound.then(function () {
const observer = new MutationObserver(mutations => {
clearTimeout(mutationTimer);
currentMutations.push(...mutations);
mutationTimer = setTimeout(() => _processMutations(), 500);
mutationTimer = setTimeout(() => _processMutations(), 750);
});
// Now that the observer is configured, we have to start it when needed.
@@ -144,6 +148,7 @@ return session.is_bound.then(function () {
childList: true,
subtree: true,
attributeOldValue: true,
characterData: true,
});
}
resolve();