From 8f2673708a2dc32a527934ac20844e73f2786874 Mon Sep 17 00:00:00 2001 From: Samuel Degueldre Date: Wed, 6 Jul 2022 12:03:49 +0000 Subject: [PATCH] [FIX] tests: stop test runner from opening error dialogs when not ready Previously, the test runner would evaluate an expression to check if the browser test that is about to be run is ready, but before the test is ready, this expression may be invalid as the variables used in the expression may not be defined yet, causing a ReferenceError to be thrown by Chrome. In Chrome >=102, errors that are thrown when writing code in the console or by using Runtime.evaluate over CDP are thrown in the context of the current tab, which means that they trip registered error handlers in that tab. In Odoo, this means that we show error dialogs with the traceback. In the tour manager, when we are looking for an element to trigger, we only look for that element inside dialogs if there are any dialogs open (unless the in_dialog option is false on that specific step). This means that if an error dialog is open, most tours will fail (which is actually what we want). In order to avoid opening a bunch of error dialogs while waiting for the tour to be ready, we simply wrap the ready expression in a try catch so that it doesn't throw an error, and simply returns a undefined until the tour is ready instead of throwing a ReferenceError. closes odoo/odoo#95635 X-original-commit: 3872dbd63233d4c6d961a3cd896b84e4301a1f84 Signed-off-by: Xavier Morel (xmo) Signed-off-by: Samuel Degueldre --- odoo/tests/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/tests/common.py b/odoo/tests/common.py index 35680eebb4e..734b9f3d2dd 100644 --- a/odoo/tests/common.py +++ b/odoo/tests/common.py @@ -1342,7 +1342,7 @@ class ChromeBrowser: break result = self._websocket_request('Runtime.evaluate', params={ - 'expression': ready_code, + 'expression': "try { %s } catch {}" % ready_code, 'awaitPromise': True, }, timeout=timeout-taken)['result']