Bug 1368335 - Don't dispatch idle executor when window has suspended. r=smaug
authorAndreas Farre <farre@mozilla.com>
Mon, 29 May 2017 14:13:54 +0200
changeset 586201 40669ce64bf7786d2a96598128db61152301a3db
parent 586200 3320e2c5c0b414af4e965b8aedc7f8c66e96eb84
child 586202 7cbe2db1830c37aaf82c6af533e53c36d0f11753
push id61331
push userbmo:cpearce@mozilla.com
push dateMon, 29 May 2017 23:54:26 +0000
reviewerssmaug
bugs1368335
milestone55.0a1
Bug 1368335 - Don't dispatch idle executor when window has suspended. r=smaug
dom/base/nsGlobalWindow.cpp
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -862,17 +862,21 @@ nsGlobalWindow::ExecuteIdleRequest(TimeS
 
   if (Performance* perf = GetPerformance()) {
     deadline = perf->GetDOMTiming()->TimeStampToDOMHighRes(aDeadline);
   }
 
   mIdleRequestExecutor->MaybeUpdateIdlePeriodLimit();
   nsresult result = RunIdleRequest(request, deadline, false);
 
-  mIdleRequestExecutor->MaybeDispatch();
+  // Running the idle callback could've suspended the window, in which
+  // case mIdleRequestExecutor will be null.
+  if (mIdleRequestExecutor) {
+    mIdleRequestExecutor->MaybeDispatch();
+  }
   return result;
 }
 
 class IdleRequestTimeoutHandler final : public TimeoutHandler
 {
 public:
   IdleRequestTimeoutHandler(JSContext* aCx,
                             IdleRequest* aIdleRequest,