Bug 1253129 - Prevent a logged warning from keeping the extension global alive after being destroyed. r=mixedpuppy

Differential Revision: https://phabricator.services.mozilla.com/D80936
This commit is contained in:
Luca Greco 2020-06-26 16:49:20 +00:00
Родитель e2f81589ab
Коммит 7a233cc08a
1 изменённых файлов: 15 добавлений и 1 удалений

Просмотреть файл

@ -516,8 +516,22 @@ class Context {
* @param {Error|string} error * @param {Error|string} error
*/ */
logError(error) { logError(error) {
if (this.cloneScope) {
Cu.reportError(
// Error objects logged using Cu.reportError are not associated
// to the related innerWindowID. This results in a leaked docshell
// since consoleService cannot release the error object when the
// extension global is destroyed.
typeof error == "string" ? error : String(error),
// Report the error with the appropriate stack trace when the
// is related to an actual extension global (instead of being
// related to a manifest validation).
this.principal && ChromeUtils.getCallerLocation(this.principal)
);
} else {
Cu.reportError(error); Cu.reportError(error);
} }
}
/** /**
* Returns the name of the value currently being normalized. For a * Returns the name of the value currently being normalized. For a