From 76700a4a1e1ca4aa675c9f48bae1e2bcbbdeb654 Mon Sep 17 00:00:00 2001 From: Joseph Caburnay Date: Wed, 24 Jun 2020 14:42:41 +0000 Subject: [PATCH] [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) --- addons/web_tour/static/src/js/tour_service.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/web_tour/static/src/js/tour_service.js b/addons/web_tour/static/src/js/tour_service.js index b619bb42430..a055c987396 100644 --- a/addons/web_tour/static/src/js/tour_service.js +++ b/addons/web_tour/static/src/js/tour_service.js @@ -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();