Bug 1346426 - Don't crash if a window is frozen while there is a dummy timer in the list. r=ehsan, a=jcristau
authorBen Kelly <ben@wanderview.com>
Mon, 13 Mar 2017 15:26:22 -0400
changeset 379057 fa57d7bb08727b72deca53dcd91c2041443e82e7
parent 379056 93673f1f4f7d4f1e0331e3bce48bc95928bb552b
child 379058 d5d5a6044fc54d03f932cd21d2ea7250b51ff486
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan, jcristau
bugs1346426
milestone53.0
Bug 1346426 - Don't crash if a window is frozen while there is a dummy timer in the list. r=ehsan, a=jcristau
dom/base/TimeoutManager.cpp
--- a/dom/base/TimeoutManager.cpp
+++ b/dom/base/TimeoutManager.cpp
@@ -1100,18 +1100,26 @@ TimeoutManager::Resume()
     // Add a reference for the new timer's closure.
     aTimeout->AddRef();
   });
 }
 
 void
 TimeoutManager::Freeze()
 {
+  DebugOnly<bool> _seenDummyTimeout = false;
+
   TimeStamp now = TimeStamp::Now();
   ForEachUnorderedTimeout([&](Timeout* aTimeout) {
+    if (!aTimeout->mWindow) {
+      NS_ASSERTION(!_seenDummyTimeout, "More than one dummy timeout?!");
+      _seenDummyTimeout = true;
+      return;
+    }
+
     // Save the current remaining time for this timeout.  We will
     // re-apply it when the window is Thaw()'d.  This effectively
     // shifts timers to the right as if time does not pass while
     // the window is frozen.
     TimeDuration delta(0);
     if (aTimeout->When() > now) {
       delta = aTimeout->When() - now;
     }