Bug 1597453 - Fix uses of nsIDocShellTreeItem in mozilla::dom::PerformanceTiming::IsTopLevelContentDocument. r=kmag
authorTetsuharu OHZEKI <tetsuharu.ohzeki@gmail.com>
Thu, 16 Jan 2020 04:47:51 +0000
changeset 510435 ce4e1638e4721dd20ddd587b082bd5eca8b0503a
parent 510434 198f7c0bb5bba88bcec19fffa3bfe38b161cf818
child 510436 7f724ded7131469ea1264a47871de593cf189b11
push id37021
push userrmaries@mozilla.com
push dateThu, 16 Jan 2020 09:46:51 +0000
treeherdermozilla-central@7541d616ff87 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1597453
milestone74.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 1597453 - Fix uses of nsIDocShellTreeItem in mozilla::dom::PerformanceTiming::IsTopLevelContentDocument. r=kmag Differential Revision: https://phabricator.services.mozilla.com/D59454
dom/performance/PerformanceTiming.cpp
--- a/dom/performance/PerformanceTiming.cpp
+++ b/dom/performance/PerformanceTiming.cpp
@@ -6,16 +6,17 @@
 
 #include "PerformanceTiming.h"
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/dom/PerformanceTimingBinding.h"
 #include "mozilla/StaticPrefs_dom.h"
 #include "mozilla/Telemetry.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeItem.h"
+#include "mozilla/dom/BrowsingContext.h"
 #include "mozilla/dom/Document.h"
 #include "nsITimedChannel.h"
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(PerformanceTiming, mPerformance)
 
@@ -611,27 +612,21 @@ JSObject* PerformanceTiming::WrapObject(
   return PerformanceTiming_Binding::Wrap(cx, this, aGivenProto);
 }
 
 bool PerformanceTiming::IsTopLevelContentDocument() const {
   nsCOMPtr<Document> document = mPerformance->GetDocumentIfCurrent();
   if (!document) {
     return false;
   }
-  nsCOMPtr<nsIDocShell> docShell = document->GetDocShell();
-  if (!docShell) {
-    return false;
+
+  if (BrowsingContext* bc = document->GetBrowsingContext()) {
+    return bc->IsTopContent();
   }
-  nsCOMPtr<nsIDocShellTreeItem> rootItem;
-  Unused << docShell->GetInProcessSameTypeRootTreeItem(
-      getter_AddRefs(rootItem));
-  if (rootItem.get() != static_cast<nsIDocShellTreeItem*>(docShell.get())) {
-    return false;
-  }
-  return rootItem->ItemType() == nsIDocShellTreeItem::typeContent;
+  return false;
 }
 
 nsTArray<nsCOMPtr<nsIServerTiming>> PerformanceTimingData::GetServerTiming() {
   if (!StaticPrefs::dom_enable_performance() || !IsInitialized() ||
       !TimingAllowed() || nsContentUtils::ShouldResistFingerprinting()) {
     return nsTArray<nsCOMPtr<nsIServerTiming>>();
   }