Bug 1492990: Make _tabIds map not leak. r=aswan

There are cases when we asynchronously handle tab events, and therefore try to
attach an ID to a tab after it's already been removed. In practice, this will
typically only affect tests, since it requires the tab to be removed
immediately after a related event is dispatched, but in those cases, it causes
a leak, since there's no way for the tab to be removed after the map after
that point.

We should ideally get rid of those weird async hacks, but either way, we
should ensure that we never add a tab to the map after it's already been
removed. This patch does that.

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

--HG--
extra : rebase_source : 9b6bea993f6261596f2c6283d6569632d395d68b
This commit is contained in:
Kris Maglione 2018-09-20 14:35:27 -07:00
Родитель ba8f70c50a
Коммит def32ee738
1 изменённых файлов: 3 добавлений и 0 удалений

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

@ -327,6 +327,9 @@ class TabTracker extends TabTrackerBase {
}
setId(nativeTab, id) {
if (!nativeTab.parentNode) {
throw new Error("Cannot attach ID to a destroyed tab.");
}
this._tabs.set(nativeTab, id);
if (nativeTab.linkedBrowser) {
this._browsers.set(nativeTab.linkedBrowser, id);