Skip to content
Snippets Groups Projects
Commit d86cc5c0 authored by Aaron Bohy's avatar Aaron Bohy
Browse files

[FIX] web: ui service: remove leak in tests

Before this commit, the ui service listened to the "change" event
on several MediaQueryList corresponding to specific window sizes.
However, those event handlers were never removed. Whereas this
isn't an issue in production (services are started once and live
forever), this caused a memory leak in tests, where services are
deployed on demand, test by test.

There is no cleanup function for services (since they live forever
by nature). In the test environment, we have a solution for handlers
bound on window (i.e. window.addEventListener), by monkey patching
the function (thanks to the browser object), and automatically
removing all handlers bound during a test, at the end of that test.

This commit fixes the memory leak by no longer using addEventListener
on MediaQueryList (as this is a deprecated feature anyway [1]), and
simply using window (or browser)'s addEventListener instead. This
leak sometimes produced a timeout in the QUnit test suite [2].

[1] https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList/addListener
[2] https://runbot.odoo.com/web#id=2374&action=573&model=runbot.build.error&view_type=form&cids=1&menu_id=405

Part-of: odoo/odoo#78621
parent f62503a5
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment