diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index ed3f449e4d3a..b037d9af7b4a 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -14524,18 +14524,15 @@ nsGlobalWindow::GetGroupMessageManager(const nsAString& aGroup, nsGlobalChromeWindow* myself = static_cast(this); nsCOMPtr messageManager = - myself->mGroupMessageManagers.Get(aGroup); - - if (!messageManager) { - nsFrameMessageManager* parent = - static_cast(GetMessageManager(aError)); - - messageManager = new nsFrameMessageManager(nullptr, - parent, - MM_CHROME | MM_BROADCASTER); - myself->mGroupMessageManagers.Put(aGroup, messageManager); - } + myself->mGroupMessageManagers.LookupForAdd(aGroup).OrInsert( + [this, &aError] () { + nsFrameMessageManager* parent = + static_cast(GetMessageManager(aError)); + return new nsFrameMessageManager(nullptr, + parent, + MM_CHROME | MM_BROADCASTER); + }); return messageManager; }