From 90e65f97623cdac6a6202e7b16209692ffa9110b Mon Sep 17 00:00:00 2001 From: Pierre Paridans Date: Tue, 17 May 2022 14:03:24 +0000 Subject: [PATCH] [FIX] web:
visiblity check regression in Chromium 97+ Since Chromium 97, folded `
` content has non-zero computed width and height which returns false-positive QUnit `assert.isNotVisible()` calls. In a nutshell, this was introduced in https://bugs.chromium.org/p/chromium/issues/detail?id=1185950 when Chromium implemented the ability for "Find in page" to search in folded `
`. To do so, the `content-visibility` rule was used instead of `display: none` which, even if functionally similar, has an impact on the values returned by `getBoundingClientRect()` (i.e. used in `assert.isNotVisible()`. A regression report was filled in https://bugs.chromium.org/p/chromium/issues/detail?id=1276028 to highlight this change of behavior. What emerged from this report's discussion is that Chromium has no intent to revert this change and instead put the emphasis on avoiding to use `getBoundingClientRect()` and similar methods for visibility check (even pushing a proposal for a `Element.isVisible()` API; cf. https://github.com/w3c/csswg-drafts/issues/6850). This commit works around this issue by forcing the content to `display: none`, like in the previous Chromium versions. closes odoo/odoo#91833 X-original-commit: b718e7eb5ceb827f59ac395577408b7bc54aa3f9 Signed-off-by: Aaron Bohy (aab) Signed-off-by: Pierre Paridans (app) --- addons/web/static/tests/qunit.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/addons/web/static/tests/qunit.js b/addons/web/static/tests/qunit.js index c5de8c71778..5ef1748e7a7 100644 --- a/addons/web/static/tests/qunit.js +++ b/addons/web/static/tests/qunit.js @@ -460,4 +460,16 @@ skippedEl.innerText = `${testSkippedCount} skipped`; } }); + + // ----------------------------------------------------------------------------- + // FIXME: This sounds stupid, it feels stupid... but it fixes visibility check in folded
since Chromium 97+ 💩 + // Since https://bugs.chromium.org/p/chromium/issues/detail?id=1185950 + // See regression report https://bugs.chromium.org/p/chromium/issues/detail?id=1276028 + // ----------------------------------------------------------------------------- + + QUnit.begin(() => { + const el = document.createElement("style"); + el.innerText = "details:not([open]) > :not(summary) { display: none; }"; + document.head.appendChild(el); + }); })();