[tbb-commits] [tor-browser] 01/08: Bug 1789128 - Always call LoadInfo::GetPerformanceStorage(). r=smaug, a=RyanVM
gitolite role
git at cupani.torproject.org
Thu Oct 20 14:41:27 UTC 2022
This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch tor-browser-91.13.0esr-11.5-1
in repository tor-browser.
commit 42daa55746cc9cbe7d1ef63cb0d547e7b6eaf2ab
Author: Valentin Gosu <valentin.gosu at gmail.com>
AuthorDate: Tue Sep 20 15:27:44 2022 +0000
Bug 1789128 - Always call LoadInfo::GetPerformanceStorage(). r=smaug, a=RyanVM
---
dom/ipc/ContentChild.cpp | 22 ++++++++++++++--------
dom/ipc/ContentChild.h | 5 +++--
dom/ipc/ContentParent.cpp | 10 +++++++---
dom/ipc/ContentParent.h | 5 +++--
dom/ipc/PContent.ipdl | 3 ++-
netwerk/protocol/http/HttpBaseChannel.cpp | 19 +++++++------------
netwerk/protocol/http/HttpBaseChannel.h | 1 -
7 files changed, 36 insertions(+), 29 deletions(-)
diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp
index 4f971ce8c5d3..c2f518542ee3 100644
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -4138,24 +4138,30 @@ mozilla::ipc::IPCResult ContentChild::RecvScriptError(
}
mozilla::ipc::IPCResult ContentChild::RecvReportFrameTimingData(
- uint64_t innerWindowId, const nsString& entryName,
+ const mozilla::Maybe<LoadInfoArgs>& loadInfoArgs, const nsString& entryName,
const nsString& initiatorType, UniquePtr<PerformanceTimingData>&& aData) {
if (!aData) {
return IPC_FAIL(this, "aData should not be null");
}
- auto* innerWindow = nsGlobalWindowInner::GetInnerWindowWithId(innerWindowId);
- if (!innerWindow) {
- return IPC_OK();
+ if (loadInfoArgs.isNothing()) {
+ return IPC_FAIL(this, "loadInfoArgs should not be null");
}
- mozilla::dom::Performance* performance = innerWindow->GetPerformance();
- if (!performance) {
+ nsCOMPtr<nsILoadInfo> loadInfo;
+ nsresult rv = mozilla::ipc::LoadInfoArgsToLoadInfo(loadInfoArgs,
+ getter_AddRefs(loadInfo));
+ if (NS_FAILED(rv)) {
+ MOZ_DIAGNOSTIC_ASSERT(false, "LoadInfoArgsToLoadInfo failed");
return IPC_OK();
}
- performance->AsPerformanceStorage()->AddEntry(entryName, initiatorType,
- std::move(aData));
+ // It is important to call LoadInfo::GetPerformanceStorage instead of simply
+ // getting the performance object via the innerWindowID in order to perform
+ // necessary cross origin checks.
+ if (PerformanceStorage* storage = loadInfo->GetPerformanceStorage()) {
+ storage->AddEntry(entryName, initiatorType, std::move(aData));
+ }
return IPC_OK();
}
diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h
index 2babe20eb6f7..b55c11ad2a2c 100644
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -757,8 +757,9 @@ class ContentChild final : public PContentChild,
const uint64_t& aInnerWindowId, const bool& aFromChromeContext);
mozilla::ipc::IPCResult RecvReportFrameTimingData(
- uint64_t innerWindowId, const nsString& entryName,
- const nsString& initiatorType, UniquePtr<PerformanceTimingData>&& aData);
+ const mozilla::Maybe<LoadInfoArgs>& loadInfoArgs,
+ const nsString& entryName, const nsString& initiatorType,
+ UniquePtr<PerformanceTimingData>&& aData);
mozilla::ipc::IPCResult RecvLoadURI(
const MaybeDiscarded<BrowsingContext>& aContext,
diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp
index 9e11d81a395d..c5eeba70b029 100644
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -4680,14 +4680,18 @@ mozilla::ipc::IPCResult ContentParent::RecvConsoleMessage(
}
mozilla::ipc::IPCResult ContentParent::RecvReportFrameTimingData(
- uint64_t aInnerWindowId, const nsString& entryName,
+ const mozilla::Maybe<LoadInfoArgs>& loadInfoArgs, const nsString& entryName,
const nsString& initiatorType, UniquePtr<PerformanceTimingData>&& aData) {
if (!aData) {
return IPC_FAIL(this, "aData should not be null");
}
+ if (loadInfoArgs.isNothing()) {
+ return IPC_FAIL(this, "loadInfoArgs should not be null");
+ }
+
RefPtr<WindowGlobalParent> parent =
- WindowGlobalParent::GetByInnerWindowId(aInnerWindowId);
+ WindowGlobalParent::GetByInnerWindowId(loadInfoArgs->innerWindowID());
if (!parent || !parent->GetContentParent()) {
return IPC_OK();
}
@@ -4696,7 +4700,7 @@ mozilla::ipc::IPCResult ContentParent::RecvReportFrameTimingData(
"No need to bounce around if in the same process");
Unused << parent->GetContentParent()->SendReportFrameTimingData(
- aInnerWindowId, entryName, initiatorType, std::move(aData));
+ loadInfoArgs, entryName, initiatorType, std::move(aData));
return IPC_OK();
}
diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h
index 98e9f70a7b47..5239b6f2934a 100644
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -1099,8 +1099,9 @@ class ContentParent final
const uint64_t& aInnerWindowId, const bool& aIsFromChromeContext);
mozilla::ipc::IPCResult RecvReportFrameTimingData(
- uint64_t innerWindowId, const nsString& entryName,
- const nsString& initiatorType, UniquePtr<PerformanceTimingData>&& aData);
+ const mozilla::Maybe<LoadInfoArgs>& loadInfoArgs,
+ const nsString& entryName, const nsString& initiatorType,
+ UniquePtr<PerformanceTimingData>&& aData);
mozilla::ipc::IPCResult RecvScriptErrorWithStack(
const nsString& aMessage, const nsString& aSourceName,
diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl
index 01a38cfb2e96..b4747302f50f 100644
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -1719,9 +1719,10 @@ both:
* another process. Child frame will send data to its ContentParent which
* will then identify the ContentParent for the innerWindowId and pass
* the data to the correct process.
+ * loadInfo is passed in order to enforce same-origin security checks
* aData must be non-null.
*/
- async ReportFrameTimingData(uint64_t innerWindowId, nsString entryName,
+ async ReportFrameTimingData(LoadInfoArgs? loadInfo, nsString entryName,
nsString initiatorType,
UniquePtr<PerformanceTimingData> aData);
diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp
index e77789105095..7044f92829d7 100644
--- a/netwerk/protocol/http/HttpBaseChannel.cpp
+++ b/netwerk/protocol/http/HttpBaseChannel.cpp
@@ -5013,29 +5013,22 @@ IMPL_TIMING_ATTR(RedirectEnd)
#undef IMPL_TIMING_ATTR
-mozilla::dom::PerformanceStorage* HttpBaseChannel::GetPerformanceStorage() {
+void HttpBaseChannel::MaybeReportTimingData() {
// If performance timing is disabled, there is no need for the Performance
// object anymore.
if (!LoadTimingEnabled()) {
- return nullptr;
+ return;
}
// There is no point in continuing, since the performance object in the parent
// isn't the same as the one in the child which will be reporting resource
// performance.
- if (XRE_IsE10sParentProcess()) {
- return nullptr;
- }
- return mLoadInfo->GetPerformanceStorage();
-}
-
-void HttpBaseChannel::MaybeReportTimingData() {
if (XRE_IsE10sParentProcess()) {
return;
}
mozilla::dom::PerformanceStorage* documentPerformance =
- GetPerformanceStorage();
+ mLoadInfo->GetPerformanceStorage();
if (documentPerformance) {
documentPerformance->AddEntry(this, this);
return;
@@ -5058,8 +5051,10 @@ void HttpBaseChannel::MaybeReportTimingData() {
if (!performanceTimingData) {
return;
}
- child->SendReportFrameTimingData(mLoadInfo->GetInnerWindowID(), entryName,
- initiatorType,
+
+ Maybe<LoadInfoArgs> loadInfoArgs;
+ mozilla::ipc::LoadInfoToLoadInfoArgs(mLoadInfo, &loadInfoArgs);
+ child->SendReportFrameTimingData(loadInfoArgs, entryName, initiatorType,
std::move(performanceTimingData));
}
}
diff --git a/netwerk/protocol/http/HttpBaseChannel.h b/netwerk/protocol/http/HttpBaseChannel.h
index c6517298c33f..64e0e283f2e9 100644
--- a/netwerk/protocol/http/HttpBaseChannel.h
+++ b/netwerk/protocol/http/HttpBaseChannel.h
@@ -545,7 +545,6 @@ class HttpBaseChannel : public nsHashPropertyBag,
// was fired.
void NotifySetCookie(const nsACString& aCookie);
- mozilla::dom::PerformanceStorage* GetPerformanceStorage();
void MaybeReportTimingData();
nsIURI* GetReferringPage();
nsPIDOMWindowInner* GetInnerDOMWindow();
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the tbb-commits
mailing list