Pier Angelo Vendrame pushed to branch mullvad-browser-140.6.0esr-15.0-1 at The 
Tor Project / Applications / Mullvad Browser


Commits:
52b09dcb by Fatih Kilic at 2025-12-08T12:31:32+01:00
Bug 1977576 - Pass JSContext to VideoFrame::PrefEnabled in more places. 
r=manuel,chunmin,tjr

Differential Revision: https://phabricator.services.mozilla.com/D257488

- - - - -


3 changed files:

- dom/base/StructuredCloneHolder.cpp
- dom/media/webcodecs/VideoFrame.h
- toolkit/components/resistfingerprinting/nsRFPService.cpp


Changes:

=====================================
dom/base/StructuredCloneHolder.cpp
=====================================
@@ -1110,7 +1110,7 @@ JSObject* StructuredCloneHolder::CustomReadHandler(
     return ClonedErrorHolder::ReadStructuredClone(aCx, aReader, this);
   }
 
-  if (VideoFrame::PrefEnabled() && aTag == SCTAG_DOM_VIDEOFRAME &&
+  if (VideoFrame::PrefEnabled(aCx) && aTag == SCTAG_DOM_VIDEOFRAME &&
       CloneScope() == StructuredCloneScope::SameProcess &&
       aCloneDataPolicy.areIntraClusterClonableSharedObjectsAllowed()) {
     JS::Rooted<JSObject*> global(aCx, mGlobal->GetGlobalJSObject());
@@ -1250,7 +1250,7 @@ bool StructuredCloneHolder::CustomWriteHandler(
   }
 
   // See if this is a VideoFrame object.
-  if (VideoFrame::PrefEnabled()) {
+  if (VideoFrame::PrefEnabled(aCx)) {
     VideoFrame* videoFrame = nullptr;
     if (NS_SUCCEEDED(UNWRAP_OBJECT(VideoFrame, &obj, videoFrame))) {
       SameProcessScopeRequired(aSameProcessScopeRequired);
@@ -1446,7 +1446,7 @@ StructuredCloneHolder::CustomReadTransferHandler(
                                             aReturnObject);
   }
 
-  if (VideoFrame::PrefEnabled() && aTag == SCTAG_DOM_VIDEOFRAME &&
+  if (VideoFrame::PrefEnabled(aCx) && aTag == SCTAG_DOM_VIDEOFRAME &&
       CloneScope() == StructuredCloneScope::SameProcess &&
       aCloneDataPolicy.areIntraClusterClonableSharedObjectsAllowed()) {
     MOZ_ASSERT(aContent);
@@ -1591,7 +1591,7 @@ StructuredCloneHolder::CustomWriteTransferHandler(
         return true;
       }
 
-      if (VideoFrame::PrefEnabled()) {
+      if (VideoFrame::PrefEnabled(aCx)) {
         VideoFrame* videoFrame = nullptr;
         rv = UNWRAP_OBJECT(VideoFrame, &obj, videoFrame);
         if (NS_SUCCEEDED(rv)) {
@@ -1758,7 +1758,7 @@ void StructuredCloneHolder::CustomFreeTransferHandler(
     return;
   }
 
-  if (VideoFrame::PrefEnabled() && aTag == SCTAG_DOM_VIDEOFRAME &&
+  if (aTag == SCTAG_DOM_VIDEOFRAME &&
       CloneScope() == StructuredCloneScope::SameProcess) {
     if (aContent) {
       VideoFrame::TransferredData* data =
@@ -1767,8 +1767,7 @@ void StructuredCloneHolder::CustomFreeTransferHandler(
     }
     return;
   }
-  if (StaticPrefs::dom_media_webcodecs_enabled() &&
-      aTag == SCTAG_DOM_AUDIODATA &&
+  if (aTag == SCTAG_DOM_AUDIODATA &&
       CloneScope() == StructuredCloneScope::SameProcess) {
     if (aContent) {
       AudioData::TransferredData* data =
@@ -1851,7 +1850,7 @@ bool StructuredCloneHolder::CustomCanTransferHandler(
     }
   }
 
-  if (VideoFrame::PrefEnabled()) {
+  if (VideoFrame::PrefEnabled(aCx)) {
     VideoFrame* videoframe = nullptr;
     nsresult rv = UNWRAP_OBJECT(VideoFrame, &obj, videoframe);
     if (NS_SUCCEEDED(rv)) {


=====================================
dom/media/webcodecs/VideoFrame.h
=====================================
@@ -104,7 +104,7 @@ class VideoFrame final : public nsISupports,
   JSObject* WrapObject(JSContext* aCx,
                        JS::Handle<JSObject*> aGivenProto) override;
 
-  static bool PrefEnabled(JSContext* aCx = nullptr, JSObject* aObj = nullptr);
+  static bool PrefEnabled(JSContext* aCx, JSObject* aObj = nullptr);
 
   static already_AddRefed<VideoFrame> Constructor(
       const GlobalObject& aGlobal, HTMLImageElement& aImageElement,


=====================================
toolkit/components/resistfingerprinting/nsRFPService.cpp
=====================================
@@ -2708,8 +2708,10 @@ bool 
nsRFPService::IsWebCodecsRFPTargetEnabled(JSContext* aCx) {
   // We know that the RFPTarget::WebCodecs is enabled, check if principal
   // is exempted.
 
-  // VideoFrame::PrefEnabled function can be called without a JSContext.
-  if (!aCx) {
+  if (NS_WARN_IF(!aCx)) {
+    MOZ_LOG(gResistFingerprintingLog, LogLevel::Warning,
+            ("nsRFPService::IsWebCodecsRFPTargetEnabled called with null "
+             "JSContext"));
     return true;
   }
 



View it on GitLab: 
https://gitlab.torproject.org/tpo/applications/mullvad-browser/-/commit/52b09dcb6f09444f9f160e56e917857c14a7db83

-- 
View it on GitLab: 
https://gitlab.torproject.org/tpo/applications/mullvad-browser/-/commit/52b09dcb6f09444f9f160e56e917857c14a7db83
You're receiving this email because of your account on gitlab.torproject.org.


_______________________________________________
tor-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to