Bug 866545. Remove the obsolete dom.enable_performance preference, so we can rely on things like performance.now() existing. r=smaug
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 01 May 2013 23:44:11 -0400
changeset 130585 a6c9a09469c606aecbf9a07b6befa7cf27dc740c
parent 130584 3f705f8db7c14bafe5b529f6353da7d43216ee5f
child 130586 60e671f364b941c704282cf191892dc65758bbe0
push id1579
push userphilringnalda@gmail.com
push dateSat, 04 May 2013 04:38:04 +0000
treeherderfx-team@a56432a42a41 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs866545
milestone23.0a1
Bug 866545. Remove the obsolete dom.enable_performance preference, so we can rely on things like performance.now() existing. r=smaug
docshell/base/nsDocShell.cpp
docshell/test/test_bug570341.html
dom/base/nsDOMClassInfo.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsPIDOMWindow.h
layout/base/nsRefreshDriver.cpp
modules/libpref/src/init/all.js
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -1645,20 +1645,18 @@ nsDocShell::FirePageHideNotification(boo
 
 nsresult
 nsDocShell::MaybeInitTiming()
 {
     if (mTiming) {
         return NS_OK;
     }
 
-    if (Preferences::GetBool("dom.enable_performance", false)) {
-        mTiming = new nsDOMNavigationTiming();
-        mTiming->NotifyNavigationStart();
-    }
+    mTiming = new nsDOMNavigationTiming();
+    mTiming->NotifyNavigationStart();
     return NS_OK;
 }
 
 
 //
 // Bug 13871: Prevent frameset spoofing
 //
 // This routine answers: 'Is origin's document from same domain as
@@ -9515,21 +9513,19 @@ nsDocShell::DoURILoad(nsIURI * aURI,
         nsCOMPtr<nsIWritablePropertyBag2> props = do_QueryInterface(channel);
         if (props) {
             props->SetPropertyAsBool(
                 NS_LITERAL_STRING("docshell.newWindowTarget"),
                 true);
         }
     }
 
-    if (Preferences::GetBool("dom.enable_performance", false)) {
-        nsCOMPtr<nsITimedChannel> timedChannel(do_QueryInterface(channel));
-        if (timedChannel) {
-            timedChannel->SetTimingEnabled(true);
-        }
+    nsCOMPtr<nsITimedChannel> timedChannel(do_QueryInterface(channel));
+    if (timedChannel) {
+        timedChannel->SetTimingEnabled(true);
     }
 
     rv = DoChannelLoad(channel, uriLoader, aBypassClassifier);
 
     //
     // If the channel load failed, we failed and nsIWebProgress just ain't
     // gonna happen.
     //
--- a/docshell/test/test_bug570341.html
+++ b/docshell/test/test_bug570341.html
@@ -88,33 +88,21 @@ https://bugzilla.mozilla.org/show_bug.cg
           var prevProp = seq[j-1];
           ok(moments[prevProp] <= moments[prop],
               ['Expected ', prevProp, ' to happen before ', prop,
               ', got ', prevProp, ' = ', moments[prevProp],
               ', ', prop, ' = ', moments[prop]].join(''));
         }
       }
     }
-    try {
-      SpecialPowers.setBoolPref('dom.enable_performance', wasEnabled);
-    } catch (err) {
-      todo(false, 'Exception in SpecialPowers: ' + err + ' at ' + err.stack);
-    }
 
     SimpleTest.finish()
   }
 
 window.onload = function() {
-  try {
-    wasEnabled = SpecialPowers.getBoolPref('dom.enable_performance');
-  } catch (err) {
-    todo(false, 'Exception in SpecialPowers: ' + err + ' at ' + err.stack);
-  }
-  SpecialPowers.setBoolPref('dom.enable_performance', true);
-
   var win = frames[0];
   win.addEventListener('unload', function(){
     unload = Date.now();
   }, true);
   var seenLoad = 0;
   win.addEventListener('load', function (){
     seenLoad = Date.now();
   }, true);
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -1556,32 +1556,30 @@ nsDOMClassInfo::RegisterExternalClasses(
 
 #ifdef MOZ_B2G
 #define DOM_CLASSINFO_WINDOW_MAP_ENTRIES(_support_indexed_db)                  \
   DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)                                        \
   DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowB2G)                                     \
   DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)                                      \
   DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)                                   \
   DOM_CLASSINFO_MAP_ENTRY(nsIInlineEventHandlers)                              \
+  DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowPerformance)                             \
   DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMStorageIndexedDB,                  \
                                       _support_indexed_db)                     \
-  DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMWindowPerformance,                 \
-                                      nsGlobalWindow::HasPerformanceSupport()) \
   DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsITouchEventReceiver,                   \
                                       nsDOMTouchEvent::PrefEnabled())
 #else // !MOZ_B2G
 #define DOM_CLASSINFO_WINDOW_MAP_ENTRIES(_support_indexed_db)                  \
   DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)                                        \
   DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)                                      \
   DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)                                   \
   DOM_CLASSINFO_MAP_ENTRY(nsIInlineEventHandlers)                              \
+  DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowPerformance)                             \
   DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMStorageIndexedDB,                  \
                                       _support_indexed_db)                     \
-  DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMWindowPerformance,                 \
-                                      nsGlobalWindow::HasPerformanceSupport()) \
   DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsITouchEventReceiver,                   \
                                       nsDOMTouchEvent::PrefEnabled())
 #endif // MOZ_B2G
 
 nsresult
 nsDOMClassInfo::Init()
 {
   /* Errors that can trigger early returns are done first,
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -3333,21 +3333,18 @@ nsGlobalWindow::GetPerformance(nsISuppor
   NS_IF_ADDREF(*aPerformance = nsPIDOMWindow::GetPerformance());
   return NS_OK;
 }
 
 nsPerformance*
 nsPIDOMWindow::GetPerformance()
 {
   MOZ_ASSERT(IsInnerWindow());
-  if (HasPerformanceSupport()) {
-    CreatePerformanceObjectIfNeeded();
-    return mPerformance;
-  }
-  return nullptr;
+  CreatePerformanceObjectIfNeeded();
+  return mPerformance;
 }
 
 void
 nsPIDOMWindow::CreatePerformanceObjectIfNeeded()
 {
   if (mPerformance || !mDoc) {
     return;
   }
@@ -11212,23 +11209,16 @@ nsGlobalWindow::DisableTimeChangeNotific
 
 // static
 bool
 nsGlobalWindow::HasIndexedDBSupport()
 {
   return Preferences::GetBool("indexedDB.feature.enabled", true);
 }
 
-// static
-bool
-nsPIDOMWindow::HasPerformanceSupport()
-{
-  return Preferences::GetBool("dom.enable_performance", false);
-}
-
 static size_t
 SizeOfEventTargetObjectsEntryExcludingThisFun(
   nsPtrHashKey<nsDOMEventTargetHelper> *aEntry,
   nsMallocSizeOfFun aMallocSizeOf,
   void *arg)
 {
   nsISupports *supports = aEntry->GetKey();
   nsCOMPtr<nsISizeOfEventTarget> iface = do_QueryInterface(supports);
--- a/dom/base/nsPIDOMWindow.h
+++ b/dom/base/nsPIDOMWindow.h
@@ -638,17 +638,16 @@ public:
    */
   virtual nsresult
   OpenNoNavigate(const nsAString& aUrl, const nsAString& aName,
                  const nsAString& aOptions, nsIDOMWindow **_retval) = 0;
 
   void AddAudioContext(mozilla::dom::AudioContext* aAudioContext);
 
   // WebIDL-ish APIs
-  static bool HasPerformanceSupport();
   nsPerformance* GetPerformance();
 
 protected:
   // The nsPIDOMWindow constructor. The aOuterWindow argument should
   // be null if and only if the created window itself is an outer
   // window. In all other cases aOuterWindow should be the outer
   // window for the inner window that is being created.
   nsPIDOMWindow(nsPIDOMWindow *aOuterWindow);
--- a/layout/base/nsRefreshDriver.cpp
+++ b/layout/base/nsRefreshDriver.cpp
@@ -893,25 +893,26 @@ nsRefreshDriver::Tick(int64_t aNowEpoch,
       }
       // OK, now reset mFrameRequestCallbackDocs so they can be
       // readded as needed.
       mFrameRequestCallbackDocs.Clear();
 
       int64_t eventTime = aNowEpoch / PR_USEC_PER_MSEC;
       for (uint32_t i = 0; i < frameRequestCallbacks.Length(); ++i) {
         const DocumentFrameCallbacks& docCallbacks = frameRequestCallbacks[i];
-        DOMHighResTimeStamp timeStamp;
         // XXXbz Bug 863140: GetInnerWindow can return the outer
         // window in some cases.
         nsPIDOMWindow* innerWindow = docCallbacks.mDocument->GetInnerWindow();
+        DOMHighResTimeStamp timeStamp = 0;
         if (innerWindow && innerWindow->IsInnerWindow()) {
-          timeStamp = innerWindow->GetPerformance()->GetDOMTiming()->
-            TimeStampToDOMHighRes(aNowTime);
-        } else {
-          timeStamp = 0;
+          nsPerformance* perf = innerWindow->GetPerformance();
+          if (perf) {
+            timeStamp = perf->GetDOMTiming()->TimeStampToDOMHighRes(aNowTime);
+          }
+          // else window is partially torn down already
         }
         for (uint32_t j = 0; j < docCallbacks.mCallbacks.Length(); ++j) {
           const nsIDocument::FrameRequestCallbackHolder& holder =
             docCallbacks.mCallbacks[j];
           nsAutoMicroTask mt;
           if (holder.HasWebIDLCallback()) {
             ErrorResult ignored;
             holder.GetWebIDLCallback()->Call(timeStamp, ignored);
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -81,19 +81,16 @@ pref("dom.indexedDB.enabled", true);
 // Space to allow indexedDB databases before prompting (in MB).
 pref("dom.indexedDB.warningQuota", 50);
 
 // Whether or not Web Workers are enabled.
 pref("dom.workers.enabled", true);
 // The number of workers per domain allowed to run concurrently.
 pref("dom.workers.maxPerDomain", 20);
 
-// Whether window.performance is enabled
-pref("dom.enable_performance", true);
-
 // Fastback caching - if this pref is negative, then we calculate the number
 // of content viewers to cache based on the amount of available memory.
 pref("browser.sessionhistory.max_total_viewers", -1);
 
 pref("ui.use_native_colors", true);
 pref("ui.click_hold_context_menus", false);
 pref("browser.display.use_document_fonts",  1);  // 0 = never, 1 = quick, 2 = always
 pref("browser.display.use_document_colors", true);