Bug 1532351. Remove idle observer API on navigator. r=farre
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 05 Mar 2019 08:32:57 +0000
changeset 520255 84c79296c4ac7442815d6b5841910a3c51b74bd1
parent 520254 c9301ae941a18690438f351eee32c709bfd95ec2
child 520256 6da1179f8eff22e45ead3b9b579de6b8a89e7374
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfarre
bugs1532351
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1532351. Remove idle observer API on navigator. r=farre Differential Revision: https://phabricator.services.mozilla.com/D22029
dom/base/Navigator.cpp
dom/base/Navigator.h
dom/base/nsGlobalWindowInner.cpp
dom/base/nsGlobalWindowInner.h
dom/base/nsGlobalWindowOuter.cpp
dom/base/nsGlobalWindowOuter.h
dom/base/nsPIDOMWindow.h
dom/base/test/chrome.ini
dom/base/test/test_bug715041.xul
dom/base/test/test_bug715041_removal.xul
dom/tests/mochitest/general/chrome.ini
dom/tests/mochitest/general/test_idleapi_permissions.html
dom/webidl/Navigator.webidl
modules/libpref/init/all.js
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -660,38 +660,16 @@ void VibrateWindowListener::RemoveListen
   }
   NS_NAMED_LITERAL_STRING(visibilitychange, "visibilitychange");
   target->RemoveSystemEventListener(visibilitychange, this,
                                     true /* use capture */);
 }
 
 }  // namespace
 
-void Navigator::AddIdleObserver(MozIdleObserver& aIdleObserver,
-                                ErrorResult& aRv) {
-  if (!mWindow) {
-    aRv.Throw(NS_ERROR_UNEXPECTED);
-    return;
-  }
-  if (NS_FAILED(mWindow->RegisterIdleObserver(aIdleObserver))) {
-    NS_WARNING("Failed to add idle observer.");
-  }
-}
-
-void Navigator::RemoveIdleObserver(MozIdleObserver& aIdleObserver,
-                                   ErrorResult& aRv) {
-  if (!mWindow) {
-    aRv.Throw(NS_ERROR_UNEXPECTED);
-    return;
-  }
-  if (NS_FAILED(mWindow->UnregisterIdleObserver(aIdleObserver))) {
-    NS_WARNING("Failed to remove idle observer.");
-  }
-}
-
 void Navigator::SetVibrationPermission(bool aPermitted, bool aPersistent) {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsTArray<uint32_t> pattern;
   pattern.SwapElements(mRequestedVibrationPattern);
 
   if (!mWindow) {
     return;
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -52,17 +52,16 @@ namespace dom {
 class Permissions;
 
 namespace battery {
 class BatteryManager;
 }  // namespace battery
 
 class Promise;
 
-class MozIdleObserver;
 class Gamepad;
 class GamepadServiceTest;
 class NavigatorUserMediaSuccessCallback;
 class NavigatorUserMediaErrorCallback;
 class MozGetUserMediaDevicesSuccessCallback;
 
 struct MIDIOptions;
 
@@ -153,18 +152,16 @@ class Navigator final : public nsISuppor
   void GetVendor(nsAString& aVendor);
   void GetProductSub(nsAString& aProductSub);
   bool CookieEnabled();
   void GetBuildID(nsAString& aBuildID, CallerType aCallerType,
                   ErrorResult& aRv) const;
   bool JavaEnabled() { return false; }
   uint64_t HardwareConcurrency();
   bool TaintEnabled() { return false; }
-  void AddIdleObserver(MozIdleObserver& aObserver, ErrorResult& aRv);
-  void RemoveIdleObserver(MozIdleObserver& aObserver, ErrorResult& aRv);
 
   already_AddRefed<LegacyMozTCPSocket> MozTCPSocket();
   network::Connection* GetConnection(ErrorResult& aRv);
   MediaDevices* GetMediaDevices(ErrorResult& aRv);
 
   void GetGamepads(nsTArray<RefPtr<Gamepad>>& aGamepads, ErrorResult& aRv);
   GamepadServiceTest* RequestGamepadServiceTest();
   already_AddRefed<Promise> GetVRDisplays(ErrorResult& aRv);
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -38,17 +38,16 @@
 #include "mozilla/dom/VisualViewport.h"
 #include "mozilla/dom/WindowProxyHolder.h"
 #include "mozilla/IntegerPrintfMacros.h"
 #if defined(MOZ_WIDGET_ANDROID)
 #  include "mozilla/dom/WindowOrientationObserver.h"
 #endif
 #include "nsDOMOfflineResourceList.h"
 #include "nsError.h"
-#include "nsIIdleService.h"
 #include "nsISizeOfEventTarget.h"
 #include "nsDOMJSUtils.h"
 #include "nsArrayUtils.h"
 #include "nsDOMWindowList.h"
 #include "mozilla/dom/WakeLock.h"
 #include "mozilla/dom/power/PowerManagerService.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIDocumentLoader.h"
@@ -337,28 +336,21 @@ static nsGlobalWindowOuter* GetOuterWind
 // Amount of time allowed between alert/prompt/confirm before enabling
 // the stop dialog checkbox.
 #define DEFAULT_SUCCESSIVE_DIALOG_TIME_LIMIT 3  // 3 sec
 
 // Maximum number of successive dialogs before we prompt users to disable
 // dialogs for this window.
 #define MAX_SUCCESSIVE_DIALOG_COUNT 5
 
-// Idle fuzz time upper limit
-#define MAX_IDLE_FUZZ_TIME_MS 90000
-
-// Min idle notification time in seconds.
-#define MIN_IDLE_NOTIFICATION_TIME_S 1
-
 // Max number of Report objects
 #define MAX_REPORT_RECORDS 100
 
 static LazyLogModule gDOMLeakPRLogInner("DOMLeakInner");
 
-static bool gIdleObserversAPIFuzzTimeDisabled = false;
 static FILE* gDumpFile = nullptr;
 
 nsGlobalWindowInner::InnerWindowByIdTable*
     nsGlobalWindowInner::sInnerWindowsById = nullptr;
 
 bool nsGlobalWindowInner::sDragServiceDisabled = false;
 bool nsGlobalWindowInner::sMouseDown = false;
 
@@ -837,24 +829,18 @@ class PromiseDocumentFlushedResolver fin
 
 //*****************************************************************************
 //***    nsGlobalWindowInner: Object Management
 //*****************************************************************************
 
 nsGlobalWindowInner::nsGlobalWindowInner(nsGlobalWindowOuter* aOuterWindow)
     : nsPIDOMWindowInner(aOuterWindow->AsOuter()),
       mozilla::webgpu::InstanceProvider(this),
-      mIdleFuzzFactor(0),
-      mIdleCallbackIndex(-1),
-      mCurrentlyIdle(false),
-      mAddActiveEventFuzzTime(true),
       mWasOffline(false),
       mHasHadSlowScript(false),
-      mNotifyIdleObserversIdleOnThaw(false),
-      mNotifyIdleObserversActiveOnThaw(false),
       mIsChrome(false),
       mCleanMessageManager(false),
       mNeedsFocus(true),
       mHasFocus(false),
       mShowFocusRingForContent(false),
       mFocusByKeyOccurred(false),
       mDidFireDocElemInserted(false),
       mHasGamepad(false),
@@ -921,19 +907,16 @@ nsGlobalWindowInner::nsGlobalWindowInner
   // We could have failed the first time through trying
   // to create the entropy collector, so we should
   // try to get one until we succeed.
 
   static bool sFirstTime = true;
   if (sFirstTime) {
     sFirstTime = false;
     TimeoutManager::Initialize();
-    Preferences::AddBoolVarCache(&gIdleObserversAPIFuzzTimeDisabled,
-                                 "dom.idle-observers-api.fuzz_time.disabled",
-                                 false);
   }
 
   if (gDumpFile == nullptr) {
     nsAutoCString fname;
     Preferences::GetCString("browser.dom.window.dump.file", fname);
     if (!fname.IsEmpty()) {
       // If this fails to open, Dump() knows to just go to stdout on null.
       gDumpFile = fopen(fname.get(), "wb+");
@@ -1109,23 +1092,16 @@ void nsGlobalWindowInner::FreeInnerObjec
   while (iter.HasMore()) {
     iter.GetNext()->Close();
   }
 
   if (mTimeoutManager) {
     mTimeoutManager->ClearAllTimeouts();
   }
 
-  if (mIdleTimer) {
-    mIdleTimer->Cancel();
-    mIdleTimer = nullptr;
-  }
-
-  mIdleObservers.Clear();
-
   DisableIdleCallbackRequests();
 
   mChromeEventHandler = nullptr;
 
   if (mListenerManager) {
     mListenerManager->Disconnect();
     mListenerManager = nullptr;
   }
@@ -1225,20 +1201,16 @@ void nsGlobalWindowInner::FreeInnerObjec
       }
     }
 
     RefPtr<StorageNotifierService> sns = StorageNotifierService::GetOrCreate();
     if (sns) {
       sns->Unregister(mObserver);
     }
 
-    if (mIdleService) {
-      mIdleService->RemoveIdleObserver(mObserver, MIN_IDLE_NOTIFICATION_TIME_S);
-    }
-
     Preferences::RemoveObserver(mObserver, "intl.accept_languages");
 
     // Drop its reference to this dying window, in case for some bogus reason
     // the object stays around.
     mObserver->Forget();
   }
 
   mMenubar = nullptr;
@@ -1375,25 +1347,22 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSharedWorkers)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLocalStorage)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSessionStorage)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mApplicationCache)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIndexedDB)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocumentPrincipal)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTabChild)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDoc)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIdleService)
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIdleRequestExecutor)
   for (IdleRequest* request : tmp->mIdleRequestCallbacks) {
     cb.NoteNativeChild(request, NS_CYCLE_COLLECTION_PARTICIPANT(IdleRequest));
   }
 
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIdleObservers)
-
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mClientSource)
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGamepads)
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCacheStorage)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mVRDisplays)
 
   // Traverse stuff from nsPIDOMWindow
@@ -1474,18 +1443,16 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ns
   }
   if (tmp->mIndexedDB) {
     tmp->mIndexedDB->DisconnectFromWindow(tmp);
     NS_IMPL_CYCLE_COLLECTION_UNLINK(mIndexedDB)
   }
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocumentPrincipal)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mTabChild)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mDoc)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mIdleService)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mIdleObservers)
 
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mGamepads)
 
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mCacheStorage)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mVRDisplays)
 
   // Unlink stuff from nsPIDOMWindow
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mChromeEventHandler)
@@ -1898,23 +1865,16 @@ void nsGlobalWindowInner::GetEventTarget
       if (ds) {
         sDragServiceDisabled = false;
         ds->Unsuppress();
       }
     }
   }
 
   aVisitor.SetParentTarget(GetParentTarget(), true);
-
-  // Handle 'active' event.
-  if (!mIdleObservers.IsEmpty() && aVisitor.mEvent->IsTrusted() &&
-      (aVisitor.mEvent->HasMouseEventMessage() ||
-       aVisitor.mEvent->HasDragEventMessage())) {
-    mAddActiveEventFuzzTime = false;
-  }
 }
 
 bool nsGlobalWindowInner::DialogsAreBeingAbused() {
   NS_ASSERTION(
       GetScriptableTopInternal() &&
           GetScriptableTopInternal()->GetCurrentInnerWindowInternal() == this,
       "DialogsAreBeingAbused called with invalid window");
 
@@ -4514,189 +4474,16 @@ void nsGlobalWindowInner::FireOfflineSta
     name.AssignLiteral("offline");
   } else {
     name.AssignLiteral("online");
   }
   nsContentUtils::DispatchTrustedEvent(mDoc, static_cast<EventTarget*>(this),
                                        name, CanBubble::eNo, Cancelable::eNo);
 }
 
-class NotifyIdleObserverRunnable : public Runnable {
- public:
-  NotifyIdleObserverRunnable(MozIdleObserver& aIdleObserver, uint32_t aTimeInS,
-                             bool aCallOnidle, nsGlobalWindowInner* aIdleWindow)
-      : mozilla::Runnable("NotifyIdleObserverRunnable"),
-        mIdleObserver(aIdleObserver),
-        mTimeInS(aTimeInS),
-        mIdleWindow(aIdleWindow),
-        mCallOnidle(aCallOnidle) {}
-
-  NS_IMETHOD Run() override {
-    if (mIdleWindow->ContainsIdleObserver(mIdleObserver, mTimeInS)) {
-      if (mCallOnidle) {
-        mIdleObserver->Onidle(IgnoreErrors());
-      } else {
-        mIdleObserver->Onactive(IgnoreErrors());
-      }
-    }
-    return NS_OK;
-  }
-
- private:
-  OwningNonNull<MozIdleObserver> mIdleObserver;
-  uint32_t mTimeInS;
-  RefPtr<nsGlobalWindowInner> mIdleWindow;
-
-  // If false then call on active
-  bool mCallOnidle;
-};
-
-void nsGlobalWindowInner::NotifyIdleObserver(
-    IdleObserverHolder* aIdleObserverHolder, bool aCallOnidle) {
-  MOZ_ASSERT(aIdleObserverHolder);
-  aIdleObserverHolder->mPrevNotificationIdle = aCallOnidle;
-
-  nsCOMPtr<nsIRunnable> caller = new NotifyIdleObserverRunnable(
-      aIdleObserverHolder->mIdleObserver, aIdleObserverHolder->mTimeInS,
-      aCallOnidle, this);
-  if (NS_FAILED(Dispatch(TaskCategory::Other, caller.forget()))) {
-    NS_WARNING("Failed to dispatch thread for idle observer notification.");
-  }
-}
-
-bool nsGlobalWindowInner::ContainsIdleObserver(MozIdleObserver& aIdleObserver,
-                                               uint32_t aTimeInS) {
-  bool found = false;
-  nsTObserverArray<IdleObserverHolder>::ForwardIterator iter(mIdleObservers);
-  while (iter.HasMore()) {
-    IdleObserverHolder& idleObserver = iter.GetNext();
-    if (idleObserver.mIdleObserver.ref() == aIdleObserver &&
-        idleObserver.mTimeInS == aTimeInS) {
-      found = true;
-      break;
-    }
-  }
-  return found;
-}
-
-void IdleActiveTimerCallback(nsITimer* aTimer, void* aClosure) {
-  RefPtr<nsGlobalWindowInner> idleWindow =
-      static_cast<nsGlobalWindowInner*>(aClosure);
-  MOZ_ASSERT(idleWindow, "Idle window has not been instantiated.");
-  idleWindow->HandleIdleActiveEvent();
-}
-
-void IdleObserverTimerCallback(nsITimer* aTimer, void* aClosure) {
-  RefPtr<nsGlobalWindowInner> idleWindow =
-      static_cast<nsGlobalWindowInner*>(aClosure);
-  MOZ_ASSERT(idleWindow, "Idle window has not been instantiated.");
-  idleWindow->HandleIdleObserverCallback();
-}
-
-void nsGlobalWindowInner::HandleIdleObserverCallback() {
-  MOZ_ASSERT(
-      static_cast<uint32_t>(mIdleCallbackIndex) < mIdleObservers.Length(),
-      "Idle callback index exceeds array bounds!");
-  IdleObserverHolder& idleObserver =
-      mIdleObservers.ElementAt(mIdleCallbackIndex);
-  NotifyIdleObserver(&idleObserver, true);
-  mIdleCallbackIndex++;
-  if (NS_FAILED(ScheduleNextIdleObserverCallback())) {
-    NS_WARNING("Failed to set next idle observer callback.");
-  }
-}
-
-nsresult nsGlobalWindowInner::ScheduleNextIdleObserverCallback() {
-  MOZ_ASSERT(mIdleService, "No idle service!");
-
-  if (mIdleCallbackIndex < 0 ||
-      static_cast<uint32_t>(mIdleCallbackIndex) >= mIdleObservers.Length()) {
-    return NS_OK;
-  }
-
-  IdleObserverHolder& idleObserver =
-      mIdleObservers.ElementAt(mIdleCallbackIndex);
-
-  uint32_t userIdleTimeMS = 0;
-  nsresult rv = mIdleService->GetIdleTime(&userIdleTimeMS);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  uint32_t callbackTimeMS = 0;
-  if (idleObserver.mTimeInS * 1000 + mIdleFuzzFactor > userIdleTimeMS) {
-    callbackTimeMS =
-        idleObserver.mTimeInS * 1000 - userIdleTimeMS + mIdleFuzzFactor;
-  }
-
-  mIdleTimer->Cancel();
-  rv = mIdleTimer->InitWithNamedFuncCallback(
-      IdleObserverTimerCallback, this, callbackTimeMS, nsITimer::TYPE_ONE_SHOT,
-      "nsGlobalWindowInner::ScheduleNextIdleObserverCallback");
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  return NS_OK;
-}
-
-uint32_t nsGlobalWindowInner::GetFuzzTimeMS() {
-  if (gIdleObserversAPIFuzzTimeDisabled) {
-    return 0;
-  }
-
-  uint32_t randNum = MAX_IDLE_FUZZ_TIME_MS;
-  size_t nbytes = PR_GetRandomNoise(&randNum, sizeof(randNum));
-  if (nbytes != sizeof(randNum)) {
-    NS_WARNING("PR_GetRandomNoise(...) Not implemented or no available noise!");
-    return MAX_IDLE_FUZZ_TIME_MS;
-  }
-
-  if (randNum > MAX_IDLE_FUZZ_TIME_MS) {
-    randNum %= MAX_IDLE_FUZZ_TIME_MS;
-  }
-
-  return randNum;
-}
-
-nsresult nsGlobalWindowInner::ScheduleActiveTimerCallback() {
-  if (!mAddActiveEventFuzzTime) {
-    return HandleIdleActiveEvent();
-  }
-
-  MOZ_ASSERT(mIdleTimer);
-  mIdleTimer->Cancel();
-
-  uint32_t fuzzFactorInMS = GetFuzzTimeMS();
-  nsresult rv = mIdleTimer->InitWithNamedFuncCallback(
-      IdleActiveTimerCallback, this, fuzzFactorInMS, nsITimer::TYPE_ONE_SHOT,
-      "nsGlobalWindowInner::ScheduleActiveTimerCallback");
-  NS_ENSURE_SUCCESS(rv, rv);
-  return NS_OK;
-}
-
-nsresult nsGlobalWindowInner::HandleIdleActiveEvent() {
-  if (mCurrentlyIdle) {
-    mIdleCallbackIndex = 0;
-    mIdleFuzzFactor = GetFuzzTimeMS();
-    nsresult rv = ScheduleNextIdleObserverCallback();
-    NS_ENSURE_SUCCESS(rv, rv);
-    return NS_OK;
-  }
-
-  mIdleCallbackIndex = -1;
-  MOZ_ASSERT(mIdleTimer);
-  mIdleTimer->Cancel();
-  nsTObserverArray<IdleObserverHolder>::ForwardIterator iter(mIdleObservers);
-  while (iter.HasMore()) {
-    IdleObserverHolder& idleObserver = iter.GetNext();
-    if (idleObserver.mPrevNotificationIdle) {
-      NotifyIdleObserver(&idleObserver, false);
-    }
-  }
-
-  return NS_OK;
-}
-
 nsGlobalWindowInner::SlowScriptResponse
 nsGlobalWindowInner::ShowSlowScriptDialog(const nsString& aAddonId) {
   nsresult rv;
   AutoJSContext cx;
 
   if (Preferences::GetBool("dom.always_stop_slow_scripts")) {
     return KillSlowScript;
   }
@@ -4915,190 +4702,16 @@ nsGlobalWindowInner::ShowSlowScriptDialo
   }
 
   JS_ClearPendingException(cx);
 
   if (checkboxValue && isAddonScript) return KillScriptGlobal;
   return KillSlowScript;
 }
 
-uint32_t nsGlobalWindowInner::FindInsertionIndex(
-    IdleObserverHolder* aIdleObserver) {
-  MOZ_ASSERT(aIdleObserver, "Idle observer not instantiated.");
-
-  uint32_t i = 0;
-  nsTObserverArray<IdleObserverHolder>::ForwardIterator iter(mIdleObservers);
-  while (iter.HasMore()) {
-    IdleObserverHolder& idleObserver = iter.GetNext();
-    if (idleObserver.mTimeInS > aIdleObserver->mTimeInS) {
-      break;
-    }
-    i++;
-    MOZ_ASSERT(i <= mIdleObservers.Length(),
-               "Array index out of bounds error.");
-  }
-
-  return i;
-}
-
-nsresult nsGlobalWindowInner::RegisterIdleObserver(
-    MozIdleObserver& aIdleObserver) {
-  nsresult rv;
-  if (mIdleObservers.IsEmpty()) {
-    mIdleService = do_GetService("@mozilla.org/widget/idleservice;1", &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    rv = mIdleService->AddIdleObserver(mObserver, MIN_IDLE_NOTIFICATION_TIME_S);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    if (!mIdleTimer) {
-      mIdleTimer = NS_NewTimer();
-      NS_ENSURE_TRUE(mIdleTimer, NS_ERROR_OUT_OF_MEMORY);
-    } else {
-      mIdleTimer->Cancel();
-    }
-  }
-
-  MOZ_ASSERT(mIdleService);
-  MOZ_ASSERT(mIdleTimer);
-
-  IdleObserverHolder tmpIdleObserver;
-  tmpIdleObserver.mIdleObserver = aIdleObserver;
-  ErrorResult err;
-  tmpIdleObserver.mTimeInS = aIdleObserver.GetTime(err);
-  if (NS_WARN_IF(err.Failed())) {
-    return err.StealNSResult();
-  }
-  NS_ENSURE_ARG_MAX(tmpIdleObserver.mTimeInS, UINT32_MAX / 1000);
-  NS_ENSURE_ARG_MIN(tmpIdleObserver.mTimeInS, MIN_IDLE_NOTIFICATION_TIME_S);
-
-  uint32_t insertAtIndex = FindInsertionIndex(&tmpIdleObserver);
-  if (insertAtIndex == mIdleObservers.Length()) {
-    mIdleObservers.AppendElement(tmpIdleObserver);
-  } else {
-    mIdleObservers.InsertElementAt(insertAtIndex, tmpIdleObserver);
-  }
-
-  bool userIsIdle = false;
-  rv = nsContentUtils::IsUserIdle(MIN_IDLE_NOTIFICATION_TIME_S, &userIsIdle);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // Special case. First idle observer added to empty list while the user is
-  // idle. Haven't received 'idle' topic notification from slow idle service
-  // yet. Need to wait for the idle notification and then notify idle observers
-  // in the list.
-  if (userIsIdle && mIdleCallbackIndex == -1) {
-    return NS_OK;
-  }
-
-  if (!mCurrentlyIdle) {
-    return NS_OK;
-  }
-
-  MOZ_ASSERT(mIdleCallbackIndex >= 0);
-
-  if (static_cast<int32_t>(insertAtIndex) < mIdleCallbackIndex) {
-    IdleObserverHolder& idleObserver = mIdleObservers.ElementAt(insertAtIndex);
-    NotifyIdleObserver(&idleObserver, true);
-    mIdleCallbackIndex++;
-    return NS_OK;
-  }
-
-  if (static_cast<int32_t>(insertAtIndex) == mIdleCallbackIndex) {
-    mIdleTimer->Cancel();
-    rv = ScheduleNextIdleObserverCallback();
-    NS_ENSURE_SUCCESS(rv, rv);
-  }
-  return NS_OK;
-}
-
-nsresult nsGlobalWindowInner::FindIndexOfElementToRemove(
-    MozIdleObserver& aIdleObserver, int32_t* aRemoveElementIndex) {
-  *aRemoveElementIndex = 0;
-  if (mIdleObservers.IsEmpty()) {
-    return NS_ERROR_FAILURE;
-  }
-
-  ErrorResult rv;
-  uint32_t aIdleObserverTimeInS = aIdleObserver.GetTime(rv);
-  if (NS_WARN_IF(rv.Failed())) {
-    return rv.StealNSResult();
-  }
-  NS_ENSURE_ARG_MIN(aIdleObserverTimeInS, MIN_IDLE_NOTIFICATION_TIME_S);
-
-  nsTObserverArray<IdleObserverHolder>::ForwardIterator iter(mIdleObservers);
-  while (iter.HasMore()) {
-    IdleObserverHolder& idleObserver = iter.GetNext();
-    if (idleObserver.mTimeInS == aIdleObserverTimeInS &&
-        idleObserver.mIdleObserver.ref() == aIdleObserver) {
-      break;
-    }
-    (*aRemoveElementIndex)++;
-  }
-  return static_cast<uint32_t>(*aRemoveElementIndex) >= mIdleObservers.Length()
-             ? NS_ERROR_FAILURE
-             : NS_OK;
-}
-
-nsresult nsGlobalWindowInner::UnregisterIdleObserver(
-    MozIdleObserver& aIdleObserver) {
-  int32_t removeElementIndex;
-  nsresult rv = FindIndexOfElementToRemove(aIdleObserver, &removeElementIndex);
-  if (NS_FAILED(rv)) {
-    NS_WARNING(
-        "Idle observer not found in list of idle observers. No idle observer "
-        "removed.");
-    return NS_OK;
-  }
-  mIdleObservers.RemoveElementAt(removeElementIndex);
-
-  MOZ_ASSERT(mIdleTimer);
-  if (mIdleObservers.IsEmpty() && mIdleService) {
-    rv = mIdleService->RemoveIdleObserver(mObserver,
-                                          MIN_IDLE_NOTIFICATION_TIME_S);
-    NS_ENSURE_SUCCESS(rv, rv);
-    mIdleService = nullptr;
-
-    mIdleTimer->Cancel();
-    mIdleCallbackIndex = -1;
-    return NS_OK;
-  }
-
-  if (!mCurrentlyIdle) {
-    return NS_OK;
-  }
-
-  if (removeElementIndex < mIdleCallbackIndex) {
-    mIdleCallbackIndex--;
-    return NS_OK;
-  }
-
-  if (removeElementIndex != mIdleCallbackIndex) {
-    return NS_OK;
-  }
-
-  mIdleTimer->Cancel();
-
-  // If the last element in the array had been notified then decrement
-  // mIdleCallbackIndex because an idle was removed from the list of
-  // idle observers.
-  // Example: add idle observer with time 1, 2, 3,
-  // Idle notifications for idle observers with time 1, 2, 3 are complete
-  // Remove idle observer with time 3 while the user is still idle.
-  // The user never transitioned to active state.
-  // Add an idle observer with idle time 4
-  if (static_cast<uint32_t>(mIdleCallbackIndex) == mIdleObservers.Length()) {
-    mIdleCallbackIndex--;
-  }
-  rv = ScheduleNextIdleObserverCallback();
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  return NS_OK;
-}
-
 nsresult nsGlobalWindowInner::Observe(nsISupports* aSubject, const char* aTopic,
                                       const char16_t* aData) {
   if (!nsCRT::strcmp(aTopic, NS_IOSERVICE_OFFLINE_STATUS_TOPIC)) {
     if (!IsFrozen()) {
       // Fires an offline status event if the offline status has changed
       FireOfflineStatusEventIfChanged();
     }
     return NS_OK;
@@ -5114,39 +4727,16 @@ nsresult nsGlobalWindowInner::Observe(ns
 
   if (!nsCRT::strcmp(aTopic, "clear-site-data-reload-needed")) {
     // The reload is propagated from the top-level window only.
     NS_ConvertUTF16toUTF8 otherOrigin(aData);
     PropagateClearSiteDataReload(otherOrigin);
     return NS_OK;
   }
 
-  if (!nsCRT::strcmp(aTopic, OBSERVER_TOPIC_IDLE)) {
-    mCurrentlyIdle = true;
-    if (IsFrozen()) {
-      // need to fire only one idle event while the window is frozen.
-      mNotifyIdleObserversIdleOnThaw = true;
-      mNotifyIdleObserversActiveOnThaw = false;
-    } else if (IsCurrentInnerWindow()) {
-      HandleIdleActiveEvent();
-    }
-    return NS_OK;
-  }
-
-  if (!nsCRT::strcmp(aTopic, OBSERVER_TOPIC_ACTIVE)) {
-    mCurrentlyIdle = false;
-    if (IsFrozen()) {
-      mNotifyIdleObserversActiveOnThaw = true;
-      mNotifyIdleObserversIdleOnThaw = false;
-    } else if (IsCurrentInnerWindow()) {
-      ScheduleActiveTimerCallback();
-    }
-    return NS_OK;
-  }
-
   if (!nsCRT::strcmp(aTopic, "offline-cache-update-added")) {
     if (mApplicationCache) return NS_OK;
 
     // Instantiate the application object now. It observes update belonging to
     // this window's document and correctly updates the applicationCache object
     // state.
     nsCOMPtr<nsIObserver> observer = GetApplicationCache();
     if (observer) observer->Observe(aSubject, aTopic, aData);
@@ -5716,26 +5306,16 @@ nsresult nsGlobalWindowInner::FireDelaye
   if (mApplicationCache) {
     static_cast<nsDOMOfflineResourceList*>(mApplicationCache.get())
         ->FirePendingEvents();
   }
 
   // Fires an offline status event if the offline status has changed
   FireOfflineStatusEventIfChanged();
 
-  if (mNotifyIdleObserversIdleOnThaw) {
-    mNotifyIdleObserversIdleOnThaw = false;
-    HandleIdleActiveEvent();
-  }
-
-  if (mNotifyIdleObserversActiveOnThaw) {
-    mNotifyIdleObserversActiveOnThaw = false;
-    ScheduleActiveTimerCallback();
-  }
-
   nsCOMPtr<nsIDocShell> docShell = GetDocShell();
   if (docShell) {
     int32_t childCount = 0;
     docShell->GetChildCount(&childCount);
 
     // Take a copy of the current children so that modifications to
     // the child list don't affect to the iteration.
     AutoTArray<nsCOMPtr<nsIDocShellTreeItem>, 8> children;
--- a/dom/base/nsGlobalWindowInner.h
+++ b/dom/base/nsGlobalWindowInner.h
@@ -150,47 +150,16 @@ extern already_AddRefed<nsIScriptTimeout
     mozilla::ErrorResult& aError);
 
 extern already_AddRefed<nsIScriptTimeoutHandler> NS_CreateJSTimeoutHandler(
     JSContext* aCx, nsGlobalWindowInner* aWindow, const nsAString& aExpression,
     mozilla::ErrorResult& aError);
 
 extern const js::Class OuterWindowProxyClass;
 
-struct IdleObserverHolder {
-  mozilla::OwningNonNull<mozilla::dom::MozIdleObserver> mIdleObserver;
-  uint32_t mTimeInS;
-  bool mPrevNotificationIdle;
-
-  IdleObserverHolder() : mTimeInS(0), mPrevNotificationIdle(false) {
-    MOZ_COUNT_CTOR(IdleObserverHolder);
-  }
-
-  IdleObserverHolder(const IdleObserverHolder& aOther)
-      : mIdleObserver(aOther.mIdleObserver),
-        mTimeInS(aOther.mTimeInS),
-        mPrevNotificationIdle(aOther.mPrevNotificationIdle) {
-    MOZ_COUNT_CTOR(IdleObserverHolder);
-  }
-
-  bool operator==(const IdleObserverHolder& aOther) const {
-    return mIdleObserver.ref() == aOther.mIdleObserver &&
-           mTimeInS == aOther.mTimeInS;
-  }
-
-  ~IdleObserverHolder() { MOZ_COUNT_DTOR(IdleObserverHolder); }
-};
-
-inline void ImplCycleCollectionTraverse(
-    nsCycleCollectionTraversalCallback& aCallback, IdleObserverHolder& aField,
-    const char* aName, unsigned aFlags) {
-  CycleCollectionNoteChild(aCallback, aField.mIdleObserver.get(), aName,
-                           aFlags);
-}
-
 //*****************************************************************************
 // nsGlobalWindowInner: Global Object for Scripting
 //*****************************************************************************
 
 // nsGlobalWindowInner inherits PRCList for maintaining a list of all inner
 // windows still in memory for any given outer window. This list is needed to
 // ensure that mOuterWindow doesn't end up dangling. The nature of PRCList means
 // that the window itself is always in the list, and an outer window's list will
@@ -486,23 +455,16 @@ class nsGlobalWindowInner final : public
 
 #if defined(MOZ_WIDGET_ANDROID)
   virtual void EnableOrientationChangeListener() override;
   virtual void DisableOrientationChangeListener() override;
 #endif
 
   void AddSizeOfIncludingThis(nsWindowSizes& aWindowSizes) const;
 
-  void NotifyIdleObserver(IdleObserverHolder* aIdleObserverHolder,
-                          bool aCallOnidle);
-  nsresult HandleIdleActiveEvent();
-  bool ContainsIdleObserver(mozilla::dom::MozIdleObserver& aIdleObserver,
-                            uint32_t timeInS);
-  void HandleIdleObserverCallback();
-
   enum SlowScriptResponse {
     ContinueSlowScript = 0,
     ContinueSlowScriptAndKeepNotifying,
     AlwaysContinueSlowScript,
     KillSlowScript,
     KillScriptGlobal
   };
   SlowScriptResponse ShowSlowScriptDialog(const nsString& aAddonId);
@@ -1006,39 +968,16 @@ class nsGlobalWindowInner final : public
   void SetOuterWidth(int32_t aOuterWidth, mozilla::dom::CallerType aCallerType,
                      mozilla::ErrorResult& aError);
   int32_t GetOuterHeight(mozilla::dom::CallerType aCallerType,
                          mozilla::ErrorResult& aError);
   void SetOuterHeight(int32_t aOuterHeight,
                       mozilla::dom::CallerType aCallerType,
                       mozilla::ErrorResult& aError);
 
-  // Array of idle observers that are notified of idle events.
-  nsTObserverArray<IdleObserverHolder> mIdleObservers;
-
-  // Idle timer used for function callbacks to notify idle observers.
-  nsCOMPtr<nsITimer> mIdleTimer;
-
-  // Idle fuzz time added to idle timer callbacks.
-  uint32_t mIdleFuzzFactor;
-
-  // Index in mArrayIdleObservers
-  // Next idle observer to notify user idle status
-  int32_t mIdleCallbackIndex;
-
-  // If false then the topic is "active"
-  // If true then the topic is "idle"
-  bool mCurrentlyIdle;
-
-  // Set to true when a fuzz time needs to be applied
-  // to active notifications to the idle observer.
-  bool mAddActiveEventFuzzTime;
-
-  nsCOMPtr<nsIIdleService> mIdleService;
-
   RefPtr<mozilla::dom::WakeLock> mWakeLock;
 
   friend class HashchangeCallback;
   friend class mozilla::dom::BarProp;
 
   // Object Management
   virtual ~nsGlobalWindowInner();
 
@@ -1121,29 +1060,16 @@ class nsGlobalWindowInner final : public
   already_AddRefed<nsIDocShellTreeOwner> GetTreeOwner();
   already_AddRefed<nsIWebBrowserChrome> GetWebBrowserChrome();
   bool IsPrivateBrowsing();
 
   void FireOfflineStatusEventIfChanged();
 
  public:
   // Inner windows only.
-  nsresult ScheduleNextIdleObserverCallback();
-  uint32_t GetFuzzTimeMS();
-  nsresult ScheduleActiveTimerCallback();
-  uint32_t FindInsertionIndex(IdleObserverHolder* aIdleObserver);
-  nsresult RegisterIdleObserver(
-      mozilla::dom::MozIdleObserver& aIdleObserverPtr) override;
-  nsresult FindIndexOfElementToRemove(
-      mozilla::dom::MozIdleObserver& aIdleObserver,
-      int32_t* aRemoveElementIndex);
-  nsresult UnregisterIdleObserver(
-      mozilla::dom::MozIdleObserver& aIdleObserverPtr) override;
-
-  // Inner windows only.
   nsresult FireHashchange(const nsAString& aOldURL, const nsAString& aNewURL);
 
   void FlushPendingNotifications(mozilla::FlushType aType);
 
   void ScrollTo(const mozilla::CSSIntPoint& aScroll,
                 const mozilla::dom::ScrollOptions& aOptions);
 
   bool IsFrame();
@@ -1285,20 +1211,16 @@ class nsGlobalWindowInner final : public
   bool mWasOffline : 1;
 
   // Represents whether the inner window's page has had a slow script notice.
   // Only used by inner windows; will always be false for outer windows.
   // This is used to implement Telemetry measures such as
   // SLOW_SCRIPT_PAGE_COUNT.
   bool mHasHadSlowScript : 1;
 
-  // Track what sorts of events we need to fire when thawed
-  bool mNotifyIdleObserversIdleOnThaw : 1;
-  bool mNotifyIdleObserversActiveOnThaw : 1;
-
   // Fast way to tell if this is a chrome window (without having to QI).
   bool mIsChrome : 1;
 
   // Hack to indicate whether a chrome window needs its message manager
   // to be disconnected, since clean up code is shared in the global
   // window superclass.
   bool mCleanMessageManager : 1;
 
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -24,33 +24,31 @@
 #include "nsISecureBrowserUI.h"
 #include "nsIWebProgressListener.h"
 #include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/dom/ContentFrameMessageManager.h"
 #include "mozilla/dom/EventTarget.h"
 #include "mozilla/dom/LocalStorage.h"
 #include "mozilla/dom/LSObject.h"
 #include "mozilla/dom/Storage.h"
-#include "mozilla/dom/IdleRequest.h"
 #include "mozilla/dom/MaybeCrossOriginObject.h"
 #include "mozilla/dom/Performance.h"
 #include "mozilla/dom/StorageEvent.h"
 #include "mozilla/dom/StorageEventBinding.h"
 #include "mozilla/dom/StorageNotifierService.h"
 #include "mozilla/dom/StorageUtils.h"
 #include "mozilla/dom/Timeout.h"
 #include "mozilla/dom/TimeoutHandler.h"
 #include "mozilla/dom/TimeoutManager.h"
 #include "mozilla/dom/WindowProxyHolder.h"
 #include "mozilla/IntegerPrintfMacros.h"
 #if defined(MOZ_WIDGET_ANDROID)
 #  include "mozilla/dom/WindowOrientationObserver.h"
 #endif
 #include "nsError.h"
-#include "nsIIdleService.h"
 #include "nsISizeOfEventTarget.h"
 #include "nsDOMJSUtils.h"
 #include "nsArrayUtils.h"
 #include "nsDOMWindowList.h"
 #include "mozilla/dom/WakeLock.h"
 #include "mozilla/dom/power/PowerManagerService.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIInterfaceRequestorUtils.h"
@@ -1093,20 +1091,16 @@ static JSObject* NewOuterWindowProxy(JSC
 }
 
 //*****************************************************************************
 //***    nsGlobalWindowOuter: Object Management
 //*****************************************************************************
 
 nsGlobalWindowOuter::nsGlobalWindowOuter(uint64_t aWindowID)
     : nsPIDOMWindowOuter(aWindowID),
-      mIdleFuzzFactor(0),
-      mIdleCallbackIndex(-1),
-      mCurrentlyIdle(false),
-      mAddActiveEventFuzzTime(true),
       mFullscreen(false),
       mFullscreenMode(false),
       mIsClosed(false),
       mInClose(false),
       mHavePendingClose(false),
       mHadOriginalOpener(false),
       mIsPopupSpam(false),
       mBlockScriptedClosingFlag(false),
@@ -1319,21 +1313,16 @@ void nsGlobalWindowOuter::CleanUp() {
   if (mContext) {
     mContext = nullptr;  // Forces Release
   }
   mChromeEventHandler = nullptr;  // Forces Release
   mParentTarget = nullptr;
   mMessageManager = nullptr;
 
   mArguments = nullptr;
-
-  if (mIdleTimer) {
-    mIdleTimer->Cancel();
-    mIdleTimer = nullptr;
-  }
 }
 
 void nsGlobalWindowOuter::ClearControllers() {
   if (mControllers) {
     uint32_t count;
     mControllers->GetControllerCount(&count);
 
     while (count--) {
@@ -1413,19 +1402,16 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mControllers)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mArguments)
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLocalStorage)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSuspendedDoc)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocumentPrincipal)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDoc)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIdleService)
-
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIdleObservers)
 
   // Traverse stuff from nsPIDOMWindow
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChromeEventHandler)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParentTarget)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMessageManager)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFrameElement)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOpenerForInitialContentBrowser)
 
@@ -1442,18 +1428,16 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ns
 
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mControllers)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mArguments)
 
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mLocalStorage)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mSuspendedDoc)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocumentPrincipal)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mDoc)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mIdleService)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mIdleObservers)
 
   // Unlink stuff from nsPIDOMWindow
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mChromeEventHandler)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mParentTarget)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mMessageManager)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mFrameElement)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mOpenerForInitialContentBrowser)
 
--- a/dom/base/nsGlobalWindowOuter.h
+++ b/dom/base/nsGlobalWindowOuter.h
@@ -75,42 +75,35 @@ class mozIDOMWindowProxy;
 
 class nsDocShellLoadState;
 class nsDOMWindowList;
 class nsScreen;
 class nsHistory;
 class nsGlobalWindowObserver;
 class nsGlobalWindowInner;
 class nsDOMWindowUtils;
-class nsIIdleService;
 struct nsRect;
 
 class nsWindowSizes;
 
-class IdleRequestExecutor;
-
-struct IdleObserverHolder;
-
 namespace mozilla {
 class AbstractThread;
 class DOMEventTargetHelper;
 namespace dom {
 class BarProp;
 class BrowsingContext;
 struct ChannelPixelLayout;
 class Console;
 class Crypto;
 class CustomElementRegistry;
 class DocGroup;
 class External;
 class Function;
 class Gamepad;
 enum class ImageBitmapFormat : uint8_t;
-class IdleRequest;
-class IdleRequestCallback;
 class IncrementalRunnable;
 class IntlUtils;
 class Location;
 class MediaQueryList;
 class Navigator;
 class OwningExternalOrWindowProxy;
 class Promise;
 class PostMessageData;
@@ -720,39 +713,16 @@ class nsGlobalWindowOuter final : public
                           mozilla::dom::CallerType aCallerType,
                           mozilla::ErrorResult& aError);
   int32_t GetOuterHeightOuter(mozilla::dom::CallerType aCallerType,
                               mozilla::ErrorResult& aError);
   void SetOuterHeightOuter(int32_t aOuterHeight,
                            mozilla::dom::CallerType aCallerType,
                            mozilla::ErrorResult& aError);
 
-  // Array of idle observers that are notified of idle events.
-  nsTObserverArray<IdleObserverHolder> mIdleObservers;
-
-  // Idle timer used for function callbacks to notify idle observers.
-  nsCOMPtr<nsITimer> mIdleTimer;
-
-  // Idle fuzz time added to idle timer callbacks.
-  uint32_t mIdleFuzzFactor;
-
-  // Index in mArrayIdleObservers
-  // Next idle observer to notify user idle status
-  int32_t mIdleCallbackIndex;
-
-  // If false then the topic is "active"
-  // If true then the topic is "idle"
-  bool mCurrentlyIdle;
-
-  // Set to true when a fuzz time needs to be applied
-  // to active notifications to the idle observer.
-  bool mAddActiveEventFuzzTime;
-
-  nsCOMPtr<nsIIdleService> mIdleService;
-
   RefPtr<mozilla::dom::WakeLock> mWakeLock;
 
   friend class HashchangeCallback;
   friend class mozilla::dom::BarProp;
 
   // Object Management
   virtual ~nsGlobalWindowOuter();
   void DropOuterWindowDocs();
@@ -1172,17 +1142,16 @@ class nsGlobalWindowOuter final : public
   } mChromeFields;
 
   friend class nsDOMScriptableHelper;
   friend class nsDOMWindowUtils;
   friend class mozilla::dom::BrowsingContext;
   friend class mozilla::dom::PostMessageEvent;
   friend class DesktopNotification;
   friend class mozilla::dom::TimeoutManager;
-  friend class IdleRequestExecutor;
   friend class nsGlobalWindowInner;
 };
 
 // XXX: EWW - This is an awful hack - let's not do this
 #include "nsGlobalWindowInner.h"
 
 inline nsISupports* ToSupports(nsGlobalWindowOuter* p) {
   return static_cast<mozilla::dom::EventTarget*>(p);
--- a/dom/base/nsPIDOMWindow.h
+++ b/dom/base/nsPIDOMWindow.h
@@ -49,17 +49,16 @@ class AudioContext;
 class BrowsingContext;
 class ClientInfo;
 class ClientState;
 class ContentFrameMessageManager;
 class DocGroup;
 class Document;
 class TabGroup;
 class Element;
-class MozIdleObserver;
 class Navigator;
 class Performance;
 class Report;
 class ReportBody;
 class ReportingObserver;
 class Selection;
 class ServiceWorker;
 class ServiceWorkerDescriptor;
@@ -338,21 +337,16 @@ class nsPIDOMWindowInner : public mozIDO
   virtual nsPIDOMWindowOuter* GetScriptableTop() = 0;
   virtual nsPIDOMWindowOuter* GetScriptableParent() = 0;
   virtual already_AddRefed<nsPIWindowRoot> GetTopWindowRoot() = 0;
 
   mozilla::dom::EventTarget* GetChromeEventHandler() const {
     return mChromeEventHandler;
   }
 
-  virtual nsresult RegisterIdleObserver(
-      mozilla::dom::MozIdleObserver& aIdleObserver) = 0;
-  virtual nsresult UnregisterIdleObserver(
-      mozilla::dom::MozIdleObserver& aIdleObserver) = 0;
-
   mozilla::dom::EventTarget* GetParentTarget() {
     if (!mParentTarget) {
       UpdateParentTarget();
     }
     return mParentTarget;
   }
 
   virtual void MaybeUpdateTouchState() {}
--- a/dom/base/test/chrome.ini
+++ b/dom/base/test/chrome.ini
@@ -15,18 +15,16 @@ support-files =
   referrer_testserver.sjs
   mozbrowser_api_utils.js
   !/image/test/mochitest/shaver.png
 
 [test_anonymousContent_xul_window.xul]
 [test_blockParsing.html]
 [test_blocking_image.html]
 [test_bug419527.xhtml]
-[test_bug715041.xul]
-[test_bug715041_removal.xul]
 [test_bug945152.html]
 [test_bug1008126.html]
 [test_bug1016960.html]
 [test_anchor_target_blank_referrer.html]
 [test_copypaste.xul]
 subsuite = clipboard
 [test_domrequesthelper.xul]
 [test_fragment_sanitization.xul]
deleted file mode 100644
--- a/dom/base/test/test_bug715041.xul
+++ /dev/null
@@ -1,808 +0,0 @@
-<?xml version="1.0"?>
-<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
-<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=715041
--->
-    <window title="Mozilla Bug 715041"
-xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-    <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
-
-    <!-- test results are displayed in the html:body -->
-    <body xmlns="http://www.w3.org/1999/xhtml">
-    <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=715041"
-target="_blank">Mozilla Bug 715041</a>
-    </body>
-
-    <!-- test code goes here -->
-    <script type="application/javascript">
-    <![CDATA[
-
-  /** Mock Idle Service Test for Bug 715041 **/
-  //class mock javascript idle service
-  var idleServiceObj = {
-    observers: [],
-    windowObservers: [],
-    idleTimeInMS: 5000,   //in milli seconds
-
-    // takes note of the idle observers added as the minimum idle observer
-    // with the idle service
-    timesAdded: [],
-
-    QueryInterface: function(iid) {
-      if (iid.equals(Ci.nsISupports) ||
-          iid.equals(Ci.nsIFactory) ||
-          iid.equals(Ci.nsIIdleService)) {
-        return this;
-      }
-      throw Cr.NS_ERROR_NO_INTERFACE;
-    },
-
-    createInstance: function(outer, iid) {
-      return this.QueryInterface(iid);
-    },
-
-    get idleTime() {
-      return this.idleTimeInMS; //in milli seconds
-    },
-
-    set idleTime(timeInMS) {
-      this.idleTimeInMS = timeInMS;
-    },
-
-    getWindowFromObserver: function(observer) {
-      try {
-        var interfaceRequestor = observer.QueryInterface(Ci.nsIInterfaceRequestor);
-        var window = interfaceRequestor.getInterface(Ci.nsIDOMWindow);
-        return window;
-      }
-      catch (e) {}
-
-      return null;
-    },
-
-    testIdleBackService: function(observer, topic) {
-      dump("\nJS FAKE IDLE SERVICE\n");
-      dump("JS NUM OBSERVERS: " + this.observers.length + "\n");
-
-      if (this.observers.length > 1) {
-        this.observers[1].observer.observe(observer, topic, '\0');
-        dump("JS CALLED OBSERVE FUNCTION!!!\n\n");
-      }
-    },
-
-    addIdleObserver: function(observer, time) {
-      dump("\nJS FAKE IDLE SERVICE add idle observer before\n");
-      dump("JS NUM OBSERVERS: " + this.observers.length + "\n");
-
-      var window = this.getWindowFromObserver(observer);
-      dump("window is: " + window + "\n");
-
-      if (window) {
-        this.observers.push({ observer: observer, time: time, });
-        addedIdleObserver = true;
-        numIdleObserversAdded++;
-        this.timesAdded.push(time);
-
-        dump ("\nMOCK IDLE SERVICE ADDING idle observer with time: " + time + "\n");
-        dump("MOCK IDLE SERVICE: num idle observers added: " + numIdleObserversAdded + "\n\n");
-      }
-      else {
-        dump("SHOULD NEVER GET HERE!");
-        oldIdleService.addIdleObserver(observer, time);
-        addedIdleObserver = false;
-      }
-
-      dump("\nJS FAKE IDLE SERVICE end of add idle observer\n");
-      dump("JS NUM OBSERVERS: " + this.observers.length + "\n");
-    },
-
-    removeIdleObserver: function(observer, time) {
-      dump("\nJS REMOVE IDLE OBSERVER () time to be removed: " + time + "\n");
-      var window = this.getWindowFromObserver(observer);
-      if (!window) {
-        oldIdleService.removeIdleObserver(observer, time);
-      }
-      else {
-        var observerIndex = -1;
-        for (var i=0; i<this.observers.length; i++) {
-          dump("JS removeIdleObserver() observer time: " + this.observers[i].time + "\n");
-          if (this.observers[i].time === time) {
-            observerIndex = i;
-            break;
-          }
-        }
-
-        if (observerIndex != -1 && this.observers.length > 0) {
-          numIdleObserversRemoved++;
-          this.observers.splice(observerIndex, 1);
-          removedIdleObserver = true;
-          dump("MOCK IDLE SERVICE REMOVING idle observer with time " + time + "\n");
-          dump("MOCK IDLE SERVICE numIdleObserversRemoved: " + numIdleObserversRemoved + " numIdleObserversAdded: " + numIdleObserversAdded + "\n\n");
-        }
-        else {
-          removedIdleObserver = false;
-        }
-      }
-      dump("\nJS FAKE IDLE SERVICE end of remove idle observer\n");
-      dump("JS NUM OBSERVERS: " + this.observers.length + "\n");
-    },
-  };
-
-  /** Test for Bug 715041 **/
-  dump("\n\n\nJS STARTING TESTING FOR BUG 715041\n");
-
-  //bool variables
-  var addedIdleObserver = removedIdleObserver = passed = cleanUp = false;
-
-  //test case enabled
-  var AddOutOfOrderActiveEnabled = AddOutOfOrderIdleEnabled =
-      AddShiftLocalEnabled = AddNewLocalWhileAllIdleEnabled =
-      TestActiveToActiveNotification = ShiftLocalTimerBackEnabled =
-      AddRemoveIdleObserverWithInvalidTimeEnabled = true;
-
-  //msgXCount
-  var msg0Count = msg1Count = msg2Count = msg3Count = msg4Count = msg5Count =
-      msg6Count = tcZero = currTestCaseNum = prevMsgNum =
-      numIdleObserversRemoved = numIdleObserversAdded = 0;
-
-  //test case number
-  var tcZero = 0;
-  var tcAddOutOfOrderActive = 1;
-  var tcAddOutOfOrderIdle = 2;
-  var tcAddShiftLocal = 3;
-  var tcAddNewLocalWhileAllIdle = 4;
-  var tcShiftLocalTimerBack = 5;
-  var tcAddRemoveIdleObserverWithInvalidTime = 6;
-  var tcTestActiveToActiveNotification = 7;
-
-  function ResetMsgCounts() {
-    msg0Count = msg1Count = msg2Count = msg3Count = msg4Count = msg5Count =
-    msg6Count = prevMsgNum = 0;
-  }
-
-  function ResetVars() {
-    msg0Count = msg1Count = msg2Count = msg3Count = msg4Count = msg5Count =
-    msg6Count = prevMsgNum = 0;
-
-    numIdleObserversAdded = numIdleObserversRemoved = 0;
-    currTestCaseNum = -1;
-    addedIdleObserver = removedIdleObserver = passed = cleanUp = false;
-  }
-
-  /*
-   * - function printMsgCounts()
-   */
-  function printMsgCounts() {
-    dump("\nmsg0Count: " + msg0Count +
-         "\nmsg1Count: " + msg1Count +
-         "\nmsg2Count: " + msg2Count +
-         "\nmsg3Count: " + msg3Count +
-         "\nmsg5Count: " + msg5Count +
-         "\nmsg6Count: " + msg6Count +
-         "\n"
-         );
-  }
-
-  function performNextTest() {
-    dump("\nfunction performNextTest()\ncurrTestCaseNum: " + currTestCaseNum +
-         "\ncleanUp: " + cleanUp +
-         "\npassed: " + passed +
-         "\nnumIdleObserversRemoved: " + numIdleObserversRemoved +
-         "\nnumIdleObservesAdded: " + numIdleObserversAdded + "\n");
-
-    switch (currTestCaseNum) {
-      case tcZero:
-        ok(passed, "Test case 0 failed clean up!");
-        caseZeroCleanUp();
-        break;
-      case tcAddShiftLocal:
-        if (cleanUp && numIdleObserversRemoved === 1) {
-          passed = true;
-          ok(passed, "Failed test case AddShiftLocalCleanUp()");
-          if (AddNewLocalWhileAllIdleEnabled) {
-            AddNewLocalWhileAllIdle();
-          }
-          else {
-            SimpleTest.finish();
-          }
-        }
-        break;
-      case tcAddNewLocalWhileAllIdle:
-        ok(passed, "Failed test case: AddNewLocalWhileAllIdle()");
-        AddNewLocalWhileAllIdleCleanUp();
-        break;
-      default:
-        //do nothing.
-        break;
-    }
-  }
-
-  //Place Holder.
-  var idleHandler0 = function() { dump("rmsg 0, should never be used!\n"); };
-
-  //idleHandler1
-  function idleHandler1() {
-    msg1Count++;
-    dump("msg 1 Count: " + msg1Count + "\n");
-
-    switch (currTestCaseNum) {
-    case tcAddOutOfOrderIdle:
-      if (msg1Count === 1 && msg2Count === 1 && msg3Count === 1) {
-        idleServiceObj.idleTime = 0;
-        idleServiceObj.testIdleBackService(idleObserversArray[1], "active");
-      }
-      else if (msg1Count === 4 && msg2Count === 4 && msg3Count === 4) {
-        passed = true;
-        AddOutOfOrderIdleCleanUp();
-      }
-      break;
-    case tcTestActiveToActiveNotification:
-      if (msg1Count === 1 && !msg2Count && !msg3Count && !msg4Count && !msg5Count) {
-        idleServiceObj.idleTime = 500;
-        idleServiceObj.testIdleBackService(idleObserversArray[1], "active");
-        return;
-      }
-      
-      if (msg1Count === 2 && !msg2Count && !msg3Count && !msg4Count && !msg5Count) {        
-        idleServiceObj.idleTime = 1000;
-        idleServiceObj.testIdleBackService(idleObserversArray[1], "idle");
-        return;
-      }
-
-      if (msg1Count === 3 && !msg2Count && !msg3Count && !msg4Count && !msg5Count) {
-        return;
-      }
-      ok(false, "Failed test active to active notification.");
-      SimpleTest.finish();
-      break;  
-    default:
-      break;
-    }
-  }
-
-  //idleHandler2
-  function idleHandler2() {
-    msg2Count++;
-    dump("msg 2 Count: " + msg2Count + "\n");
-
-    switch (currTestCaseNum) {
-    case tcZero:
-      switch (msg2Count) {
-      case 2:
-        passed = true;
-        performNextTest();
-        break;
-      default:
-        break;
-      }
-      break;
-    case tcAddOutOfOrderIdle:
-      if (msg3Count === 1 && msg2Count === 1 && !msg1Count) {
-        idleServiceObj.idleTime = 4000;
-        window.navigator.addIdleObserver(idleObserversArray[1]);
-      }
-      break;
-    case tcAddShiftLocal:
-      if (!msg1Count && msg2Count === 1 && !msg3Count && !msg4Count) {
-        window.navigator.addIdleObserver(idleObserversArray[3]);
-      }
-      AddShiftLocalCleanUp();
-      break;
-    case tcAddNewLocalWhileAllIdle:
-      if (msg1Count === 1 && msg2Count === 2) {
-        idleServiceObj.idleTime = 3500;
-        window.navigator.addIdleObserver(idleObserversArray[5]);
-      }
-      break;
-    case (tcShiftLocalTimerBack):
-      if (!msg1Count && msg2Count === 1 && !msg3Count && !msg4Count && !msg5Count) {
-        window.navigator.addIdleObserver(idleObserversArray[5]);
-        window.navigator.addIdleObserver(idleObserversArray[4]);
-      }
-      break;
-    default:
-      //do nothing.
-      break;
-    }
-  }
-
-  //idleHandler3
-  function idleHandler3() {
-    msg3Count++;
-    dump("msg 3 Count: " + msg3Count + "\n");
-
-    switch (currTestCaseNum) {
-    case (tcAddOutOfOrderIdle):
-      if (msg3Count === 1) {
-        idleServiceObj.idleTime = 3500;
-        window.navigator.addIdleObserver(idleObserversArray[2]);
-      }
-      if (msg1Count === 2 && msg2Count === 2 && msg3Count === 2) {
-        idleServiceObj.idleTime = 1000;
-        idleServiceObj.testIdleBackService(idleObserversArray[1], "idle");
-      }
-      else if (msg1Count === 3 && msg2Count === 3 && msg3Count === 3) {
-        AddOutOfOrderIdle();
-      }
-      else if (msg1Count === 3 && msg2Count === 3 && msg3Count === 4) {
-        passed = true;
-        AddOutOfOrderIdleCleanUp();
-      }
-      break;
-    default:
-      break;
-    }
-  }
-
-  //idleHandler4
-  function idleHandler4() {
-    msg4Count++;
-    dump("msg 4 Count: " + msg4Count + "\n");
-
-    switch (currTestCaseNum) {
-    case tcAddOutOfOrderActive:
-      if (msg1Count && msg2Count && msg3Count && msg4Count) {
-        passed = true;
-        ok(passed, "idleHandler4: failed AddOutOfOrderActive()");
-        AddOutOfOrderActiveCleanUp();
-        cleanUp = true;
-      }
-      break;
-    case tcAddShiftLocal:
-      if (msg1Count === 1 && msg3Count === 1 && msg4Count === 1) {
-        idleServiceObj.idleTime = 3200;
-        window.navigator.addIdleObserver(idleObserversArray[2]);
-      }
-      break;
-    default:
-      //do nothing.
-      break;
-    }
-  }
-
-  //idleHandler5
-  function idleHandler5() {
-    msg5Count++;
-    dump("msg 5 Count: " + msg5Count + "\n");
-
-    switch (currTestCaseNum) {
-    case tcAddNewLocalWhileAllIdle:
-      if (msg1Count === 1 && msg2Count === 2 && msg5Count === 1) {
-        passed = true;
-        performNextTest();
-      }
-      break;
-    case tcShiftLocalTimerBack:
-      if (!msg1Count && msg2Count === 1 && !msg3Count && msg4Count === 1 && msg5Count === 1) {
-        passed = true;
-        ShiftLocalTimerBackCleanUp();
-      }
-      break;
-    case tcTestActiveToActiveNotification:
-      passed = false;
-      if (msg1Count === 3 && !msg2Count && !msg3Count && !msg4Count && msg5Count === 1) {
-        passed = true;
-      }
-      ok(passed, "Failed TestActiveToActiveNotification.");
-          TestActiveNotificationCleanUp();
-      break;  
-    default:
-      //do nothing.
-      break;
-    }
-  }
-
-  //idleHandler6
-  function idleHandler6() {
-    dump("msg 6 Count: " + msg6Count + "\n");
-  }
-
-  var  idleObserversArray = [];
-  idleObserversArray[0] = {time: 0, onidle: idleHandler0, onactive: idleHandler0};
-  idleObserversArray[1] = {time: 1, onidle: idleHandler1, onactive: idleHandler1};
-  idleObserversArray[2] = {time: 2, onidle: idleHandler2, onactive: idleHandler2};
-  idleObserversArray[3] = {time: 3, onidle: idleHandler3, onactive: idleHandler3};
-  idleObserversArray[4] = {time: 4, onidle: idleHandler4, onactive: idleHandler4};
-  idleObserversArray[5] = {time: 5, onidle: idleHandler5, onactive: idleHandler5};
-  idleObserversArray[6] = {time: 0, onidle: idleHandler6, onactive: idleHandler6};
-  idleObserversArray[7] = {time: 2, onidle: null, onactive: null};
-
-  idleServiceObj.observers.push( {observer: idleObserversArray[0], time: 0, } );
-
-  /*
-   * - case 0
-   * - AddSingleIdleObserver
-   * - takes care of adding duplicate local too
-   * - user is currently idle since the
-   *   requested idle time of 2s < current idle time of 5000ms set below.
-   */
-  function caseZero() {
-    dump("\n\nTESTING CASE 0\n");
-    dump("==============\n");
-
-    ResetVars();
-    currTestCaseNum = tcZero;
-    idleServiceObj.idleTime = 5000;
-
-    window.navigator.addIdleObserver(idleObserversArray[2]);
-    idleServiceObj.testIdleBackService(idleObserversArray[2], "idle");
-    window.navigator.addIdleObserver(idleObserversArray[2]);
-  }
-
-  function caseZeroCleanUp() {
-    dump("\ncaseZeroCleanUp()\n");
-    dump("==============\n");
-    ResetVars();
-    currTestCaseNum = tcZero;
-    cleanUp = false;
-
-    window.navigator.removeIdleObserver(idleObserversArray[2]);
-    window.navigator.removeIdleObserver(idleObserversArray[2]);
-
-    if (AddOutOfOrderActiveEnabled) {
-      AddOutOfOrderActive();
-    }
-    else {
-      dump("Finishing testing idle API.\n");
-      SimpleTest.finish();
-    }
-  }
-
-  /*
-    AddOutOfOrderActive()
-    - Tests if the idle observer with the min time is always registered correctly
-      with the idle service.
-  */
-  function AddOutOfOrderActive() {
-    dump("\n\nTESTING CASE AddOutOfOrderActive\n");
-    dump("==============\n");
-
-    ResetVars();
-    currTestCaseNum = tcAddOutOfOrderActive;
-    idleServiceObj.idleTime = 500;
-
-    window.navigator.addIdleObserver(idleObserversArray[3]); //msg3
-    window.navigator.addIdleObserver(idleObserversArray[4]); //msg4
-    window.navigator.addIdleObserver(idleObserversArray[1]); //msg1
-    window.navigator.addIdleObserver(idleObserversArray[2]); //msg2
-    passed = false;
-
-    idleServiceObj.idleTime = 1000;
-    idleServiceObj.testIdleBackService(idleObserversArray[1], "idle");
-  }
-
-  /*
-    - AddOutOfOrderActiveCleanUp()
-  */
-  function AddOutOfOrderActiveCleanUp() {
-    dump("\nAddOutOfOrderActiveCleanUp()\n");
-    dump("==============================\n");
-    ResetVars();
-    currTestCaseNum = tcAddOutOfOrderActive;
-    cleanUp = false;
-    idleServiceObj.idleTime = 4500;
-
-    for (var i=1; i<5; i++) {
-      window.navigator.removeIdleObserver(idleObserversArray[i]);
-    }
-    dump("JS AddOutOfOrderActiveCleanUp() DONE\n");
-    if (AddOutOfOrderIdleEnabled) {
-      AddOutOfOrderIdle();
-    }
-    else {
-      dump("Finishing testing idle API.\n");
-      SimpleTest.finish();
-    }
-  }
-
-  /*
-    - AddOutOfOrderIdle()
-  */
-  function AddOutOfOrderIdle() {
-    dump("\nAddOutOfOrderIdle()\n");
-    dump("======================================================================\n");
-
-    dump("\nJS AddOutOfOrderIdle\n");
-    dump("JS NUM OBSERVERS: " + idleServiceObj.observers.length + "\n");
-
-    if (!msg1Count && !msg2Count && !msg3Count) {
-      ResetVars();
-    }
-    currTestCaseNum = tcAddOutOfOrderIdle;
-    cleanUp = false;
-
-    if (!msg1Count && !msg2Count && !msg3Count) {
-      idleServiceObj.idleTime = 3100;
-    }
-    window.navigator.addIdleObserver(idleObserversArray[3]);
-    if (!msg1Count && !msg2Count && !msg3Count) {
-      idleServiceObj.testIdleBackService(idleObserversArray[3], "idle");
-    }
-  }
-
-  /*
-   - AddOutOfOrderIdleCleanUp()
-  */
-  function AddOutOfOrderIdleCleanUp() {
-    ok(passed, "Failed test case: AddOutOfOrderIdle()");
-    dump("\nAddOutOfOrderIdleCleanUp()\n");
-    dump("==========================\n");
-    ResetVars();
-    currTestCaseNum = tcAddOutOfOrderIdle;
-    cleanUp = true;
-    idleServiceObj.idleTime = 4100;
-
-    for (var j=1; j<4; j++) {
-      window.navigator.removeIdleObserver(idleObserversArray[j]);
-    }
-    window.navigator.removeIdleObserver(idleObserversArray[3]);
-
-    if (idleServiceObj.observers.length === 1) {
-      passed = true;
-    }
-    else {
-      passed = false;
-    }
-    ok(passed, "Failed test case: AddOutOfOrderIdleCleanUp()");
-    if (AddShiftLocalEnabled) {
-      AddShiftLocal();
-    }
-    else {
-      dump("Finished AddOutOfOrderIdleCleanUp() test.\n");
-      SimpleTest.finish();
-    }
-  }
-
-  /*
-   * function AddShiftLocal()
-   * - user is idle
-   * - check that local idle timer is shifted correctly
-   * - msg 1 fired when user is idle
-   * - msg 3 fired when 3000
-   * - msg 2 fired immediately when added at 3200 ms
-   * - msg 4 fired by local timer.
-   */
-  function AddShiftLocal()
-  {
-    dump("\n\nTESTING CASE AddShiftLocal\n");
-    dump("==============\n");
-
-    ResetVars();
-    currTestCaseNum = tcAddShiftLocal;
-    idleServiceObj.idleTime = 500;
-
-    window.navigator.addIdleObserver(idleObserversArray[1]);
-    window.navigator.addIdleObserver(idleObserversArray[3]);
-    window.navigator.addIdleObserver(idleObserversArray[4]);
-
-    idleServiceObj.idleTime = 1000;
-    idleServiceObj.testIdleBackService(idleObserversArray[1], "idle");
-  }
-
-  /*
-   * function AddShiftLocalCleanUp()
-   */
-  function AddShiftLocalCleanUp()
-  {
-    dump("\n\nTESTING CASE AddShiftLocalCleanUp\n");
-    dump("==============\n");
-
-    ResetVars();
-    currTestCaseNum = tcAddShiftLocal;
-
-    for (var i=1; i<5; i++) {
-      window.navigator.removeIdleObserver(idleObserversArray[i]);
-    }
-    dump("AddShiftLocalCleanUp() done clean up\n");
-    if (AddNewLocalWhileAllIdleEnabled) {
-      AddNewLocalWhileAllIdle();
-    }
-    else {
-      dump("Finished testing AddShiftLocal()\n");
-      SimpleTest.finish();
-    }
-  }
-
-  /*
-   * AddNewLocalWhileAllIdle()
-   * - no local idle timer exists because all of the idle observers that were added had a requested
-   *   idle time of < curr user idle time and so were fired immediately. No local timer was required.
-   * - now add an idle observer whose requested idle time is > current use idle time and > min idle
-   *   requested time in the list of idle observers.
-   */
-  function AddNewLocalWhileAllIdle()
-  {
-    dump("\n\nTESTING CASE AddNewLocalWhileAllIdle\n");
-    dump("==============\n");
-
-    ResetVars();
-    currTestCaseNum = tcAddNewLocalWhileAllIdle;
-    idleServiceObj.idleTime = 500;
-
-    window.navigator.addIdleObserver(idleObserversArray[1]);
-    window.navigator.addIdleObserver(idleObserversArray[2]);
-    window.navigator.addIdleObserver(idleObserversArray[2]);
-
-    idleServiceObj.idleTime = 1000;
-    idleServiceObj.testIdleBackService(idleObserversArray[1], "idle");
-  }
-
-  function AddNewLocalWhileAllIdleCleanUp()
-  {
-    dump("\n\nTESTING CASE AddNewLocalWhileAllIdleCleanUp\n");
-    dump("==============\n");
-
-    ResetVars();
-    currTestCaseNum = tcAddNewLocalWhileAllIdle;
-
-    window.navigator.removeIdleObserver(idleObserversArray[1]);
-    window.navigator.removeIdleObserver(idleObserversArray[2]);
-    window.navigator.removeIdleObserver(idleObserversArray[2]);
-    window.navigator.removeIdleObserver(idleObserversArray[5]);
-
-    if (ShiftLocalTimerBackEnabled) {
-      ShiftLocalTimerBack();
-    }
-    else {
-      dump("Finished testing TestActiveToActiveNotificationCleanUp()\n");
-      SimpleTest.finish();
-    }
-  }
-
-  /*
-   * ShiftLocalTimerBack()
-   * - add a new idle observer whose requested time is > current user idle time
-   *   but < the current local timer that has been set.
-   * - the local timer will need to be reset to fire the new msg added.
-   * RESULT
-   * - should print all of them in order
-   */
-  function ShiftLocalTimerBack()
-  {
-    dump("\n\nTESTING CASE ShiftLocalTimerBack()\n");
-    dump("==============\n");
-
-    ResetVars();
-    currTestCaseNum = tcShiftLocalTimerBack;
-    idleServiceObj.idleTime = 2100;
-
-    window.navigator.addIdleObserver(idleObserversArray[2]);
-    idleServiceObj.testIdleBackService(idleObserversArray[2], "idle");
-  }
-
-  function ShiftLocalTimerBackCleanUp()
-  {
-    dump("\n\nTESTING CASE ShiftLocalTimerBackCleanUp\n");
-    dump("==============\n");
-
-    ResetVars();
-    currTestCaseNum = tcShiftLocalTimerBack;
-    window.navigator.removeIdleObserver(idleObserversArray[2]);
-    window.navigator.removeIdleObserver(idleObserversArray[4]);
-    window.navigator.removeIdleObserver(idleObserversArray[5]);
-    dump("ShiftLocalTimerBackCleanUp() done clean up\n");
-
-    if (TestActiveToActiveNotificationEnabled) {
-      TestActiveNotification();
-    }
-    else {
-      dump("Finished testing AddNewLocalWhileAllIdle()\n");
-      SimpleTest.finish();
-    }   
-  }
-
-  function TestActiveNotification()
-  {
-    dump("\n\nTESTING CASE TestActiveNotification\n");
-    dump("===============================================\n");
-
-    ResetVars();
-    currTestCaseNum = tcTestActiveToActiveNotification;
-
-    idleServiceObj.idleTime = 500;
-    window.navigator.addIdleObserver(idleObserversArray[1]);
-    window.navigator.addIdleObserver(idleObserversArray[5]);
-    idleServiceObj.idleTime = 1000;
-    idleServiceObj.testIdleBackService(idleObserversArray[1], "idle");    
-  }
-
-  function TestActiveNotificationCleanUp()
-  {
-    dump("\n\nTESTING CASE TestActiveNotificationCleanUp\n");
-    dump("===============================================\n");
-
-    try {
-      componentMgr.unregisterFactory(idleServiceCID, idleServiceObj);
-    }
-    catch(err) {
-      dump("test_bug715041.xul: ShiftLocalTimerBackCleanUp() Failed to unregister factory, mock idle service!\n");
-    }
-
-    try {
-      componentMgr.registerFactory(oldIdleServiceCID, "Re registering old idle service", idleServiceContractID, null);
-    }
-    catch(err) {
-      dump("test_bug715041.xul: ShiftLocalTimerBackCleanUp() Failed to register factory, original idle service!\n");
-    }
-
-    SimpleTest.finish();
-  }
-
-  /*
-   * function AddRemoveIdleObserverWithInvalidTime()
-   */
-  function AddRemoveIdleObserverWithInvalidTime()
-  {
-    dump("\n\nTESTING CASE AddRemoveIdleObserverWithInvalidTime()\n");
-    dump("==============\n");
-
-    ResetVars();
-    currTestCaseNum = tcAddRemoveIdleObserverWithInvalidTime;
-
-    //while idle
-    idleServiceObj.idleTime = 2100;
-    var rv = window.navigator.addIdleObserver(idleObserversArray[6]);
-    dump("rv: " + rv + "\n");
-    rv = window.navigator.removeIdleObserver(idleObserversArray[6]);
-
-    idleServiceObj.idleTime = 0;
-    window.navigator.addIdleObserver(idleObserversArray[6]);
-    window.navigator.removeIdleObserver(idleObserversArray[6]);
-
-    SimpleTest.finish();
-  }
-
-  try {
-    var idleServiceCID = Components.ID("287075a6-f968-4516-8043-406c46f503b4");
-    var idleServiceContractID = "@mozilla.org/widget/idleservice;1";
-    var oldIdleService = Cc[idleServiceContractID].getService(Ci.nsIIdleService);
-  }
-  catch(ex) {
-    dump("test_bug715041.xul: 1) Failed to get old idle service.\n");
-  }
-
-  try {
-    // Registering new moch JS idle service
-    var componentMgr = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
-  }
-  catch(err) {
-    dump("test_bug715041.xul: Failed to query component registrar interface.\n");
-  }
-
-  try {
-    var oldIdleServiceFactoryObj = componentMgr.getClassObjectByContractID(idleServiceContractID, Ci.nsIFactory);
-  }
-  catch(err) {
-    dump("test_bug715041.xul: Failed to get old idle service.\n");
-  }
-
-  try {
-    var oldIdleServiceCID = componentMgr.contractIDToCID(idleServiceContractID);
-  }
-  catch(err) {
-    dump("test_bug715041.xul: Failed to convert ID to CID for old idle service.\n");
-  }
-
-  try {
-    componentMgr.registerFactory(idleServiceCID, "Test Simple Idle/Back Notifications", idleServiceContractID, idleServiceObj);
-  }
-  catch(err) {
-    dump("test_bug715041.xul: Failed to register mock idle service.\n");
-  }
-
-  SimpleTest.waitForExplicitFinish();
-  SimpleTest.requestLongerTimeout(10);
-
-  AddOutOfOrderActiveEnabled = true;
-  AddOutOfOrderIdleEnabled = true;
-  AddNewLocalWhileAllIdleEnabled = true;
-  TestActiveToActiveNotificationEnabled = true;
-  AddShiftLocalEnabled = true;
-  AddIdleObserverWithInvalidTimeEnabled = false;
-  
-  SpecialPowers.pushPrefEnv({"set":[['dom.idle-observers-api.fuzz_time.disabled', true]]}, caseZero);
-    ]]>
-    </script>
-    </window>
-
deleted file mode 100644
--- a/dom/base/test/test_bug715041_removal.xul
+++ /dev/null
@@ -1,834 +0,0 @@
-<?xml version="1.0"?>
-<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
-<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=715041
--->
-    <window title="Mozilla Bug 715041"
-xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-    <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
-
-    <!-- test results are displayed in the html:body -->
-    <body xmlns="http://www.w3.org/1999/xhtml">
-    <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=715041"
-target="_blank">Mozilla Bug 715041</a>
-    </body>
-
-    <!-- test code goes here -->
-    <script type="application/javascript">
-    <![CDATA[
-
-  /** Mock Idle Service Test for Bug 715041 **/
-  try {
-    var idleServiceCID = Components.ID("6f95d965-4322-4829-8a3c-5dc8a4587f4d");
-    var idleServiceContractID = "@mozilla.org/widget/idleservice;1";
-    var oldIdleService = Cc[idleServiceContractID].getService(Ci.nsIIdleService);
-  }
-  catch (ex) {
-    dump("test_bug715041_removal.xul: failed to get old idle service 1.");
-  }
-
-  //class mock javascript idle service
-  var idleServiceObj = {
-    observers: [],
-    windowObservers: [],
-    idleTimeInMS: 5000,   //in milli seconds
-
-    // takes note of the idle observers added as the minimum idle observer
-    //with the idle service
-    timesAdded: [],
-
-    QueryInterface: function(iid) {
-      if (iid.equals(Ci.nsISupports) ||
-          iid.equals(Ci.nsIFactory) ||
-          iid.equals(Ci.nsIIdleService)) {
-        return this;
-      }
-      throw Cr.NS_ERROR_NO_INTERFACE;
-    },
-
-    createInstance: function(outer, iid) {
-      return this.QueryInterface(iid);
-    },
-
-    get idleTime() {
-      return this.idleTimeInMS; //in milli seconds
-    },
-
-    set idleTime(timeInMS) {
-      this.idleTimeInMS = timeInMS;
-    },
-
-    getWindowFromObserver: function(observer) {
-      try {
-        var interfaceRequestor = observer.QueryInterface(Ci.nsIInterfaceRequestor);
-        var window = interfaceRequestor.getInterface(Ci.nsIDOMWindow);
-        return window;
-      }
-      catch (e) {}
-
-      return null;
-    },
-
-    testIdleBackService: function(observer, topic) {
-      dump("\nJS FAKE IDLE SERVICE\n");
-      dump("JS NUM OBSERVERS: " + this.observers.length + "\n");
-
-      if (this.observers.length > 1) {
-        this.observers[1].observer.observe(observer, topic, '\0');
-        dump("JS CALLED OBSERVE FUNCTION!!!\n\n");
-      }
-    },
-
-    addIdleObserver: function(observer, time) {
-      dump("\nJS FAKE IDLE SERVICE add idle observer before\n");
-      dump("JS NUM OBSERVERS: " + this.observers.length + "\n");
-      var window = this.getWindowFromObserver(observer);
-
-      if (window) {
-        this.observers.push({ observer: observer, time: time, });
-        addedIdleObserver = true;
-        numIdleObserversAdded++;
-        this.timesAdded.push(time);
-        dump ("\nMOCK IDLE SERVICE ADDING idle observer with time: " + time + "\n");
-        dump("MOCK IDLE SERVICE: num idle observers added: " + numIdleObserversAdded + "\n\n");
-      }
-      else {
-        dump("SHOULD NEVER GET HERE!");
-        oldIdleService.addIdleObserver(observer, time);
-        addedIdleObserver = false;
-      }
-
-      dump("\nJS FAKE IDLE SERVICE end of add idle observer\n");
-      dump("JS NUM OBSERVERS: " + this.observers.length + "\n");
-    },
-
-    removeIdleObserver: function(observer, time) {
-      dump("\nJS REMOVE IDLE OBSERVER () time to be removed: " + time + "\n");
-      var window = this.getWindowFromObserver(observer);
-      if (!window) {
-        oldIdleService.removeIdleObserver(observer, time);
-      }
-      else {
-        var observerIndex = -1;
-        for (var i=0; i<this.observers.length; i++) {
-          dump("JS removeIdleObserver() observer time: " + this.observers[i].time + "\n");
-          if (this.observers[i].time === time) {
-              observerIndex = i;
-              break;
-          }
-         }
-
-        if (observerIndex != -1 && this.observers.length > 0) {
-          numIdleObserversRemoved++;
-          this.observers.splice(observerIndex, 1);
-          removedIdleObserver = true;
-          dump("MOCK IDLE SERVICE REMOVING idle observer with time " + time + "\n");
-          dump("MOCK IDLE SERVICE numIdleObserversRemoved: " + numIdleObserversRemoved + " numIdleObserversAdded: " + numIdleObserversAdded + "\n\n");
-        }
-        else {
-          removedIdleObserver = false;
-        }
-      }
-      dump("\nJS FAKE IDLE SERVICE end of remove idle observer\n");
-      dump("JS NUM OBSERVERS: " + this.observers.length + "\n");
-    },
-  };
-
-  /** Test for Bug 715041 **/
-  dump("\n\n\nJS STARTING TESTING FOR BUG 715041 REMOVAL\n");
-
-  //bool variables
-  var addedIdleObserver = removedIdleObserver = passed = cleanUp = false;
-
-  //msgXCount
-  var msg0Count = msg1Count = msg2Count = msg3Count = msg4Count = msg5Count =
-      msg6Count = tcZero = currTestCaseNum = prevMsgNum = 0;
-
-  //test case number
-  var tcRemoveHeadIdleObserverWhileActive = 0;
-  var tcRemoveLocalIdleObserverWhileIdle = 1;
-  var tcRemoveHeadIdleObserver = 2;
-  var tcRemoveLocalIdleTimerWhileIdle = 3;
-  var tcRemoveLocalIdleTimerLastElement = 4;
-  var tcRemoveHeadAfterLastLocalFired = 5;
-  var tcRemoveHeadIdleObserverWhileIdleCase1 = 6;
-  var tcRemoveLastAddLast = 7;
-
-  function ResetMsgCounts() {
-    msg0Count = msg1Count = msg2Count = msg3Count = msg4Count = msg5Count =
-    msg6Count = prevMsgNum = 0;
-  }
-
-  function ResetVars() {
-    msg0Count = msg1Count = msg2Count = msg3Count = msg4Count = msg5Count =
-    msg6Count = prevMsgNum = 0;
-
-    numIdleObserversAdded = numIdleObserversRemoved = 0;
-    currTestCaseNum = -1;
-    addedIdleObserver = removedIdleObserver = passed = cleanUp = false;
-  }
-
-  function printVariableValues()
-  {
-    dump("\nfunction printVariableValues()\ncurrTestCaseNum: " + currTestCaseNum +
-          "\ncleanUp: " + cleanUp +
-          "\npassed: " + passed +
-          "\nnumIdleObserversRemoved: " + numIdleObserversRemoved +
-          "\nnumIdleObservesAdded: " + numIdleObserversAdded +
-          "\nmsg1Count " + msg1Count +
-          "\nmsg2Count " + msg2Count +
-          "\nmsg3Count " + msg3Count +
-          "\nmsg4Count " + msg4Count +
-          "\nmsg5Count " + msg5Count +
-          "\n");
-  }
-
-  //Place Holder.
-  var idleHandler0 = function() { dump("msg 0, should never be used!\n"); };
-
-  //idleHandler1
-  function idleHandler1() {
-    msg1Count++;
-    dump("msg 1 Count: " + msg1Count + "\n");
-
-    switch (currTestCaseNum) {
-    case tcRemoveHeadIdleObserver:
-      if (msg1Count === 1 && !msg2Count && !msg3Count && !msg4Count && !msg5Count) {
-        window.navigator.removeIdleObserver(idleObserversArray[1]);
-      }
-      break;
-    case tcRemoveLocalIdleObserverWhileIdle:
-      if (msg1Count === 1 && !msg2Count && !msg3Count && !msg4Count) {
-        window.navigator.removeIdleObserver(idleObserversArray[2]);
-      }
-      break;
-    case tcRemoveLocalIdleTimerWhileIdle:
-      if (msg1Count === 1 && !msg2Count && !msg3Count && !msg4Count) {
-        idleServiceObj.idleTime = 2000;
-        window.navigator.removeIdleObserver(idleObserversArray[3]);
-      }
-      break;
-    case tcRemoveHeadIdleObserverWhileIdleCase1:
-      if (msg1Count === 1 && !msg2Count && !msg3Count && !msg4Count) {
-        for (var i=1; i<4; i++) {
-          window.navigator.addIdleObserver(idleObserversArray[i]);
-        }
-        window.navigator.addIdleObserver(idleObserversArray[2]);
-        window.navigator.addIdleObserver(idleObserversArray[3]);
-
-        idleServiceObj.idleTime = 1200;
-        window.navigator.removeIdleObserver(idleObserversArray[1]);
-      }
-      break;
-    case tcRemoveLocalIdleTimerLastElement:
-      if (msg1Count === 1 && !msg2Count && !msg3Count && !msg4Count && !msg5Count) {
-        idleServiceObj.idleTime = 1500;
-        window.navigator.removeIdleObserver(idleObserversArray[1]);
-        idleServiceObj.idleTime = 1700;
-        window.navigator.addIdleObserver(idleObserversArray[2]);
-        idleServiceObj.idleTime = 2000;
-        idleServiceObj.testIdleBackService(idleObserversArray[2], "idle");
-      }
-      break;
-    case tcRemoveHeadAfterLastLocalFired:
-      if (msg1Count === 1 && !msg2Count && !msg3Count && !msg4Count && !msg5Count) {
-        dump("idle handler 1:     case tcRemoveHeadAfterLastLocalFired:\n");
-        window.navigator.addIdleObserver(idleObserversArray[2]);
-        window.navigator.addIdleObserver(idleObserversArray[3]);
-        window.navigator.addIdleObserver(idleObserversArray[4]);
-      }
-      break;
-    case tcRemoveLastAddLast:
-      window.navigator.addIdleObserver(idleObserversArray[2]);
-      window.navigator.addIdleObserver(idleObserversArray[3]);
-      break;
-    default:
-      break;
-    }
-  }
-
-  //idleHandler2
-  function idleHandler2() {
-    msg2Count++;
-    dump("msg 2 Count: " + msg2Count + "\n");
-
-    switch (currTestCaseNum) {
-    case tcRemoveLocalIdleTimerLastElement:
-      if (msg1Count === 1 && msg2Count === 1 && !msg3Count && !msg4Count) {
-        window.navigator.addIdleObserver(idleObserversArray[3]);
-        window.navigator.addIdleObserver(idleObserversArray[4]);
-        window.navigator.removeIdleObserver(idleObserversArray[3]);
-      }
-      break;
-    default:
-      //do nothing.
-      break;
-    }
-  }
-
-  //idleHandler3
-  function idleHandler3() {
-    msg3Count++;
-    dump("msg 3 Count: " + msg3Count + "\n");
-    passed = false;
-    switch (currTestCaseNum) {
-    case tcRemoveHeadIdleObserverWhileActive:
-      if (!msg1Count && msg2Count === 1 && msg3Count === 1) {
-        passed = true;
-      }
-      dump("idleHandler3: passed: " + passed + "\n");
-      RemoveHeadIdleObserverWhileActiveCleanUp();
-      break;
-    case tcRemoveHeadIdleObserverWhileIdleCase1:
-      if (msg3Count != 2 && msg3Count != 4) {
-        return;
-      }
-
-      if (msg1Count === 2 && msg2Count === 2 && msg3Count === 2 && !msg4Count) {
-        passed = true;
-        ok(passed, "Failed test case remove head idle observer while idle case 1, part 1.\n");
-        idleServiceObj.testIdleBackService(idleObserversArray[1], "active");
-        return;
-      }
-
-      if (msg1Count === 3 && msg2Count === 4 && msg3Count === 4 &&
-        !msg4Count && !msg5Count) {
-        passed = true;
-      }
-      RemoveHeadIdleObserverWhileIdleCase1CleanUp();
-      break;
-    case tcRemoveLastAddLast:
-      if (msg1Count === 1 && msg2Count === 1 && msg3Count === 1
-          && !msg4Count && !msg5Count) {
-        idleServiceObj.idleTime = 3200;
-        window.navigator.removeIdleObserver(idleObserversArray[3]);
-        idleServiceObj.idleTime = 3500;
-        window.navigator.addIdleObserver(idleObserversArray[4]);
-        return;
-      }
-      break;
-    case tcRemoveHeadAfterLastLocalFired:
-      if (msg3Count === 1) {
-        return;
-      }
-
-      if (msg1Count === 2 && msg2Count === 2 && msg3Count === 2 && msg4Count === 1) {
-        passed = true;
-      }
-      RemoveHeadAfterLastLocalFiredCleanUp();
-      break;
-    default:
-      break;
-    }
-  }
-
-  //idleHandler4
-  function idleHandler4() {
-    msg4Count++;
-    dump("msg 4 Count: " + msg4Count + "\n");
-
-    switch (currTestCaseNum) {
-    case tcRemoveLocalIdleObserverWhileIdle:
-      if (msg1Count === 1 && !msg2Count && msg3Count === 1 && msg4Count === 1) {
-        passed = true;
-        RemoveLocalIdleObserverWhileIdleCleanUp();
-      }
-      break;
-    case tcRemoveHeadIdleObserver:
-      printVariableValues();
-      if (msg1Count === 1 && msg2Count === 1 && msg3Count === 1 && msg4Count === 1) {
-        passed = true;
-        RemoveHeadIdleObserverCleanUp();
-      }
-      break;
-    case tcRemoveLocalIdleTimerWhileIdle:
-      if (msg1Count === 1 && !msg2Count && !msg3Count && msg4Count === 1) {
-        passed = true;
-        RemoveLocalIdleTimerWhileIdleCleanUp();
-      }
-      break
-    case tcRemoveLocalIdleTimerLastElement:
-      if (msg1Count === 1 && msg2Count === 1 && !msg3Count && msg4Count === 1) {
-        passed = true;
-        ok(passed, "Failed test case remove local idle timer last element.\n");
-        RemoveLocalIdleTimerLastElementCleanUp();
-      }
-    break;
-    case tcRemoveHeadAfterLastLocalFired:
-      if (msg1Count === 1 && msg2Count === 1 && msg3Count === 1 && msg4Count === 1) {
-        window.navigator.removeIdleObserver(idleObserversArray[4]);
-        passed = true;
-        ok(passed, "Failed remove head after last local fired.\n");
-        idleServiceObj.testIdleBackService(idleObserversArray[1], "active");
-      }
-      break;
-    case tcRemoveLastAddLast:
-      if (msg1Count === 1 && msg2Count === 1 && msg3Count === 1 && msg4Count == 1) {
-        idleServiceObj.idleTime = 4100;
-        passed = true;
-        RemoveLastAddLastCleanUp();
-      }
-      break;
-    default:
-      //do nothing.
-      break;
-    }
-  }
-
-  //idleHandler5
-  function idleHandler5() {
-    msg5Count++;
-    dump("msg 5 Count: " + msg5Count + "\n");
-
-    switch (currTestCaseNum) {
-
-    default:
-      //do nothing.
-      break;
-    }
-  }
-
-  //idleHandler6
-  function idleHandler6() {
-    dump("msg 6 Count: " + msg6Count + "\n");
-  }
-
-  var  idleObserversArray = [];
-  idleObserversArray[0] = {time: 0, onidle: idleHandler0, onactive: idleHandler0};
-  idleObserversArray[1] = {time: 1, onidle: idleHandler1, onactive: idleHandler1};
-  idleObserversArray[2] = {time: 2, onidle: idleHandler2, onactive: idleHandler2};
-  idleObserversArray[3] = {time: 3, onidle: idleHandler3, onactive: idleHandler3};
-  idleObserversArray[4] = {time: 4, onidle: idleHandler4, onactive: idleHandler4};
-  idleObserversArray[5] = {time: 5, onidle: idleHandler5, onactive: idleHandler5};
-  idleObserversArray[6] = {time: 0, onidle: idleHandler6, onactive: idleHandler6};
-
-  //observers array space holder at index zero
-  idleServiceObj.observers.push( {observer: idleObserversArray[0], time: 0, } );
-
-    /*
-  * - function RemoveHeadIdleObserverWhileActive1()
-  * - Remove head idle observer before the head idle notification is fired by the
-  *   idle service. I.e. remove the head idle observer while the user is active.
-  * - RESULT: prints 2 in 2ms, 3
-  */
-  function RemoveHeadIdleObserverWhileActive() {
-    dump("\n\nTESTING CASE RemoveHeadIdleObserverWhileActive\n");
-    dump("=================================\n");
-
-    ResetVars();
-    currTestCaseNum = tcRemoveHeadIdleObserverWhileActive;
-    idleServiceObj.idleTime = 500;
-
-    window.navigator.addIdleObserver(idleObserversArray[1]);
-    dump("test_bug715041_removal.xul: RemoveHeadIdleObserverWhileActive() idle time " + idleServiceObj.idleTime + "\n");
-    window.navigator.addIdleObserver(idleObserversArray[2]);
-    window.navigator.addIdleObserver(idleObserversArray[3]);
-
-    idleServiceObj.idleTime = 800;
-    window.navigator.removeIdleObserver(idleObserversArray[1]);
-
-    idleServiceObj.idleTime = 1000;
-    idleServiceObj.testIdleBackService(idleObserversArray[2], "idle");
-  }
-
-  function RemoveHeadIdleObserverWhileActiveCleanUp() {
-    dump("\nRemoveHeadIdleObserverWhileActiveCleanUp()\n");
-    dump("=====================================\n");
-
-    dump("Passed: " + passed + "\n");
-    ok(passed, "Failed test case: RemoveHeadIdleObserverWhileActive");
-
-    ResetVars();
-    currTestCaseNum = tcRemoveHeadIdleObserverWhileActive;
-    idleServiceObj.idleTime = 3500;
-
-    for (var i=2; i<4; i++) {
-      window.navigator.removeIdleObserver(idleObserversArray[i]);
-    }
-
-    dump("JS RemoveHeadIdleObserverWhileActiveCleanUp() DONE\n");
-    if (RemoveLocalIdleObserverWhileIdleEnabled) {
-        RemoveLocalIdleObserverWhileIdle();
-    }
-    else {
-      dump("Finishing testing idle API.\n");
-      SimpleTest.finish();
-    }
-  }
-
-  /*
-  * function RemoveLocalIdleObserverWhileIdle()
-  * Remove local observer before the local oberver at index 1 is triggered while
-  * the user is idle.
-  * RESULT: should print 1, 3, 4
-  */
-  function RemoveLocalIdleObserverWhileIdle() {
-    dump("\n\nTESTING CASE RemoveLocalIdleObserverWhileIdle\n");
-    dump("=================================\n");
-
-    ResetVars();
-    currTestCaseNum = tcRemoveLocalIdleObserverWhileIdle;
-    idleServiceObj.idleTime = 500;
-
-    window.navigator.addIdleObserver(idleObserversArray[1]);
-    window.navigator.addIdleObserver(idleObserversArray[2]);
-    window.navigator.addIdleObserver(idleObserversArray[3]);
-    window.navigator.addIdleObserver(idleObserversArray[4]);
-
-    idleServiceObj.idleTime = 1000;
-    idleServiceObj.testIdleBackService(idleObserversArray[1], "idle");
-  }
-
-  function RemoveLocalIdleObserverWhileIdleCleanUp()  {
-    dump("\nRemoveLocalIdleObserverWhileIdleCleanUp()\n");
-    dump("=====================================\n");
-
-    ok(passed, "Failed test case: RemoveLocalIdleObserverWhileIdleCleanUp()");
-
-    ResetVars();
-    currTestCaseNum = tcRemoveHeadIdleObserverWhileActive;
-    idleServiceObj.idleTime = 3500;
-
-    window.navigator.removeIdleObserver(idleObserversArray[1]);
-    window.navigator.removeIdleObserver(idleObserversArray[3]);
-    window.navigator.removeIdleObserver(idleObserversArray[4]);
-
-    dump("JS RemoveLocalIdleObserverWhileIdleCleanUp() DONE\n");
-    if (RemoveHeadIdleObserverEnabled) {
-      RemoveHeadIdleObserver();
-    }
-    else {
-      dump("Finishing testing idle API.\n");
-      SimpleTest.finish();
-    }
-  }
-
-
-  /*
-   * function RemoveHeadIdleObserver()
-   * Remove head idle observer while the user has been idle for 2400 ms.
-   * - RESULT: prints 1, 2, remove 2, 3, 4
-   */
-  function RemoveHeadIdleObserver() {
-    dump("\n\nTESTING CASE RemoveHeadIdleObserver\n");
-    dump("=================================\n");
-
-    ResetVars();
-    currTestCaseNum = tcRemoveHeadIdleObserver;
-    idleServiceObj.idleTime = 500;
-
-    window.navigator.addIdleObserver(idleObserversArray[1]);
-    window.navigator.addIdleObserver(idleObserversArray[2]);
-    window.navigator.addIdleObserver(idleObserversArray[3]);
-    window.navigator.addIdleObserver(idleObserversArray[4]);
-
-    idleServiceObj.idleTime = 1000;
-    idleServiceObj.testIdleBackService(idleObserversArray[1], "idle");
-  }
-
-  function RemoveHeadIdleObserverCleanUp()  {
-    dump("\nRemoveHeadIdleObserverCleanUp()\n");
-    dump("=====================================\n");
-
-    ok(passed, "Failed test case: RemoveHeadIdleObserverCleanUp()");
-
-    ResetVars();
-    currTestCaseNum = tcRemoveHeadIdleObserver;
-    idleServiceObj.idleTime = 3500;
-
-    for (var i=2; i<5; i++) {
-      window.navigator.removeIdleObserver(idleObserversArray[i]);
-    }
-
-    dump("JS RemoveHeadIdleObserverCleanUp() DONE\n");
-    if (RemoveLocalIdleTimerWhileIdleEnabled) {
-      RemoveLocalIdleTimerWhileIdle();
-    }
-    else {
-      dump("Finishing testing idle API.\n");
-      SimpleTest.finish();
-    }
-  }
-
-  /*
-   * RemoveLocalIdleTimerWhileIdle()
-   * - Removes the idle observer that is also set as the current local idle timer callback
-   *   local idle observer being removed is NOT at index 1!
-   * - RESULT: should trigger 1 in 1ms and 4 in 4ms
-   */
-  function RemoveLocalIdleTimerWhileIdle()
-  {
-    dump("\n\nTESTING CASE RemoveLocalIdleTimerWhileIdle\n");
-    dump("=================================\n");
-
-    ResetVars();
-    currTestCaseNum = tcRemoveLocalIdleTimerWhileIdle;
-    idleServiceObj.idleTime = 500;
-
-    window.navigator.addIdleObserver(idleObserversArray[1]);
-    window.navigator.addIdleObserver(idleObserversArray[3]);
-    window.navigator.addIdleObserver(idleObserversArray[4]);
-
-    idleServiceObj.idleTime = 1000;
-    idleServiceObj.testIdleBackService(idleObserversArray[1], "idle");
-  }
-
-  function RemoveLocalIdleTimerWhileIdleCleanUp()
-  {
-    dump("\nRemoveLocalIdleTimerWhileIdleCleanUp()\n");
-    dump("=====================================\n");
-
-    ok(passed, "Failed test case: RemoveLocalIdleTimerWhileIdleCleanUp()");
-
-    ResetVars();
-    currTestCaseNum = tcRemoveLocalIdleTimerWhileIdle;
-
-    window.navigator.removeIdleObserver(idleObserversArray[1]);
-    window.navigator.removeIdleObserver(idleObserversArray[4]);
-
-    dump("JS RemoveLocalIdleTimerWhileIdleCleanUp() DONE\n");
-    if (RemoveLocalIdleTimerLastElementEnabled) {
-        RemoveLocalIdleTimerLastElement();
-    }
-    else {
-      dump("Finishing testing idle API.\n");
-      SimpleTest.finish();
-    }
-  }
-
-  /*
-   * function RemoveLocalIdleTimerLastElement()
-   */
-  function RemoveLocalIdleTimerLastElement()
-  {
-    dump("\n\nTESTING CASE RemoveLocalIdleTimerLastElement\n");
-    dump("=================================\n");
-
-    ResetVars();
-    currTestCaseNum = tcRemoveLocalIdleTimerLastElement;
-    idleServiceObj.idleTime = 1200;
-
-    window.navigator.addIdleObserver(idleObserversArray[1]);
-    idleServiceObj.testIdleBackService(idleObserversArray[1], "idle");
-  }
-
-  function RemoveLocalIdleTimerLastElementCleanUp() {
-    dump("\nRemoveLocalIdleTimerLastElementCleanUp()\n");
-    dump("=====================================\n");
-
-    ok(passed, "Failed test case: RemoveLocalIdleTimerLastElementCleanUp()");
-
-    ResetVars();
-    currTestCaseNum = tcRemoveLocalIdleTimerLastElement;
-    window.navigator.removeIdleObserver(idleObserversArray[2]);
-    window.navigator.removeIdleObserver(idleObserversArray[4]);
-
-    dump("JS RemoveLocalIdleTimerLastElementCleanUp() DONE\n");
-    if (RemoveHeadAfterLastLocalFiredEnabled) {
-      RemoveHeadAfterLastLocalFired();
-    }
-    else {
-      dump("Finishing testing idle API.\n");
-      SimpleTest.finish();
-    }
-  }
-
-  /*
-   - Remove the head after the last local idle timer has been fired
-   - add 1 2 3 4
-   - after 4 has been notified, removed idle observer with time 4
-   - send a back topic
-   - message notification should be 1, 2, 3.
-  */
-  function RemoveHeadAfterLastLocalFired()
-  {
-    dump("\n\nTESTING CASE RemoveHeadAfterLastLocalFired\n");
-    dump("=================================\n");
-
-    ResetVars();
-    currTestCaseNum = tcRemoveHeadAfterLastLocalFired;
-    idleServiceObj.idleTime = 1200;
-
-    window.navigator.addIdleObserver(idleObserversArray[1]);
-    idleServiceObj.testIdleBackService(idleObserversArray[1], "idle");
-  }
-
-  function RemoveHeadAfterLastLocalFiredCleanUp() {
-    dump("\RemoveHeadAfterLastLocalFiredCleanUp()\n");
-    dump("=====================================\n");
-
-    ok(passed, "Failed test case: RemoveHeadAfterLastLocalFiredCleanUp()");
-
-    ResetVars();
-    currTestCaseNum = tcRemoveHeadAfterLastLocalFired;
-
-    window.navigator.removeIdleObserver(idleObserversArray[1]);
-    window.navigator.removeIdleObserver(idleObserversArray[2]);
-    window.navigator.removeIdleObserver(idleObserversArray[3]);
-
-    dump("JS RemoveHeadAfterLastLocalFiredCleanUp() DONE\n");
-    if (RemoveHeadIdleObserverWhileIdleCase1Enabled) {
-      RemoveHeadIdleObserverWhileIdleCase1();
-    }
-    else {
-      dump("Finishing testing idle API.\n");
-      SimpleTest.finish();
-    }
-  }
-
-  function RemoveHeadIdleObserverWhileIdleCase1() {
-    dump("\n\nTESTING CASE RemoveHeadIdleObserverWhileIdleCase1\n");
-    dump("=================================\n");
-
-    ResetVars();
-    currTestCaseNum = tcRemoveHeadIdleObserverWhileIdleCase1;
-    idleServiceObj.idleTime = 1000;
-    window.navigator.addIdleObserver(idleObserversArray[1]);
-    idleServiceObj.testIdleBackService(idleObserversArray[1], "idle");
-  }
-
-  function RemoveHeadIdleObserverWhileIdleCase1CleanUp() {
-    dump("\nRemoveHeadIdleObserverWhileIdleCase1CleanUp()\n");
-    dump("=====================================\n");
-
-    ok(passed, "Failed test case: RemoveHeadIdleObserverWhileIdleCase1CleanUp()");
-
-    ResetVars();
-    currTestCaseNum = tcRemoveHeadIdleObserverWhileIdleCase1;
-
-    for (var i=1; i<4; i++) {
-      window.navigator.removeIdleObserver(idleObserversArray[i]);
-    }
-
-    window.navigator.removeIdleObserver(idleObserversArray[2]);
-    window.navigator.removeIdleObserver(idleObserversArray[3]);
-
-    dump("JS RemoveHeadIdleObserverWhileIdleCase1CleanUp() DONE\n");
-    if (RemoveLastAddLastEnabled) {
-      RemoveLastAddLast();
-    }
-    else {
-      dump("Finishing testing idle API.\n");
-      SimpleTest.finish();
-    }
-  }
-
-  /*
-   * - RemoveLastAddLast()
-   *
-   * - User is currently idle.
-   * - Add callback 1, 2, 3,
-   * - Remove callback 3 after 3200 MS. I.e. after callback 3 has been notified.
-   * - Add callback 4 after 3500 MS
-   * - Output: 1, 2, 3, 4
-   */
-  function RemoveLastAddLast()
-  {
-    dump("\n\nTESTING CASE RemoveLastAddLast()\n");
-    dump("=================================\n");
-
-    ResetVars();
-    currTestCaseNum = tcRemoveLastAddLast;
-    idleServiceObj.idleTime = 1000;
-    window.navigator.addIdleObserver(idleObserversArray[1]);
-    idleServiceObj.testIdleBackService(idleObserversArray[1], "idle");
-  }
-
-  function RemoveLastAddLastCleanUp()
-  {
-    dump("\RemoveLastAddLastCleanUp()\n");
-    dump("=====================================\n");
-
-    ok(passed, "Failed test case: RemoveLastAddLastCleanUp()");
-
-    ResetVars();
-    currTestCaseNum = tcRemoveLastAddLast;
-
-    window.navigator.removeIdleObserver(idleObserversArray[1]);
-    window.navigator.removeIdleObserver(idleObserversArray[2]);
-    window.navigator.removeIdleObserver(idleObserversArray[4]);
-
-    if (numIdleObserversRemoved === 1 && !numIdleObserversAdded) {
-      ok(true, "Failed test case: RemoveLastAddLastCleanUp()");
-    }
-    else {
-      ok(false, "Failed test case: RemoveLastAddLastCleanUp()");
-    }
-
-
-    try {
-      componentMgr.unregisterFactory(idleServiceCID, idleServiceObj);
-    }
-    catch(err) {
-      dump("test_bug715041_removal.xul: RemoveLastAddLastCleanUp() Failed to unregister factory, mock idle service!\n");
-    }
-
-    try {
-      componentMgr.registerFactory(oldIdleServiceCID, "Re registering old idle service", idleServiceContractID, null);
-    }
-    catch(err) {
-      dump("test_bug715041_removal.xul: RemoveLastAddLastCleanUp() Failed to register factory, original idle service!\n");
-    }
-
-    dump("JS RemoveLastAddLastCleanUp() DONE\n");
-    dump("Finishing testing idle API.\n");
-    SimpleTest.finish();
-  }
-
-
-  // Registering new moch JS idle service
-  SimpleTest.waitForExplicitFinish();
-  SimpleTest.requestLongerTimeout(10);
-
-  try {
-    var idleServiceCID = Components.ID("0fdc1bbf-3868-4660-9855-0c2e376922bc");
-    var idleServiceContractID = "@mozilla.org/widget/idleservice;1";
-    var oldIdleService = Cc[idleServiceContractID].getService(Ci.nsIIdleService);
-  }
-  catch(ex) {
-    dump("test_bug715041_removal.xul: 1) Failed to get old idle service.\n");
-  }
-
-  try {
-    // Registering new moch JS idle service
-    var componentMgr = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
-  }
-  catch(err) {
-    dump("test_bug715041_removal.xul: Failed to query component registrar interface.\n");
-  }
-
-  try {
-    var oldIdleServiceFactoryObj = componentMgr.getClassObjectByContractID(idleServiceContractID, Ci.nsIFactory);
-  }
-  catch(err) {
-    dump("test_bug715041_removal.xul: Failed to get old idle service.\n");
-  }
-
-  try {
-    var oldIdleServiceCID = componentMgr.contractIDToCID(idleServiceContractID);
-  }
-  catch(err) {
-    dump("test_bug715041._removalxul: Failed to convert ID to CID for old idle service.\n");
-  }
-
-  try {
-    componentMgr.registerFactory(idleServiceCID, "Test Simple Idle/Back Notifications", idleServiceContractID, idleServiceObj);
-  }
-  catch(err) {
-    dump("test_bug715041_removal.xul: Failed to register mock idle service.\n");
-  }
-
-  //test case enabled
-  var RemoveLocalIdleObserverWhileIdleEnabled = true;
-  var RemoveHeadIdleObserverEnabled = true;
-  var RemoveLocalIdleTimerWhileIdleEnabled = true;
-  var RemoveLocalIdleTimerLastElementEnabled = true;
-  var RemoveHeadAfterLastLocalFiredEnabled = true;
-  var RemoveHeadIdleObserverWhileIdleCase1Enabled = true;
-  var RemoveLastAddLastEnabled = true;
-  SpecialPowers.pushPrefEnv({"set":[['dom.idle-observers-api.fuzz_time.disabled', true]]}, RemoveHeadIdleObserverWhileActive);
-]]>
-    </script>
-    </window>
-
--- a/dom/tests/mochitest/general/chrome.ini
+++ b/dom/tests/mochitest/general/chrome.ini
@@ -1,8 +1,7 @@
 [DEFAULT]
 skip-if = os == 'android'
 
-[test_idleapi_permissions.html]
 [test_innerScreen.xul]
 [test_offsets.xul]
 support-files = test_offsets.css test_offsets.js
 [test_spacetopagedown.html]
deleted file mode 100644
--- a/dom/tests/mochitest/general/test_idleapi_permissions.html
+++ /dev/null
@@ -1,48 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for idle api permissions</title>
-  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<p id="display"></p>
-<div id="content" style="display: none">
-</div>
-<pre id="test">
-<script type="application/javascript">
-
-var idleObserver = {
-  onidle: null,
-  onactive: null
-};
-
-function doAddIdleObserver(obs) {
-  var i = document.createElement("iframe");
-  document.body.appendChild(i);
-  var added = false;
-  try {
-    i.contentWindow.navigator.addIdleObserver(obs);
-    added = true;
-  } catch (e) { }
-  i.remove();
-  return added;
-}
-
-function run_test() {
-  // addIdleObserver checks whether time is > 0.
-  this.idleObserver.time = 100;
-
-  SpecialPowers.pushPermissions([{type: "idle", allow: true, context: document}], () => {
-    added = doAddIdleObserver(this.idleObserver, true);
-    ok(added, "Should be able to add idle observer with permission.");
-    SimpleTest.finish();
-  });
-}
-
-SimpleTest.waitForExplicitFinish();
-addLoadEvent(run_test);
-</script>
-</pre>
-</body>
-</html>
--- a/dom/webidl/Navigator.webidl
+++ b/dom/webidl/Navigator.webidl
@@ -170,24 +170,16 @@ partial interface Navigator {
      * @param permitted permission state (true for allowing vibration)
      * @param persistent make the permission session-persistent
      */
     [ChromeOnly]
     void setVibrationPermission(boolean permitted,
                                 optional boolean persistent = true);
 };
 
-callback interface MozIdleObserver {
-  // Time is in seconds and is read only when idle observers are added
-  // and removed.
-  readonly attribute unsigned long time;
-  void onidle();
-  void onactive();
-};
-
 partial interface Navigator {
   [Throws, Constant, Cached, NeedsCallerType]
   readonly attribute DOMString oscpu;
   // WebKit/Blink support this; Trident/Presto do not.
   readonly attribute DOMString vendor;
   // WebKit/Blink supports this (hardcoded ""); Trident/Presto do not.
   readonly attribute DOMString vendorSub;
   // WebKit/Blink supports this (hardcoded "20030107"); Trident/Presto don't
@@ -195,28 +187,16 @@ partial interface Navigator {
   // WebKit/Blink/Trident/Presto support this.
   readonly attribute boolean cookieEnabled;
   [Throws, Constant, Cached, NeedsCallerType]
   readonly attribute DOMString buildID;
 
   // WebKit/Blink/Trident/Presto support this.
   [Affects=Nothing, DependsOn=Nothing]
   boolean javaEnabled();
-
-  /**
-   * Navigator requests to add an idle observer to the existing window.
-   */
-  [Throws, ChromeOnly]
-  void addIdleObserver(MozIdleObserver aIdleObserver);
-
-  /**
-   * Navigator requests to remove an idle observer from the existing window.
-   */
-  [Throws, ChromeOnly]
-  void removeIdleObserver(MozIdleObserver aIdleObserver);
 };
 
 // NetworkInformation
 partial interface Navigator {
   [Throws, Pref="dom.netinfo.enabled"]
   readonly attribute NetworkInformation connection;
 };
 
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -5318,20 +5318,16 @@ pref("layout.css.touch_action.enabled", 
 pref("memory.ghost_window_timeout_seconds", 60);
 
 // Don't dump memory reports on OOM, by default.
 pref("memory.dump_reports_on_oom", false);
 
 // Number of stack frames to capture in createObjectURL for about:memory.
 pref("memory.blob_report.stack_frames", 0);
 
-// Disable idle observer fuzz, because only privileged content can access idle
-// observers (bug 780507).
-pref("dom.idle-observers-api.fuzz_time.disabled", true);
-
 // Activates the activity monitor
 pref("io.activity.enabled", false);
 
 // If true, reuse the same global for (almost) everything loaded by the component
 // loader (JS components, JSMs, etc). This saves memory, but makes it possible
 // for the scripts to interfere with each other.  A restart is required for this
 // to take effect.
 pref("jsloader.shareGlobal", true);