Skip to content

Commit

Permalink
Bug 1514762 - Delay modifying the observer list until we hit the even…
Browse files Browse the repository at this point in the history
…t loop; r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D14830
  • Loading branch information
ehsan committed Dec 19, 2018
1 parent 789f480 commit 330e681
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion dom/base/nsGlobalWindowOuter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7265,7 +7265,12 @@ mozilla::dom::TabGroup* nsPIDOMWindowOuter::TabGroup() {
window->InitWasOffline();
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
obs->AddObserver(window, PERM_CHANGE_NOTIFICATION, true);
// Delay calling AddObserver until we hit the event loop, in case we may be
// in the middle of modifying the observer list somehow.
NS_DispatchToMainThread(
NS_NewRunnableFunction("PermChangeDelayRunnable", [obs, window] {
obs->AddObserver(window, PERM_CHANGE_NOTIFICATION, true);
}));
}
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (prefBranch) {
Expand Down

0 comments on commit 330e681

Please sign in to comment.