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 375205 e18a84324de25e10c3c39044cd5e6c5c0ad2aa46
parent 375204 934d877fa6cd083a32b3d068c272eaed67ef4903
child 375206 2cec20bb0f9d236f22eb359ab2987ae6c61e1d5c
push id10899
push userryanvm@gmail.com
push dateTue, 14 Mar 2017 21:50:32 +0000
treeherdermozilla-aurora@e18a84324de2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan, jcristau
bugs1346426
milestone54.0a2
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
@@ -1193,18 +1193,26 @@ TimeoutManager::Resume()
 }
 
 void
 TimeoutManager::Freeze()
 {
   MOZ_LOG(gLog, LogLevel::Debug,
           ("Freeze(TimeoutManager=%p)\n", this));
 
+  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;
     }