summaryrefslogtreecommitdiff
path: root/odoo/tests
diff options
context:
space:
mode:
authorstd-odoo <std@odoo.com>2020-11-24 13:32:51 +0000
committerstd-odoo <std@odoo.com>2020-12-03 08:12:33 +0000
commit6d08408a33880221b28f0f8a81d699825d927a48 (patch)
treeb659620e348b9703922e608aeac3f0b7a68093f3 /odoo/tests
parentfc962de2b60adaa1ffa3bf70bfadc5c3d17867b3 (diff)
[FIX] test_event_full: fix the registration testing tour
Bug === Sometimes, the registration testing tour failed. The bug can be semi-deterministic if we add a "sleep(1)" in the endpoint "/event/<event>/track". Reason ====== The reason for that is the service worker. It will pre-fetch all the links in the page (see "prefetch-pages"), so for the "Online Reveal" we will pre-fetch ~100 pages... If the server is slow, it can cause issues. If one endpoint takes some time, all other HTTP requests done by the service worker will be waiting for it. So, at the end of the testing tour, the service worker will continue to make HTTP requests (because it makes the request sequentially) and so some threads will still be created after the tour. Even if "_wait_remaining_requests" is called to wait those threads, as the service worker is still running, it will still continue to make HTTP requests, creating new threads... Fix === The solution to this issue is to kill the service workers of the browser when we stop the tour before waiting for the end of the "HTTP request threads". Task 2381066 closes odoo/odoo#62248 Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
Diffstat (limited to 'odoo/tests')
-rw-r--r--odoo/tests/common.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/odoo/tests/common.py b/odoo/tests/common.py
index df1b5409232..af270c5b7f8 100644
--- a/odoo/tests/common.py
+++ b/odoo/tests/common.py
@@ -1159,6 +1159,15 @@ class ChromeBrowser():
self.screencast_frames = []
sl_id = self._websocket_send('Page.stopLoading')
self._websocket_wait_id(sl_id)
+ clear_service_workers = """
+ if ('serviceWorker' in navigator) {
+ navigator.serviceWorker.getRegistrations().then(
+ registrations => registrations.forEach(r => r.unregister())
+ )
+ }
+ """
+ cl_id = self._websocket_send('Runtime.evaluate', params={'expression': clear_service_workers, 'awaitPromise': True})
+ self._websocket_wait_id(cl_id)
self._logger.info('Deleting cookies and clearing local storage')
dc_id = self._websocket_send('Network.clearBrowserCache')
self._websocket_wait_id(dc_id)