Bug 1659025 - Add `dom.streams.transferable.enabled` r=smaug
authorKagami Sascha Rosylight <krosylight@mozilla.com>
Thu, 19 May 2022 11:54:32 +0000
changeset 618227 454e9dcf44198c0d4d43facd7839dd3a411b779e
parent 618226 848b3025ef7c540246db27ddc3c287d4266d20cf
child 618228 974bc11d251bea2ac2b119ee368ee4f9528c4225
push id39719
push usersmolnar@mozilla.com
push dateThu, 19 May 2022 16:03:14 +0000
treeherdermozilla-central@cc776278c4ea [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1659025
milestone102.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 1659025 - Add `dom.streams.transferable.enabled` r=smaug Differential Revision: https://phabricator.services.mozilla.com/D146747
dom/base/StructuredCloneHolder.cpp
modules/libpref/init/StaticPrefList.yaml
testing/web-platform/meta/html/infrastructure/safe-passing-of-structured-data/__dir__.ini
testing/web-platform/meta/html/webappapis/structured-clone/__dir__.ini
testing/web-platform/meta/streams/transferable/__dir__.ini
testing/web-platform/meta/workers/semantics/structured-clone/__dir__.ini
--- a/dom/base/StructuredCloneHolder.cpp
+++ b/dom/base/StructuredCloneHolder.cpp
@@ -1324,75 +1324,77 @@ StructuredCloneHolder::CustomWriteTransf
         *aContent = clonedBitmap.release();
         MOZ_ASSERT(*aContent);
         bitmap->Close();
 
         return true;
       }
     }
 
-    {
-      RefPtr<ReadableStream> stream;
-      rv = UNWRAP_OBJECT(ReadableStream, &obj, stream);
-      if (NS_SUCCEEDED(rv)) {
-        MOZ_ASSERT(stream);
+    if (StaticPrefs::dom_streams_transferable_enabled()) {
+      {
+        RefPtr<ReadableStream> stream;
+        rv = UNWRAP_OBJECT(ReadableStream, &obj, stream);
+        if (NS_SUCCEEDED(rv)) {
+          MOZ_ASSERT(stream);
 
-        *aTag = SCTAG_DOM_READABLESTREAM;
-        *aOwnership = JS::SCTAG_TMO_CUSTOM;
-        *aContent = nullptr;
+          *aTag = SCTAG_DOM_READABLESTREAM;
+          *aOwnership = JS::SCTAG_TMO_CUSTOM;
+          *aContent = nullptr;
 
-        UniqueMessagePortId id;
-        if (!stream->Transfer(aCx, id)) {
-          return false;
+          UniqueMessagePortId id;
+          if (!stream->Transfer(aCx, id)) {
+            return false;
+          }
+          *aExtraData = mPortIdentifiers.Length();
+          mPortIdentifiers.AppendElement(id.release());
+          return true;
         }
-        *aExtraData = mPortIdentifiers.Length();
-        mPortIdentifiers.AppendElement(id.release());
-        return true;
       }
-    }
 
-    {
-      RefPtr<WritableStream> stream;
-      rv = UNWRAP_OBJECT(WritableStream, &obj, stream);
-      if (NS_SUCCEEDED(rv)) {
-        MOZ_ASSERT(stream);
+      {
+        RefPtr<WritableStream> stream;
+        rv = UNWRAP_OBJECT(WritableStream, &obj, stream);
+        if (NS_SUCCEEDED(rv)) {
+          MOZ_ASSERT(stream);
 
-        *aTag = SCTAG_DOM_WRITABLESTREAM;
-        *aOwnership = JS::SCTAG_TMO_CUSTOM;
-        *aContent = nullptr;
+          *aTag = SCTAG_DOM_WRITABLESTREAM;
+          *aOwnership = JS::SCTAG_TMO_CUSTOM;
+          *aContent = nullptr;
 
-        UniqueMessagePortId id;
-        if (!stream->Transfer(aCx, id)) {
-          return false;
+          UniqueMessagePortId id;
+          if (!stream->Transfer(aCx, id)) {
+            return false;
+          }
+          *aExtraData = mPortIdentifiers.Length();
+          mPortIdentifiers.AppendElement(id.release());
+          return true;
         }
-        *aExtraData = mPortIdentifiers.Length();
-        mPortIdentifiers.AppendElement(id.release());
-        return true;
       }
-    }
 
-    {
-      RefPtr<TransformStream> stream;
-      rv = UNWRAP_OBJECT(TransformStream, &obj, stream);
-      if (NS_SUCCEEDED(rv)) {
-        MOZ_ASSERT(stream);
+      {
+        RefPtr<TransformStream> stream;
+        rv = UNWRAP_OBJECT(TransformStream, &obj, stream);
+        if (NS_SUCCEEDED(rv)) {
+          MOZ_ASSERT(stream);
 
-        *aTag = SCTAG_DOM_TRANSFORMSTREAM;
-        *aOwnership = JS::SCTAG_TMO_CUSTOM;
-        *aContent = nullptr;
+          *aTag = SCTAG_DOM_TRANSFORMSTREAM;
+          *aOwnership = JS::SCTAG_TMO_CUSTOM;
+          *aContent = nullptr;
 
-        UniqueMessagePortId id1;
-        UniqueMessagePortId id2;
-        if (!stream->Transfer(aCx, id1, id2)) {
-          return false;
+          UniqueMessagePortId id1;
+          UniqueMessagePortId id2;
+          if (!stream->Transfer(aCx, id1, id2)) {
+            return false;
+          }
+          *aExtraData = mPortIdentifiers.Length();
+          mPortIdentifiers.AppendElement(id1.release());
+          mPortIdentifiers.AppendElement(id2.release());
+          return true;
         }
-        *aExtraData = mPortIdentifiers.Length();
-        mPortIdentifiers.AppendElement(id1.release());
-        mPortIdentifiers.AppendElement(id2.release());
-        return true;
       }
     }
   }
 
   return false;
 }
 
 void StructuredCloneHolder::CustomFreeTransferHandler(
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -3648,16 +3648,21 @@
   value: true
   mirror: always
 
 - name: dom.streams.pipeTo.enabled
   type: RelaxedAtomicBool
   value: true
   mirror: always
 
+- name: dom.streams.transferable.enabled
+  type: RelaxedAtomicBool
+  value: @IS_NIGHTLY_BUILD@
+  mirror: always
+
 # For area and anchor elements with target=_blank and no rel set to
 # opener/noopener.
 - name: dom.targetBlankNoOpener.enabled
   type: bool
   value: true
   mirror: always
 
 # Is support for Selection.GetRangesForInterval enabled?
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/html/infrastructure/safe-passing-of-structured-data/__dir__.ini
@@ -0,0 +1,1 @@
+prefs: [dom.streams.transferable.enabled:true]
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/html/webappapis/structured-clone/__dir__.ini
@@ -0,0 +1,1 @@
+prefs: [dom.streams.transferable.enabled:true]
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/streams/transferable/__dir__.ini
@@ -0,0 +1,1 @@
+prefs: [dom.streams.transferable.enabled:true]
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/workers/semantics/structured-clone/__dir__.ini
@@ -0,0 +1,1 @@
+prefs: [dom.streams.transferable.enabled:true]