Bug 1557031 - Fix test leaks caused by InactivePropertyHelper. r=miker.

We put some objects on the InactivePropertyHelper (node, rule),
but never reset those properties, which was causing leaks in some
inspector tests.
This patch adds a unselect function that clears all the references
added in the select function.

Differential Revision: https://phabricator.services.mozilla.com/D34844

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nicolas Chevobbe 2019-06-13 10:51:35 +00:00
parent 934be35969
commit 87dddd801b

View File

@ -266,11 +266,13 @@ class InactivePropertyHelper {
return false;
});
// Accessing this.style might throws, we wrap it in a try/catch block to avoid test
this.unselect();
// Accessing elStyle might throws, we wrap it in a try/catch block to avoid test
// failures.
let display;
try {
display = this.style ? this.style.display : null;
display = elStyle ? elStyle.display : null;
} catch (e) {}
return {
@ -296,6 +298,16 @@ class InactivePropertyHelper {
this._style = style;
}
/**
* Clear references to avoid leaks.
*/
unselect() {
this._node = null;
this._cssRule = null;
this._property = null;
this._style = null;
}
/**
* Provide a public reference to node.
*/