Backed out 2 changesets (bug 1432271) for bustage in /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/dom/Navigator.h:79:23 on a CLOSED TREE
authorNoemi Erli <nerli@mozilla.com>
Sat, 27 Jan 2018 02:49:25 +0200
changeset 747923 e7e552647dcbe9c7846fc99798e4f6bed3c7db79
parent 747922 7af7827525c8188c0ba8bd3ba0dab16c778d3c12
child 747924 81157078b090fda2f79d42a1e0e93b1b86449944
push id97032
push userbmo:emilio@crisal.io
push dateSat, 27 Jan 2018 01:02:51 +0000
bugs1432271
milestone60.0a1
backs out7af7827525c8188c0ba8bd3ba0dab16c778d3c12
79b9d49e08db829bcbd8165d8c07d4c842123d91
Backed out 2 changesets (bug 1432271) for bustage in /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/dom/Navigator.h:79:23 on a CLOSED TREE Backed out changeset 7af7827525c8 (bug 1432271) Backed out changeset 79b9d49e08db (bug 1432271)
dom/base/Navigator.cpp
dom/base/Navigator.h
dom/base/moz.build
dom/base/nsGlobalWindowInner.cpp
dom/base/nsGlobalWindowInner.h
dom/base/nsGlobalWindowOuter.cpp
dom/base/nsPIDOMWindow.h
dom/bindings/Bindings.conf
dom/ipc/ContentChild.cpp
dom/ipc/ContentParent.cpp
dom/moz.build
dom/time/DateCacheCleaner.cpp
dom/time/DateCacheCleaner.h
dom/time/TimeChangeObserver.cpp
dom/time/TimeChangeObserver.h
dom/time/TimeManager.cpp
dom/time/TimeManager.h
dom/time/TimeService.cpp
dom/time/TimeService.h
dom/time/moz.build
dom/time/nsITimeService.idl
dom/webidl/MozTimeManager.webidl
dom/webidl/Navigator.webidl
dom/webidl/moz.build
layout/build/nsLayoutModule.cpp
layout/build/nsLayoutStatics.cpp
old-configure.in
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -57,16 +57,17 @@
 #include "nsMimeTypes.h"
 #include "nsNetUtil.h"
 #include "nsRFPService.h"
 #include "nsStringStream.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIStringStream.h"
 #include "nsIHttpChannel.h"
 #include "nsIHttpChannelInternal.h"
+#include "TimeManager.h"
 #include "nsStreamUtils.h"
 #include "WidgetUtils.h"
 #include "nsIPresentationService.h"
 #include "nsIScriptError.h"
 
 #include "mozilla/dom/MediaDevices.h"
 #include "MediaManager.h"
 
@@ -192,16 +193,17 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPermissions)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGeolocation)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBatteryManager)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBatteryPromise)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mConnection)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStorageManager)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCredentials)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMediaDevices)
+  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTimeManager)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mServiceWorkerContainer)
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMediaKeySystemAccessManager)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPresentation)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGamepadServiceTest)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mVRGetDisplaysPromises)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mVRServiceTest)
@@ -241,16 +243,20 @@ Navigator::Invalidate()
 
   if (mConnection) {
     mConnection->Shutdown();
     mConnection = nullptr;
   }
 
   mMediaDevices = nullptr;
 
+  if (mTimeManager) {
+    mTimeManager = nullptr;
+  }
+
   if (mPresentation) {
     mPresentation = nullptr;
   }
 
   mServiceWorkerContainer = nullptr;
 
   if (mMediaKeySystemAccessManager) {
     mMediaKeySystemAccessManager->Shutdown();
@@ -1491,16 +1497,33 @@ Navigator::GetConnection(ErrorResult& aR
       return nullptr;
     }
     mConnection = network::Connection::CreateForWindow(mWindow);
   }
 
   return mConnection;
 }
 
+#ifdef MOZ_TIME_MANAGER
+time::TimeManager*
+Navigator::GetMozTime(ErrorResult& aRv)
+{
+  if (!mWindow) {
+    aRv.Throw(NS_ERROR_UNEXPECTED);
+    return nullptr;
+  }
+
+  if (!mTimeManager) {
+    mTimeManager = new time::TimeManager(mWindow);
+  }
+
+  return mTimeManager;
+}
+#endif
+
 already_AddRefed<ServiceWorkerContainer>
 Navigator::ServiceWorker()
 {
   MOZ_ASSERT(mWindow);
 
   if (!mServiceWorkerContainer) {
     mServiceWorkerContainer = new ServiceWorkerContainer(mWindow);
   }
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -70,18 +70,21 @@ class Connection;
 } // namespace network
 
 class Presentation;
 class LegacyMozTCPSocket;
 class VRDisplay;
 class VRServiceTest;
 class StorageManager;
 
-class Navigator final : public nsIDOMNavigator
-                      , public nsIMozNavigatorNetwork
+namespace time {
+class TimeManager;
+} // namespace time
+
+class Navigator final : public nsISupports
                       , public nsWrapperCache
 {
 public:
   explicit Navigator(nsPIDOMWindowInner* aInnerWindow);
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Navigator)
 
@@ -174,16 +177,19 @@ public:
   GamepadServiceTest* RequestGamepadServiceTest();
   already_AddRefed<Promise> GetVRDisplays(ErrorResult& aRv);
   void GetActiveVRDisplays(nsTArray<RefPtr<VRDisplay>>& aDisplays) const;
   VRServiceTest* RequestVRServiceTest();
   bool IsWebVRContentDetected() const;
   bool IsWebVRContentPresenting() const;
   void RequestVRPresentation(VRDisplay& aDisplay);
   nsINetworkProperties* GetNetworkProperties();
+#ifdef MOZ_TIME_MANAGER
+  time::TimeManager* GetMozTime(ErrorResult& aRv);
+#endif // MOZ_TIME_MANAGER
 
   Presentation* GetPresentation(ErrorResult& aRv);
 
   bool SendBeacon(const nsAString& aUrl,
                   const Nullable<fetch::BodyInit>& aData,
                   ErrorResult& aRv);
 
   void MozGetUserMedia(const MediaStreamConstraints& aConstraints,
@@ -260,16 +266,17 @@ private:
   RefPtr<nsPluginArray> mPlugins;
   RefPtr<Permissions> mPermissions;
   RefPtr<Geolocation> mGeolocation;
   RefPtr<battery::BatteryManager> mBatteryManager;
   RefPtr<Promise> mBatteryPromise;
   RefPtr<network::Connection> mConnection;
   RefPtr<CredentialsContainer> mCredentials;
   RefPtr<MediaDevices> mMediaDevices;
+  RefPtr<time::TimeManager> mTimeManager;
   RefPtr<ServiceWorkerContainer> mServiceWorkerContainer;
   nsCOMPtr<nsPIDOMWindowInner> mWindow;
   RefPtr<Presentation> mPresentation;
   RefPtr<GamepadServiceTest> mGamepadServiceTest;
   nsTArray<RefPtr<Promise> > mVRGetDisplaysPromises;
   RefPtr<VRServiceTest> mVRServiceTest;
   nsTArray<uint32_t> mRequestedVibrationPattern;
   RefPtr<StorageManager> mStorageManager;
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -421,16 +421,17 @@ EXTRA_JS_MODULES += [
     'IndexedDBHelper.jsm',
 ]
 
 LOCAL_INCLUDES += [
     '../battery',
     '../events',
     '../media',
     '../network',
+    '../time',
     '/caps',
     '/docshell/base',
     '/dom/base',
     '/dom/file',
     '/dom/geolocation',
     '/dom/html',
     '/dom/ipc',
     '/dom/storage',
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -223,16 +223,17 @@
 #include "mozilla/Services.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/dom/Location.h"
 #include "nsHTMLDocument.h"
 #include "nsWrapperCacheInlines.h"
 #include "mozilla/DOMEventTargetHelper.h"
 #include "prrng.h"
 #include "nsSandboxFlags.h"
+#include "TimeChangeObserver.h"
 #include "mozilla/dom/AudioContext.h"
 #include "mozilla/dom/BrowserElementDictionariesBinding.h"
 #include "mozilla/dom/cache/CacheStorage.h"
 #include "mozilla/dom/Console.h"
 #include "mozilla/dom/Fetch.h"
 #include "mozilla/dom/FunctionBinding.h"
 #include "mozilla/dom/HashChangeEvent.h"
 #include "mozilla/dom/IntlUtils.h"
@@ -6867,16 +6868,28 @@ nsGlobalWindowInner::IsVRContentPresenti
     if (display->IsAnyPresenting(gfx::kVRGroupAll)) {
       return true;
     }
   }
   return false;
 }
 
 void
+nsGlobalWindowInner::EnableTimeChangeNotifications()
+{
+  mozilla::time::AddWindowListener(this);
+}
+
+void
+nsGlobalWindowInner::DisableTimeChangeNotifications()
+{
+  mozilla::time::RemoveWindowListener(this);
+}
+
+void
 nsGlobalWindowInner::AddSizeOfIncludingThis(nsWindowSizes& aWindowSizes) const
 {
   aWindowSizes.mDOMOtherSize += aWindowSizes.mState.mMallocSizeOf(this);
 
   EventListenerManager* elm = GetExistingListenerManager();
   if (elm) {
     aWindowSizes.mDOMOtherSize +=
       elm->SizeOfIncludingThis(aWindowSizes.mState.mMallocSizeOf);
--- a/dom/base/nsGlobalWindowInner.h
+++ b/dom/base/nsGlobalWindowInner.h
@@ -484,16 +484,19 @@ public:
   virtual void EnableDeviceSensor(uint32_t aType) override;
   virtual void DisableDeviceSensor(uint32_t aType) override;
 
 #if defined(MOZ_WIDGET_ANDROID)
   virtual void EnableOrientationChangeListener() override;
   virtual void DisableOrientationChangeListener() override;
 #endif
 
+  virtual void EnableTimeChangeNotifications() override;
+  virtual void DisableTimeChangeNotifications() override;
+
   bool IsClosedOrClosing() {
     return mCleanedUp;
   }
 
   bool
   IsCleanedUp() const
   {
     return mCleanedUp;
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -221,16 +221,17 @@
 #include "mozilla/Services.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/dom/Location.h"
 #include "nsHTMLDocument.h"
 #include "nsWrapperCacheInlines.h"
 #include "mozilla/DOMEventTargetHelper.h"
 #include "prrng.h"
 #include "nsSandboxFlags.h"
+#include "TimeChangeObserver.h"
 #include "mozilla/dom/AudioContext.h"
 #include "mozilla/dom/BrowserElementDictionariesBinding.h"
 #include "mozilla/dom/cache/CacheStorage.h"
 #include "mozilla/dom/Console.h"
 #include "mozilla/dom/Fetch.h"
 #include "mozilla/dom/FunctionBinding.h"
 #include "mozilla/dom/HashChangeEvent.h"
 #include "mozilla/dom/IntlUtils.h"
--- a/dom/base/nsPIDOMWindow.h
+++ b/dom/base/nsPIDOMWindow.h
@@ -553,16 +553,19 @@ public:
    */
   virtual void DisableDeviceSensor(uint32_t aType) = 0;
 
 #if defined(MOZ_WIDGET_ANDROID)
   virtual void EnableOrientationChangeListener() = 0;
   virtual void DisableOrientationChangeListener() = 0;
 #endif
 
+  virtual void EnableTimeChangeNotifications() = 0;
+  virtual void DisableTimeChangeNotifications() = 0;
+
   /**
    * Tell this window that there is an observer for gamepad input
    *
    * Inner windows only.
    */
   virtual void SetHasGamepadEventListener(bool aHasGamepad = true) = 0;
 
   /**
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -596,16 +596,20 @@ DOMInterfaces = {
     'nativeType': 'mozilla::dom::HTMLCanvasPrintState',
 },
 
 'MozChannel': {
     'nativeType': 'nsIChannel',
     'notflattened': True
 },
 
+'MozTimeManager': {
+    'nativeType': 'mozilla::dom::time::TimeManager',
+},
+
 'MozStorageAsyncStatementParams': {
     'headerFile': 'mozilla/storage/mozStorageAsyncStatementParams.h',
     'nativeType': 'mozilla::storage::AsyncStatementParams',
 },
 
 'MozStorageStatementParams': {
     'headerFile': 'mozilla/storage/mozStorageStatementParams.h',
     'nativeType': 'mozilla::storage::StatementParams',
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -206,16 +206,17 @@
 
 #include "ClearOnShutdown.h"
 #include "ProcessUtils.h"
 #include "URIUtils.h"
 #include "nsContentUtils.h"
 #include "nsIPrincipal.h"
 #include "DomainPolicy.h"
 #include "mozilla/dom/ipc/StructuredCloneData.h"
+#include "mozilla/dom/time/DateCacheCleaner.h"
 #include "mozilla/ipc/CrashReporterClient.h"
 #include "mozilla/net/NeckoMessageUtils.h"
 #include "mozilla/widget/PuppetBidiKeyboard.h"
 #include "mozilla/RemoteSpellCheckEngineChild.h"
 #include "GMPServiceChild.h"
 #include "GfxInfoBase.h"
 #include "gfxPlatform.h"
 #include "nscore.h" // for NS_FREE_PERMANENT_DATA
@@ -1216,16 +1217,19 @@ ContentChild::InitXPCOM(const XPCOMInitD
     ProcessGlobal* global = ProcessGlobal::Get();
     global->SetInitialProcessData(data);
   }
 
   // The stylesheet cache is not ready yet. Store this URL for future use.
   nsCOMPtr<nsIURI> ucsURL = DeserializeURI(aXPCOMInit.userContentSheetURL());
   nsLayoutStylesheetCache::SetUserContentCSSURL(ucsURL);
 
+  // This will register cross-process observer.
+  mozilla::dom::time::InitializeDateCacheCleaner();
+
   GfxInfoBase::SetFeatureStatus(aXPCOMInit.gfxFeatureStatus());
 
   DataStorage::SetCachedStorageEntries(aXPCOMInit.dataStorage());
 
   // Set the dynamic scalar definitions for this process.
   TelemetryIPC::AddDynamicScalarDefinitions(aXPCOMInit.dynamicScalarDefs());
 
   DOMPrefs::Initialize();
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -52,16 +52,17 @@
 #include "mozilla/dom/PCycleCollectWithLogsParent.h"
 #include "mozilla/dom/ServiceWorkerRegistrar.h"
 #include "mozilla/dom/power/PowerManagerService.h"
 #include "mozilla/dom/Permissions.h"
 #include "mozilla/dom/PresentationParent.h"
 #include "mozilla/dom/PPresentationParent.h"
 #include "mozilla/dom/PushNotifier.h"
 #include "mozilla/dom/quota/QuotaManagerService.h"
+#include "mozilla/dom/time/DateCacheCleaner.h"
 #include "mozilla/dom/URLClassifierParent.h"
 #include "mozilla/embedding/printingui/PrintingParent.h"
 #include "mozilla/extensions/StreamFilterParent.h"
 #include "mozilla/gfx/gfxVars.h"
 #include "mozilla/gfx/GPUProcessManager.h"
 #include "mozilla/hal_sandbox/PHalParent.h"
 #include "mozilla/ipc/BackgroundChild.h"
 #include "mozilla/ipc/BackgroundParent.h"
@@ -622,16 +623,18 @@ ContentParent::StartUp()
 
   if (!XRE_IsParentProcess()) {
     return;
   }
 
   // Note: This reporter measures all ContentParents.
   RegisterStrongMemoryReporter(new ContentParentsMemoryReporter());
 
+  mozilla::dom::time::InitializeDateCacheCleaner();
+
   BackgroundChild::Startup();
   ClientManager::Startup();
 
   sDisableUnsafeCPOWWarnings = PR_GetEnv("DISABLE_UNSAFE_CPOW_WARNINGS");
 
 #if defined(XP_LINUX) && defined(MOZ_CONTENT_SANDBOX)
   sSandboxBrokerPolicyFactory = MakeUnique<SandboxBrokerPolicyFactory>();
 #endif
--- a/dom/moz.build
+++ b/dom/moz.build
@@ -69,16 +69,17 @@ DIRS += [
     'notification',
     'offline',
     'power',
     'push',
     'quota',
     'security',
     'storage',
     'svg',
+    'time',
     'locales',
     'network',
     'permission',
     'plugins/base',
     'plugins/ipc',
     'indexedDB',
     'system',
     'ipc',
new file mode 100644
--- /dev/null
+++ b/dom/time/DateCacheCleaner.cpp
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "DateCacheCleaner.h"
+
+#include "js/Date.h"
+#include "mozilla/dom/ScriptSettings.h"
+#include "mozilla/ClearOnShutdown.h"
+#include "mozilla/Hal.h"
+#include "mozilla/StaticPtr.h"
+
+using namespace mozilla::hal;
+
+namespace mozilla {
+namespace dom {
+namespace time {
+
+class DateCacheCleaner : public SystemTimezoneChangeObserver
+{
+public:
+  DateCacheCleaner()
+  {
+    RegisterSystemTimezoneChangeObserver(this);
+  }
+
+  ~DateCacheCleaner()
+  {
+    UnregisterSystemTimezoneChangeObserver(this);
+  }
+
+  void Notify(const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo) override
+  {
+    JS::ResetTimeZone();
+  }
+
+};
+
+StaticAutoPtr<DateCacheCleaner> sDateCacheCleaner;
+
+void
+InitializeDateCacheCleaner()
+{
+  if (!sDateCacheCleaner) {
+    sDateCacheCleaner = new DateCacheCleaner();
+    ClearOnShutdown(&sDateCacheCleaner);
+  }
+}
+
+} // namespace time
+} // namespace dom
+} // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/dom/time/DateCacheCleaner.h
@@ -0,0 +1,19 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * InitializeDateCacheCleaner registers DateCacheCleaner to
+ * SystemTimeChangeObserver. When time zone is changed, DateCacheCleaner calls
+ * JS::ResetTimeZone to update the time zone information.
+ */
+
+namespace mozilla {
+namespace dom {
+namespace time {
+void InitializeDateCacheCleaner();
+} //namespace time
+} //namespace dom
+} //namespace mozilla
new file mode 100644
--- /dev/null
+++ b/dom/time/TimeChangeObserver.cpp
@@ -0,0 +1,166 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "TimeChangeObserver.h"
+#include "mozilla/Hal.h"
+#include "mozilla/Observer.h"
+#include "mozilla/HalTypes.h"
+#include "nsWeakPtr.h"
+#include "nsTObserverArray.h"
+#include "mozilla/ClearOnShutdown.h"
+#include "mozilla/Services.h"
+#include "mozilla/StaticPtr.h"
+#include "nsPIDOMWindow.h"
+#include "nsContentUtils.h"
+#include "nsIObserverService.h"
+#include "nsIDocument.h"
+
+using namespace mozilla;
+using namespace mozilla::hal;
+using namespace mozilla::services;
+
+class nsSystemTimeChangeObserver : public SystemClockChangeObserver,
+                                   public SystemTimezoneChangeObserver
+{
+  typedef nsTObserverArray<nsWeakPtr> ListenerArray;
+public:
+  static nsSystemTimeChangeObserver* GetInstance();
+  virtual ~nsSystemTimeChangeObserver();
+
+  // Implementing hal::SystemClockChangeObserver::Notify()
+  void Notify(const int64_t& aClockDeltaMS) override;
+
+  // Implementing hal::SystemTimezoneChangeObserver::Notify()
+  void Notify(
+    const mozilla::hal::SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo) override;
+
+  nsresult AddWindowListenerImpl(nsPIDOMWindowInner* aWindow);
+  nsresult RemoveWindowListenerImpl(nsPIDOMWindowInner* aWindow);
+
+private:
+  nsSystemTimeChangeObserver() { };
+  ListenerArray mWindowListeners;
+  void FireMozTimeChangeEvent();
+};
+
+StaticAutoPtr<nsSystemTimeChangeObserver> sObserver;
+
+nsSystemTimeChangeObserver* nsSystemTimeChangeObserver::GetInstance()
+{
+  if (!sObserver) {
+    sObserver = new nsSystemTimeChangeObserver();
+    ClearOnShutdown(&sObserver);
+  }
+  return sObserver;
+}
+
+nsSystemTimeChangeObserver::~nsSystemTimeChangeObserver()
+{
+  UnregisterSystemClockChangeObserver(this);
+  UnregisterSystemTimezoneChangeObserver(this);
+}
+
+void
+nsSystemTimeChangeObserver::FireMozTimeChangeEvent()
+{
+  ListenerArray::ForwardIterator iter(mWindowListeners);
+  while (iter.HasMore()) {
+    nsWeakPtr weakWindow = iter.GetNext();
+    nsCOMPtr<nsPIDOMWindowInner> innerWindow = do_QueryReferent(weakWindow);
+    nsCOMPtr<nsPIDOMWindowOuter> outerWindow;
+    nsCOMPtr<nsIDocument> document;
+    if (!innerWindow ||
+        !(document = innerWindow->GetExtantDoc()) ||
+        !(outerWindow = innerWindow->GetOuterWindow())) {
+      mWindowListeners.RemoveElement(weakWindow);
+      continue;
+    }
+
+    nsContentUtils::DispatchTrustedEvent(document, outerWindow,
+      NS_LITERAL_STRING("moztimechange"), /* bubbles = */ true,
+      /* canceable = */ false);
+  }
+}
+
+void
+nsSystemTimeChangeObserver::Notify(const int64_t& aClockDeltaMS)
+{
+  // Notify observers that the system clock has been adjusted.
+  nsCOMPtr<nsIObserverService> observerService = GetObserverService();
+  if (observerService) {
+    nsString dataStr;
+    dataStr.AppendFloat(static_cast<double>(aClockDeltaMS));
+    observerService->NotifyObservers(
+      nullptr, "system-clock-change", dataStr.get());
+  }
+
+  FireMozTimeChangeEvent();
+}
+
+void
+nsSystemTimeChangeObserver::Notify(
+  const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo)
+{
+  FireMozTimeChangeEvent();
+}
+
+nsresult
+mozilla::time::AddWindowListener(nsPIDOMWindowInner* aWindow)
+{
+  return nsSystemTimeChangeObserver::GetInstance()->AddWindowListenerImpl(aWindow);
+}
+
+nsresult
+nsSystemTimeChangeObserver::AddWindowListenerImpl(nsPIDOMWindowInner* aWindow)
+{
+  if (!aWindow) {
+    return NS_ERROR_ILLEGAL_VALUE;
+  }
+
+  nsWeakPtr windowWeakRef = do_GetWeakReference(aWindow);
+  NS_ASSERTION(windowWeakRef, "nsIDOMWindow implementations shuld support weak ref");
+
+  if (mWindowListeners.IndexOf(windowWeakRef) !=
+      ListenerArray::array_type::NoIndex) {
+    return NS_OK;
+  }
+
+  if (mWindowListeners.IsEmpty()) {
+    RegisterSystemClockChangeObserver(sObserver);
+    RegisterSystemTimezoneChangeObserver(sObserver);
+  }
+
+  mWindowListeners.AppendElement(windowWeakRef);
+  return NS_OK;
+}
+
+nsresult
+mozilla::time::RemoveWindowListener(nsPIDOMWindowInner* aWindow)
+{
+  if (!sObserver) {
+    return NS_OK;
+  }
+
+  return nsSystemTimeChangeObserver::GetInstance()->RemoveWindowListenerImpl(aWindow);
+}
+
+nsresult
+nsSystemTimeChangeObserver::RemoveWindowListenerImpl(nsPIDOMWindowInner* aWindow)
+{
+  if (!aWindow) {
+    return NS_OK;
+  }
+
+  nsWeakPtr windowWeakRef = do_GetWeakReference(aWindow);
+  mWindowListeners.RemoveElement(windowWeakRef);
+
+  if (mWindowListeners.IsEmpty()) {
+    UnregisterSystemClockChangeObserver(sObserver);
+    UnregisterSystemTimezoneChangeObserver(sObserver);
+  }
+
+  return NS_OK;
+}
new file mode 100644
--- /dev/null
+++ b/dom/time/TimeChangeObserver.h
@@ -0,0 +1,23 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef _mozilla_time_change_observer_h_
+#define _mozilla_time_change_observer_h_
+
+#include "nscore.h"
+
+class nsPIDOMWindowInner;
+
+namespace mozilla {
+namespace time {
+
+nsresult AddWindowListener(nsPIDOMWindowInner* aWindow);
+nsresult RemoveWindowListener(nsPIDOMWindowInner* aWindow);
+
+} // namespace time
+} // namespace mozilla
+
+#endif //_mozilla_time_change_observer_h_
new file mode 100644
--- /dev/null
+++ b/dom/time/TimeManager.cpp
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "TimeManager.h"
+
+#include "mozilla/dom/Date.h"
+#include "mozilla/dom/MozTimeManagerBinding.h"
+#include "nsITimeService.h"
+#include "nsServiceManagerUtils.h"
+
+namespace mozilla {
+namespace dom {
+namespace time {
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TimeManager)
+  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
+  NS_INTERFACE_MAP_ENTRY(nsISupports)
+NS_INTERFACE_MAP_END
+
+NS_IMPL_CYCLE_COLLECTING_ADDREF(TimeManager)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(TimeManager)
+
+NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(TimeManager, mWindow)
+
+JSObject*
+TimeManager::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
+{
+  return MozTimeManagerBinding::Wrap(aCx, this, aGivenProto);
+}
+
+void
+TimeManager::Set(Date& aDate)
+{
+  Set(aDate.ToDouble());
+}
+
+void
+TimeManager::Set(double aTime)
+{
+  nsCOMPtr<nsITimeService> timeService = do_GetService(TIMESERVICE_CONTRACTID);
+  if (timeService) {
+    timeService->Set(aTime);
+  }
+}
+
+} // namespace time
+} // namespace dom
+} // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/dom/time/TimeManager.h
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_dom_time_TimeManager_h
+#define mozilla_dom_time_TimeManager_h
+
+#include "mozilla/Attributes.h"
+#include "nsISupports.h"
+#include "nsPIDOMWindow.h"
+#include "nsWrapperCache.h"
+
+namespace mozilla {
+namespace dom {
+
+class Date;
+
+namespace time {
+
+class TimeManager final : public nsISupports
+                        , public nsWrapperCache
+{
+public:
+  static bool PrefEnabled(JSContext* aCx, JSObject* aGlobal)
+  {
+#ifdef MOZ_TIME_MANAGER
+    return true;
+#else
+    return false;
+#endif
+  }
+
+  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TimeManager)
+
+  explicit TimeManager(nsPIDOMWindowInner* aWindow)
+    : mWindow(aWindow)
+  {
+  }
+
+  nsPIDOMWindowInner* GetParentObject() const
+  {
+    return mWindow;
+  }
+  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
+
+  void Set(Date& aDate);
+  void Set(double aTime);
+
+private:
+  ~TimeManager() {}
+
+  nsCOMPtr<nsPIDOMWindowInner> mWindow;
+};
+
+} // namespace time
+} // namespace dom
+} // namespace mozilla
+
+#endif //mozilla_dom_time_TimeManager_h
new file mode 100644
--- /dev/null
+++ b/dom/time/TimeService.cpp
@@ -0,0 +1,40 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "base/basictypes.h"
+#include "jsapi.h"
+#include "mozilla/ClearOnShutdown.h"
+#include "mozilla/Hal.h"
+#include "TimeService.h"
+
+namespace mozilla {
+namespace dom {
+namespace time {
+
+NS_IMPL_ISUPPORTS(TimeService, nsITimeService)
+
+/* static */ StaticRefPtr<TimeService> TimeService::sSingleton;
+
+/* static */ already_AddRefed<TimeService>
+TimeService::GetInstance()
+{
+  if (!sSingleton) {
+    sSingleton = new TimeService();
+    ClearOnShutdown(&sSingleton);
+  }
+  RefPtr<TimeService> service = sSingleton.get();
+  return service.forget();
+}
+
+NS_IMETHODIMP
+TimeService::Set(int64_t aTimeInMS) {
+  hal::AdjustSystemClock(aTimeInMS - (JS_Now() / PR_USEC_PER_MSEC));
+  return NS_OK;
+}
+
+} // namespace time
+} // namespace dom
+} // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/dom/time/TimeService.h
@@ -0,0 +1,38 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_dom_time_TimeService_h
+#define mozilla_dom_time_TimeService_h
+
+#include "mozilla/StaticPtr.h"
+#include "nsITimeService.h"
+
+namespace mozilla {
+namespace dom {
+namespace time {
+
+/**
+ * This class implements a service which lets us modify the system clock time.
+ */
+class TimeService : public nsITimeService
+{
+public:
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSITIMESERVICE
+
+  static already_AddRefed<TimeService> GetInstance();
+
+private:
+  virtual ~TimeService() {};
+
+  static StaticRefPtr<TimeService> sSingleton;
+};
+
+} // namespace time
+} // namespace dom
+} // namespace mozilla
+
+#endif //mozilla_dom_time_TimeService_h
new file mode 100644
--- /dev/null
+++ b/dom/time/moz.build
@@ -0,0 +1,32 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+with Files("**"):
+    BUG_COMPONENT = ("Core", "DOM: Device Interfaces")
+
+XPIDL_SOURCES += [
+    'nsITimeService.idl',
+]
+
+XPIDL_MODULE = 'dom_time'
+
+EXPORTS.mozilla.dom.time += [
+    'DateCacheCleaner.h',
+    'TimeChangeObserver.h',
+    'TimeManager.h',
+    'TimeService.h',
+]
+
+UNIFIED_SOURCES += [
+    'DateCacheCleaner.cpp',
+    'TimeChangeObserver.cpp',
+    'TimeManager.cpp',
+    'TimeService.cpp',
+]
+
+include('/ipc/chromium/chromium-config.mozbuild')
+
+FINAL_LIBRARY = 'xul'
new file mode 100644
--- /dev/null
+++ b/dom/time/nsITimeService.idl
@@ -0,0 +1,20 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "nsISupports.idl"
+
+%{C++
+#define NS_TIMESERVICE_CID { 0x80d6f9cc, 0xf16d, 0x40c3, { 0xa5, 0x2e, 0xc4, 0xe6, 0x56, 0xe3, 0x65, 0xb4 } }
+#define TIMESERVICE_CONTRACTID "@mozilla.org/time/timeservice;1"
+%}
+
+[scriptable, builtinclass, uuid(1fc7fde2-0090-11e2-bdd6-0fea4b9f41f8)]
+interface nsITimeService : nsISupports
+{
+  /* Set the system time.
+   *
+   * The |aTimeInMS| argument is the time in milliseconds since the epoch.
+   */
+  void set(in int64_t aTimeInMS);
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/MozTimeManager.webidl
@@ -0,0 +1,18 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+[Func="mozilla::dom::time::TimeManager::PrefEnabled"]
+interface MozTimeManager {
+  /* Set the system time.
+   *
+   * The |time| argument can be either a Date object or a number.
+   *
+   * - If |time| is a number, it's interpreted as milliseconds
+   *   since the epoch (midnight UTC on January 1, 1970).
+   * - If |time| is a Date object, |set(time)| is equivalent to
+   *   |set(time.getTime())|.
+   */
+  void set(Date time);
+  void set(double time);
+};
--- a/dom/webidl/Navigator.webidl
+++ b/dom/webidl/Navigator.webidl
@@ -229,16 +229,24 @@ partial interface Navigator {
   [ChromeOnly, Pref="dom.vr.enabled"]
   void requestVRPresentation(VRDisplay display);
 };
 partial interface Navigator {
   [Pref="dom.vr.test.enabled"]
   VRServiceTest requestVRServiceTest();
 };
 
+#ifdef MOZ_TIME_MANAGER
+// nsIDOMMozNavigatorTime
+partial interface Navigator {
+  [Throws, ChromeOnly]
+  readonly attribute MozTimeManager mozTime;
+};
+#endif // MOZ_TIME_MANAGER
+
 callback NavigatorUserMediaSuccessCallback = void (MediaStream stream);
 callback NavigatorUserMediaErrorCallback = void (MediaStreamError error);
 
 partial interface Navigator {
   [Throws, Func="Navigator::HasUserMediaSupport"]
   readonly attribute MediaDevices mediaDevices;
 
   // Deprecated. Use mediaDevices.getUserMedia instead.
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -206,16 +206,19 @@ with Files("*Record*"):
     BUG_COMPONENT = ("Core", "Audio/Video: Recording")
 
 with Files("Media*Track*"):
     BUG_COMPONENT = ("Core", "WebRTC: Audio/Video")
 
 with Files("Mouse*"):
     BUG_COMPONENT = ("Core", "DOM: Events")
 
+with Files("MozTimeManager.webidl"):
+    BUG_COMPONENT = ("Core", "DOM: Device Interfaces")
+
 with Files("MutationEvent.webidl"):
     BUG_COMPONENT = ("Core", "DOM: Events")
 
 with Files("NativeOSFileInternals.webidl"):
     BUG_COMPONENT = ("Toolkit", "OS.File")
 
 with Files("Net*"):
     BUG_COMPONENT = ("Core", "Networking")
@@ -356,16 +359,17 @@ with Files("Worker*"):
     BUG_COMPONENT = ("Core", "DOM: Workers")
 
 GENERATED_WEBIDL_FILES = [
     'CSS2Properties.webidl',
 ]
 
 PREPROCESSED_WEBIDL_FILES = [
     'ChromeUtils.webidl',
+    'Navigator.webidl',
     'Node.webidl',
     'Window.webidl',
 ]
 
 WEBIDL_FILES = [
     'AbortController.webidl',
     'AbortSignal.webidl',
     'AbstractWorker.webidl',
@@ -681,21 +685,21 @@ WEBIDL_FILES = [
     'MessagePort.webidl',
     'MimeType.webidl',
     'MimeTypeArray.webidl',
     'MouseEvent.webidl',
     'MouseScrollEvent.webidl',
     'MozStorageAsyncStatementParams.webidl',
     'MozStorageStatementParams.webidl',
     'MozStorageStatementRow.webidl',
+    'MozTimeManager.webidl',
     'MutationEvent.webidl',
     'MutationObserver.webidl',
     'NamedNodeMap.webidl',
     'NativeOSFileInternals.webidl',
-    'Navigator.webidl',
     'NetDashboard.webidl',
     'NetworkInformation.webidl',
     'NetworkOptions.webidl',
     'NodeFilter.webidl',
     'NodeIterator.webidl',
     'NodeList.webidl',
     'Notification.webidl',
     'NotificationEvent.webidl',
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -158,16 +158,17 @@ static void Shutdown();
 #include "nsIPowerManagerService.h"
 #include "nsIMediaManager.h"
 #include "mozilla/dom/nsMixedContentBlocker.h"
 
 #include "AudioChannelService.h"
 #include "mozilla/net/WebSocketEventService.h"
 
 #include "mozilla/dom/power/PowerManagerService.h"
+#include "mozilla/dom/time/TimeService.h"
 
 #include "nsIPresentationService.h"
 
 #include "MediaManager.h"
 
 #include "GMPService.h"
 
 #include "mozilla/dom/PresentationDeviceManager.h"
@@ -179,16 +180,17 @@ static void Shutdown();
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using mozilla::dom::power::PowerManagerService;
 using mozilla::dom::quota::QuotaManagerService;
 using mozilla::dom::workers::ServiceWorkerManager;
 using mozilla::dom::workers::WorkerDebuggerManager;
 using mozilla::dom::UDPSocketChild;
+using mozilla::dom::time::TimeService;
 using mozilla::gmp::GeckoMediaPluginService;
 using mozilla::dom::NotificationTelemetryService;
 
 #define NS_EDITORCOMMANDTABLE_CID \
 { 0x4f5e62b8, 0xd659, 0x4156, \
   { 0x84, 0xfc, 0x2f, 0x60, 0x99, 0x40, 0x03, 0x69 } }
 
 #define NS_EDITINGCOMMANDTABLE_CID \
@@ -254,16 +256,18 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(AudioChan
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceSensors)
 
 #if defined(ANDROID)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsHapticFeedback)
 #endif
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(ThirdPartyUtil, Init)
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIPowerManagerService,
                                          PowerManagerService::GetInstance)
+NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsITimeService,
+                                         TimeService::GetInstance)
 
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIMediaManagerService,
                                          MediaManager::GetInstance)
 NS_GENERIC_FACTORY_CONSTRUCTOR(PresentationDeviceManager)
 NS_GENERIC_FACTORY_CONSTRUCTOR(TextInputProcessor)
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIPresentationService,
                                          NS_CreatePresentationService)
 NS_GENERIC_FACTORY_CONSTRUCTOR(PresentationTCPSessionTransport)
@@ -640,16 +644,17 @@ NS_DEFINE_NAMED_CID(THIRDPARTYUTIL_CID);
 NS_DEFINE_NAMED_CID(NS_STRUCTUREDCLONECONTAINER_CID);
 NS_DEFINE_NAMED_CID(NS_DEVICE_SENSORS_CID);
 #if defined(ANDROID)
 NS_DEFINE_NAMED_CID(NS_HAPTICFEEDBACK_CID);
 #endif
 NS_DEFINE_NAMED_CID(NS_POWERMANAGERSERVICE_CID);
 NS_DEFINE_NAMED_CID(OSFILECONSTANTSSERVICE_CID);
 NS_DEFINE_NAMED_CID(UDPSOCKETCHILD_CID);
+NS_DEFINE_NAMED_CID(NS_TIMESERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_MEDIAMANAGERSERVICE_CID);
 #ifdef MOZ_WEBSPEECH_TEST_BACKEND
 NS_DEFINE_NAMED_CID(NS_FAKE_SPEECH_RECOGNITION_SERVICE_CID);
 #endif
 #ifdef MOZ_WEBSPEECH
 NS_DEFINE_NAMED_CID(NS_SYNTHVOICEREGISTRY_CID);
 #endif
 
@@ -900,16 +905,17 @@ static const mozilla::Module::CIDEntry k
   { &kNS_HAPTICFEEDBACK_CID, false, nullptr, nsHapticFeedbackConstructor },
 #endif
   { &kTHIRDPARTYUTIL_CID, false, nullptr, ThirdPartyUtilConstructor },
   { &kNS_STRUCTUREDCLONECONTAINER_CID, false, nullptr, nsStructuredCloneContainerConstructor },
   { &kNS_POWERMANAGERSERVICE_CID, false, nullptr, nsIPowerManagerServiceConstructor, Module::ALLOW_IN_GPU_PROCESS },
   { &kOSFILECONSTANTSSERVICE_CID, true, nullptr, OSFileConstantsServiceConstructor },
   { &kUDPSOCKETCHILD_CID, false, nullptr, UDPSocketChildConstructor },
   { &kGECKO_MEDIA_PLUGIN_SERVICE_CID, true, nullptr, GeckoMediaPluginServiceConstructor },
+  { &kNS_TIMESERVICE_CID, false, nullptr, nsITimeServiceConstructor },
   { &kNS_MEDIAMANAGERSERVICE_CID, false, nullptr, nsIMediaManagerServiceConstructor },
 #ifdef ACCESSIBILITY
   { &kNS_ACCESSIBILITY_SERVICE_CID, false, nullptr, CreateA11yService },
 #endif
   { &kPRESENTATION_SERVICE_CID, false, nullptr, nsIPresentationServiceConstructor },
   { &kPRESENTATION_DEVICE_MANAGER_CID, false, nullptr, PresentationDeviceManagerConstructor },
   { &kPRESENTATION_TCP_SESSION_TRANSPORT_CID, false, nullptr, PresentationTCPSessionTransportConstructor },
   { &kTEXT_INPUT_PROCESSOR_CID, false, nullptr, TextInputProcessorConstructor },
@@ -1018,16 +1024,17 @@ static const mozilla::Module::ContractID
 #if defined(ANDROID)
   { "@mozilla.org/widget/hapticfeedback;1", &kNS_HAPTICFEEDBACK_CID },
 #endif
   { THIRDPARTYUTIL_CONTRACTID, &kTHIRDPARTYUTIL_CID },
   { NS_STRUCTUREDCLONECONTAINER_CONTRACTID, &kNS_STRUCTUREDCLONECONTAINER_CID },
   { POWERMANAGERSERVICE_CONTRACTID, &kNS_POWERMANAGERSERVICE_CID, Module::ALLOW_IN_GPU_PROCESS },
   { OSFILECONSTANTSSERVICE_CONTRACTID, &kOSFILECONSTANTSSERVICE_CID },
   { "@mozilla.org/udp-socket-child;1", &kUDPSOCKETCHILD_CID },
+  { TIMESERVICE_CONTRACTID, &kNS_TIMESERVICE_CID },
   { MEDIAMANAGERSERVICE_CONTRACTID, &kNS_MEDIAMANAGERSERVICE_CID },
 #ifdef ACCESSIBILITY
   { "@mozilla.org/accessibilityService;1", &kNS_ACCESSIBILITY_SERVICE_CID },
   { "@mozilla.org/accessibleRetrieval;1", &kNS_ACCESSIBILITY_SERVICE_CID },
 #endif
   { "@mozilla.org/gecko-media-plugin-service;1",  &kGECKO_MEDIA_PLUGIN_SERVICE_CID },
   { PRESENTATION_SERVICE_CONTRACTID, &kPRESENTATION_SERVICE_CID },
   { PRESENTATION_DEVICE_MANAGER_CONTRACTID, &kPRESENTATION_DEVICE_MANAGER_CID },
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -101,16 +101,17 @@
 #include "nsHyphenationManager.h"
 #include "nsWindowMemoryReporter.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/ProcessPriorityManager.h"
 #include "nsPermissionManager.h"
 #include "nsCookieService.h"
 #include "nsApplicationCacheService.h"
 #include "mozilla/dom/CustomElementRegistry.h"
+#include "mozilla/dom/time/DateCacheCleaner.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/IMEStateManager.h"
 #include "mozilla/dom/HTMLVideoElement.h"
 #include "TouchManager.h"
 #include "DecoderDoctorLogger.h"
 #include "MediaDecoder.h"
 #include "MediaPrefs.h"
 #include "mozilla/ServoBindings.h"
--- a/old-configure.in
+++ b/old-configure.in
@@ -1986,16 +1986,17 @@ MOZ_TOOLKIT_SEARCH=1
 MOZ_UNIVERSALCHARDET=1
 MOZ_XUL=1
 MOZ_ZIPWRITER=1
 MOZ_NO_SMART_CARDS=
 NECKO_COOKIES=1
 MOZ_USE_NATIVE_POPUP_WINDOWS=
 MOZ_EXCLUDE_HYPHENATION_DICTIONARIES=
 ACCESSIBILITY=1
+MOZ_TIME_MANAGER=
 MOZ_CONTENT_SANDBOX=
 MOZ_GMP_SANDBOX=
 MOZ_SANDBOX=1
 MOZ_BINARY_EXTENSIONS=
 MOZ_DEVTOOLS=server
 
 case "$target_os" in
     mingw*)
@@ -3801,16 +3802,24 @@ MOZ_ARG_DISABLE_BOOL(startupcache,
     MOZ_DISABLE_STARTUPCACHE=)
 
 if test -n "$MOZ_DISABLE_STARTUPCACHE"; then
   AC_DEFINE(MOZ_DISABLE_STARTUPCACHE)
 fi
 AC_SUBST(MOZ_DISABLE_STARTUPCACHE)
 
 dnl ========================================================
+dnl = Enable Support for Time Manager API
+dnl ========================================================
+if test -n "$MOZ_TIME_MANAGER"; then
+    AC_DEFINE(MOZ_TIME_MANAGER)
+fi
+AC_SUBST(MOZ_TIME_MANAGER)
+
+dnl ========================================================
 dnl = Enable Support for Secure Element API
 dnl ========================================================
    MOZ_SECUREELEMENT=1,
 if test -n "$MOZ_SECUREELEMENT"; then
    AC_DEFINE(MOZ_SECUREELEMENT)
 fi
  AC_SUBST(MOZ_SECUREELEMENT)