<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[279769] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/279769">279769</a></dd>
<dt>Author</dt> <dd>ysuzuki@apple.com</dd>
<dt>Date</dt> <dd>2021-07-08 17:38:41 -0700 (Thu, 08 Jul 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fix StructuredClone for streams to handle BigInt64Array / BigUint64Array
https://bugs.webkit.org/show_bug.cgi?id=227571

Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

* resources/import-expectations.json:
* web-platform-tests/FileAPI/blob/Blob-constructor.any-expected.txt:
* web-platform-tests/FileAPI/blob/Blob-constructor.any.js:
(test_blob):
* web-platform-tests/FileAPI/blob/Blob-constructor.any.worker-expected.txt:
* web-platform-tests/encoding/encodeInto.any-expected.txt:
* web-platform-tests/encoding/encodeInto.any.js:
(string_appeared_here.forEach.type.string_appeared_here.forEach):
(Float64Array.forEach.view.string_appeared_here.forEach): Deleted.
* web-platform-tests/encoding/encodeInto.any.worker-expected.txt:
* web-platform-tests/encoding/w3c-import.log:
* web-platform-tests/fetch/api/response/response-clone.any-expected.txt:
* web-platform-tests/fetch/api/response/response-clone.any.js:
* web-platform-tests/fetch/api/response/response-clone.any.worker-expected.txt:

Source/WebCore:

While we already support BigInt64Array / BigUint64Array handling even in DOM code,
we lack support of them only in fetch's structuredClone code (which is specialized one
to make it fast by bypassing serialization / deserialization).

This patch fixes the issue to complete BigInt64Array / BigUint64Array in all DOM code.

* Modules/streams/ReadableStreamInternals.js:
(readableStreamTeePullFunction):
(doStructuredClone): Deleted.
* bindings/js/JSDOMGlobalObject.cpp:
(WebCore::JSDOMGlobalObject::addBuiltinGlobals):
* bindings/js/StructuredClone.cpp:
(WebCore::JSC_DEFINE_HOST_FUNCTION):
* bindings/js/StructuredClone.h:
* bindings/js/WebCoreBuiltinNames.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cresourcesimportexpectationsjson">trunk/LayoutTests/imported/w3c/resources/import-expectations.json</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsFileAPIblobBlobconstructoranyexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/blob/Blob-constructor.any-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsFileAPIblobBlobconstructoranyjs">trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/blob/Blob-constructor.any.js</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsFileAPIblobBlobconstructoranyworkerexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/blob/Blob-constructor.any.worker-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsencodingencodeIntoanyexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/encoding/encodeInto.any-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsencodingencodeIntoanyjs">trunk/LayoutTests/imported/w3c/web-platform-tests/encoding/encodeInto.any.js</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsencodingencodeIntoanyworkerexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/encoding/encodeInto.any.worker-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsencodingw3cimportlog">trunk/LayoutTests/imported/w3c/web-platform-tests/encoding/w3c-import.log</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsecloneanyexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-clone.any-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsecloneanyjs">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-clone.any.js</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsecloneanyworkerexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-clone.any.worker-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesstreamsReadableStreamInternalsjs">trunk/Source/WebCore/Modules/streams/ReadableStreamInternals.js</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMGlobalObjectcpp">trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsStructuredClonecpp">trunk/Source/WebCore/bindings/js/StructuredClone.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsStructuredCloneh">trunk/Source/WebCore/bindings/js/StructuredClone.h</a></li>
<li><a href="#trunkSourceWebCorebindingsjsWebCoreBuiltinNamesh">trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (279768 => 279769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-07-09 00:12:30 UTC (rev 279768)
+++ trunk/LayoutTests/imported/w3c/ChangeLog    2021-07-09 00:38:41 UTC (rev 279769)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2021-07-08  Yusuke Suzuki  <ysuzuki@apple.com>
+
+        Fix StructuredClone for streams to handle BigInt64Array / BigUint64Array
+        https://bugs.webkit.org/show_bug.cgi?id=227571
+
+        Reviewed by Chris Dumez.
+
+        * resources/import-expectations.json:
+        * web-platform-tests/FileAPI/blob/Blob-constructor.any-expected.txt:
+        * web-platform-tests/FileAPI/blob/Blob-constructor.any.js:
+        (test_blob):
+        * web-platform-tests/FileAPI/blob/Blob-constructor.any.worker-expected.txt:
+        * web-platform-tests/encoding/encodeInto.any-expected.txt:
+        * web-platform-tests/encoding/encodeInto.any.js:
+        (string_appeared_here.forEach.type.string_appeared_here.forEach):
+        (Float64Array.forEach.view.string_appeared_here.forEach): Deleted.
+        * web-platform-tests/encoding/encodeInto.any.worker-expected.txt:
+        * web-platform-tests/encoding/w3c-import.log:
+        * web-platform-tests/fetch/api/response/response-clone.any-expected.txt:
+        * web-platform-tests/fetch/api/response/response-clone.any.js:
+        * web-platform-tests/fetch/api/response/response-clone.any.worker-expected.txt:
+
</ins><span class="cx"> 2021-07-08  Chris Dumez  <cdumez@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [IndexedDB] KeyPath validity checks should happen on the cloned value, not the original one
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cresourcesimportexpectationsjson"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/resources/import-expectations.json (279768 => 279769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/resources/import-expectations.json        2021-07-09 00:12:30 UTC (rev 279768)
+++ trunk/LayoutTests/imported/w3c/resources/import-expectations.json   2021-07-09 00:38:41 UTC (rev 279769)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx">     "web-platform-tests/DOM-parsing": "skip", 
</span><span class="cx">     "web-platform-tests/DOMEvents": "skip", 
</span><span class="cx">     "web-platform-tests/FileAPI": "import", 
</span><ins>+    "web-platform-tests/FileAPI/blob": "import", 
</ins><span class="cx">     "web-platform-tests/IndexedDB": "import", 
</span><span class="cx">     "web-platform-tests/WebCryptoAPI": "import", 
</span><span class="cx">     "web-platform-tests/WebIDL": "import", 
</span><span class="lines">@@ -208,6 +209,7 @@
</span><span class="cx">     "web-platform-tests/fetch/api/cors": "import", 
</span><span class="cx">     "web-platform-tests/fetch/api/redirect": "import", 
</span><span class="cx">     "web-platform-tests/fetch/api/resources": "import", 
</span><ins>+    "web-platform-tests/fetch/api/response": "import", 
</ins><span class="cx">     "web-platform-tests/fetch/origin": "import", 
</span><span class="cx">     "web-platform-tests/fetch/range": "import", 
</span><span class="cx">     "web-platform-tests/fetch/stale-while-revalidate": "import", 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsFileAPIblobBlobconstructoranyexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/blob/Blob-constructor.any-expected.txt (279768 => 279769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/blob/Blob-constructor.any-expected.txt 2021-07-09 00:12:30 UTC (rev 279768)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/blob/Blob-constructor.any-expected.txt    2021-07-09 00:38:41 UTC (rev 279769)
</span><span class="lines">@@ -20,6 +20,7 @@
</span><span class="cx"> PASS ArrayBuffer elements of the blobParts array should be supported.
</span><span class="cx"> PASS Passing typed arrays as elements of the blobParts array should work.
</span><span class="cx"> PASS Passing a Float64Array as element of the blobParts array should work.
</span><ins>+PASS Passing BigInt typed arrays as elements of the blobParts array should work.
</ins><span class="cx"> PASS Passing a FrozenArray as the blobParts array should work (FrozenArray<MessagePort>).
</span><span class="cx"> PASS Array with two blobs
</span><span class="cx"> PASS Array with two buffers
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsFileAPIblobBlobconstructoranyjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/blob/Blob-constructor.any.js (279768 => 279769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/blob/Blob-constructor.any.js   2021-07-09 00:12:30 UTC (rev 279768)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/blob/Blob-constructor.any.js      2021-07-09 00:38:41 UTC (rev 279769)
</span><span class="lines">@@ -311,8 +311,17 @@
</span><span class="cx">   desc: "Passing a Float64Array as element of the blobParts array should work."
</span><span class="cx"> });
</span><span class="cx"> 
</span><ins>+test_blob(function() {
+  return new Blob([
+    new BigInt64Array([BigInt("0x5353415053534150")]),
+    new BigUint64Array([BigInt("0x5353415053534150")])
+  ]);
+}, {
+  expected: "PASSPASSPASSPASS",
+  type: "",
+  desc: "Passing BigInt typed arrays as elements of the blobParts array should work."
+});
</ins><span class="cx"> 
</span><del>-
</del><span class="cx"> var t_ports = async_test("Passing a FrozenArray as the blobParts array should work (FrozenArray<MessagePort>).");
</span><span class="cx"> t_ports.step(function() {
</span><span class="cx">     var channel = new MessageChannel();
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsFileAPIblobBlobconstructoranyworkerexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/blob/Blob-constructor.any.worker-expected.txt (279768 => 279769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/blob/Blob-constructor.any.worker-expected.txt  2021-07-09 00:12:30 UTC (rev 279768)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/blob/Blob-constructor.any.worker-expected.txt     2021-07-09 00:38:41 UTC (rev 279769)
</span><span class="lines">@@ -20,6 +20,7 @@
</span><span class="cx"> PASS ArrayBuffer elements of the blobParts array should be supported.
</span><span class="cx"> PASS Passing typed arrays as elements of the blobParts array should work.
</span><span class="cx"> PASS Passing a Float64Array as element of the blobParts array should work.
</span><ins>+PASS Passing BigInt typed arrays as elements of the blobParts array should work.
</ins><span class="cx"> PASS Passing a FrozenArray as the blobParts array should work (FrozenArray<MessagePort>).
</span><span class="cx"> PASS Array with two blobs
</span><span class="cx"> PASS Array with two buffers
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsencodingencodeIntoanyexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/encoding/encodeInto.any-expected.txt (279768 => 279769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/encoding/encodeInto.any-expected.txt   2021-07-09 00:12:30 UTC (rev 279768)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/encoding/encodeInto.any-expected.txt      2021-07-09 00:38:41 UTC (rev 279769)
</span><span class="lines">@@ -97,6 +97,10 @@
</span><span class="cx"> PASS Invalid encodeInto() destination: Uint32Array, backed by: SharedArrayBuffer
</span><span class="cx"> PASS Invalid encodeInto() destination: Uint8ClampedArray, backed by: ArrayBuffer
</span><span class="cx"> PASS Invalid encodeInto() destination: Uint8ClampedArray, backed by: SharedArrayBuffer
</span><ins>+PASS Invalid encodeInto() destination: BigInt64Array, backed by: ArrayBuffer
+PASS Invalid encodeInto() destination: BigInt64Array, backed by: SharedArrayBuffer
+PASS Invalid encodeInto() destination: BigUint64Array, backed by: ArrayBuffer
+PASS Invalid encodeInto() destination: BigUint64Array, backed by: SharedArrayBuffer
</ins><span class="cx"> PASS Invalid encodeInto() destination: Float32Array, backed by: ArrayBuffer
</span><span class="cx"> PASS Invalid encodeInto() destination: Float32Array, backed by: SharedArrayBuffer
</span><span class="cx"> PASS Invalid encodeInto() destination: Float64Array, backed by: ArrayBuffer
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsencodingencodeIntoanyjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/encoding/encodeInto.any.js (279768 => 279769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/encoding/encodeInto.any.js     2021-07-09 00:12:30 UTC (rev 279768)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/encoding/encodeInto.any.js        2021-07-09 00:38:41 UTC (rev 279769)
</span><span class="lines">@@ -120,19 +120,22 @@
</span><span class="cx">   });
</span><span class="cx"> });
</span><span class="cx"> 
</span><del>-[DataView,
- Int8Array,
- Int16Array,
- Int32Array,
- Uint16Array,
- Uint32Array,
- Uint8ClampedArray,
- Float32Array,
- Float64Array].forEach(view => {
</del><ins>+["DataView",
+ "Int8Array",
+ "Int16Array",
+ "Int32Array",
+ "Uint16Array",
+ "Uint32Array",
+ "Uint8ClampedArray",
+ "BigInt64Array",
+ "BigUint64Array",
+ "Float32Array",
+ "Float64Array"].forEach(type => {
</ins><span class="cx">   ["ArrayBuffer", "SharedArrayBuffer"].forEach((arrayBufferOrSharedArrayBuffer) => {
</span><span class="cx">     test(() => {
</span><del>-      assert_throws_js(TypeError, () => new TextEncoder().encodeInto("", new view(createBuffer(arrayBufferOrSharedArrayBuffer, 0))));
-    }, "Invalid encodeInto() destination: " + view.name + ", backed by: " + arrayBufferOrSharedArrayBuffer);
</del><ins>+      const viewInstance = new self[type](createBuffer(arrayBufferOrSharedArrayBuffer, 0));
+      assert_throws_js(TypeError, () => new TextEncoder().encodeInto("", viewInstance));
+    }, "Invalid encodeInto() destination: " + type + ", backed by: " + arrayBufferOrSharedArrayBuffer);
</ins><span class="cx">   });
</span><span class="cx"> });
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsencodingencodeIntoanyworkerexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/encoding/encodeInto.any.worker-expected.txt (279768 => 279769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/encoding/encodeInto.any.worker-expected.txt    2021-07-09 00:12:30 UTC (rev 279768)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/encoding/encodeInto.any.worker-expected.txt       2021-07-09 00:38:41 UTC (rev 279769)
</span><span class="lines">@@ -97,6 +97,10 @@
</span><span class="cx"> PASS Invalid encodeInto() destination: Uint32Array, backed by: SharedArrayBuffer
</span><span class="cx"> PASS Invalid encodeInto() destination: Uint8ClampedArray, backed by: ArrayBuffer
</span><span class="cx"> PASS Invalid encodeInto() destination: Uint8ClampedArray, backed by: SharedArrayBuffer
</span><ins>+PASS Invalid encodeInto() destination: BigInt64Array, backed by: ArrayBuffer
+PASS Invalid encodeInto() destination: BigInt64Array, backed by: SharedArrayBuffer
+PASS Invalid encodeInto() destination: BigUint64Array, backed by: ArrayBuffer
+PASS Invalid encodeInto() destination: BigUint64Array, backed by: SharedArrayBuffer
</ins><span class="cx"> PASS Invalid encodeInto() destination: Float32Array, backed by: ArrayBuffer
</span><span class="cx"> PASS Invalid encodeInto() destination: Float32Array, backed by: SharedArrayBuffer
</span><span class="cx"> PASS Invalid encodeInto() destination: Float64Array, backed by: ArrayBuffer
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsencodingw3cimportlog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/encoding/w3c-import.log (279768 => 279769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/encoding/w3c-import.log        2021-07-09 00:12:30 UTC (rev 279768)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/encoding/w3c-import.log   2021-07-09 00:38:41 UTC (rev 279769)
</span><span class="lines">@@ -23,6 +23,7 @@
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/encoding/bom-handling.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/encoding/bom-handling.html.headers
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/encoding/encodeInto.any.js
</span><ins>+/LayoutTests/imported/w3c/web-platform-tests/encoding/eof-shift_jis-expected.html
</ins><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/encoding/eof-shift_jis.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/encoding/eof-utf-8-one-expected.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/encoding/eof-utf-8-one.html
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsecloneanyexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-clone.any-expected.txt (279768 => 279769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-clone.any-expected.txt     2021-07-09 00:12:30 UTC (rev 279768)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-clone.any-expected.txt        2021-07-09 00:38:41 UTC (rev 279769)
</span><span class="lines">@@ -14,6 +14,8 @@
</span><span class="cx"> PASS Check response clone use structureClone for teed ReadableStreams (Uint8ClampedArraychunk)
</span><span class="cx"> PASS Check response clone use structureClone for teed ReadableStreams (Uint16Arraychunk)
</span><span class="cx"> PASS Check response clone use structureClone for teed ReadableStreams (Uint32Arraychunk)
</span><ins>+PASS Check response clone use structureClone for teed ReadableStreams (BigInt64Arraychunk)
+PASS Check response clone use structureClone for teed ReadableStreams (BigUint64Arraychunk)
</ins><span class="cx"> PASS Check response clone use structureClone for teed ReadableStreams (Float32Arraychunk)
</span><span class="cx"> PASS Check response clone use structureClone for teed ReadableStreams (Float64Arraychunk)
</span><span class="cx"> FAIL Check response clone use structureClone for teed ReadableStreams (DataViewchunk) assert_array_equals: Cloned buffer chunks have the same content value is object "[object DataView]", expected array
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsecloneanyjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-clone.any.js (279768 => 279769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-clone.any.js       2021-07-09 00:12:30 UTC (rev 279768)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-clone.any.js  2021-07-09 00:38:41 UTC (rev 279769)
</span><span class="lines">@@ -119,6 +119,8 @@
</span><span class="cx"> testReadableStreamClone(new Uint8ClampedArray(arrayBuffer), "Uint8ClampedArray");
</span><span class="cx"> testReadableStreamClone(new Uint16Array(arrayBuffer, 2), "Uint16Array");
</span><span class="cx"> testReadableStreamClone(new Uint32Array(arrayBuffer), "Uint32Array");
</span><ins>+testReadableStreamClone(typeof BigInt64Array === "function" ? new BigInt64Array(arrayBuffer) : undefined, "BigInt64Array");
+testReadableStreamClone(typeof BigUint64Array === "function" ? new BigUint64Array(arrayBuffer) : undefined, "BigUint64Array");
</ins><span class="cx"> testReadableStreamClone(new Float32Array(arrayBuffer), "Float32Array");
</span><span class="cx"> testReadableStreamClone(new Float64Array(arrayBuffer), "Float64Array");
</span><span class="cx"> testReadableStreamClone(new DataView(arrayBuffer, 2, 8), "DataView");
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsecloneanyworkerexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-clone.any.worker-expected.txt (279768 => 279769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-clone.any.worker-expected.txt      2021-07-09 00:12:30 UTC (rev 279768)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-clone.any.worker-expected.txt 2021-07-09 00:38:41 UTC (rev 279769)
</span><span class="lines">@@ -14,6 +14,8 @@
</span><span class="cx"> PASS Check response clone use structureClone for teed ReadableStreams (Uint8ClampedArraychunk)
</span><span class="cx"> PASS Check response clone use structureClone for teed ReadableStreams (Uint16Arraychunk)
</span><span class="cx"> PASS Check response clone use structureClone for teed ReadableStreams (Uint32Arraychunk)
</span><ins>+PASS Check response clone use structureClone for teed ReadableStreams (BigInt64Arraychunk)
+PASS Check response clone use structureClone for teed ReadableStreams (BigUint64Arraychunk)
</ins><span class="cx"> PASS Check response clone use structureClone for teed ReadableStreams (Float32Arraychunk)
</span><span class="cx"> PASS Check response clone use structureClone for teed ReadableStreams (Float64Arraychunk)
</span><span class="cx"> FAIL Check response clone use structureClone for teed ReadableStreams (DataViewchunk) assert_array_equals: Cloned buffer chunks have the same content value is object "[object DataView]", expected array
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (279768 => 279769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-07-09 00:12:30 UTC (rev 279768)
+++ trunk/Source/WebCore/ChangeLog      2021-07-09 00:38:41 UTC (rev 279769)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2021-07-08  Yusuke Suzuki  <ysuzuki@apple.com>
+
+        Fix StructuredClone for streams to handle BigInt64Array / BigUint64Array
+        https://bugs.webkit.org/show_bug.cgi?id=227571
+
+        Reviewed by Chris Dumez.
+
+        While we already support BigInt64Array / BigUint64Array handling even in DOM code,
+        we lack support of them only in fetch's structuredClone code (which is specialized one
+        to make it fast by bypassing serialization / deserialization).
+
+        This patch fixes the issue to complete BigInt64Array / BigUint64Array in all DOM code.
+
+        * Modules/streams/ReadableStreamInternals.js:
+        (readableStreamTeePullFunction):
+        (doStructuredClone): Deleted.
+        * bindings/js/JSDOMGlobalObject.cpp:
+        (WebCore::JSDOMGlobalObject::addBuiltinGlobals):
+        * bindings/js/StructuredClone.cpp:
+        (WebCore::JSC_DEFINE_HOST_FUNCTION):
+        * bindings/js/StructuredClone.h:
+        * bindings/js/WebCoreBuiltinNames.h:
+
</ins><span class="cx"> 2021-07-08  Chris Dumez  <cdumez@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Make sure SVG SMIL animations do not run in processes without any pages
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesstreamsReadableStreamInternalsjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/streams/ReadableStreamInternals.js (279768 => 279769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/streams/ReadableStreamInternals.js  2021-07-09 00:12:30 UTC (rev 279768)
+++ trunk/Source/WebCore/Modules/streams/ReadableStreamInternals.js     2021-07-09 00:38:41 UTC (rev 279769)
</span><span class="lines">@@ -435,22 +435,6 @@
</span><span class="cx">     return [branch1, branch2];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function doStructuredClone(object)
-{
-    "use strict";
-
-    // FIXME: We should implement http://w3c.github.io/html/infrastructure.html#ref-for-structured-clone-4
-    // Implementation is currently limited to ArrayBuffer/ArrayBufferView to meet Fetch API needs.
-
-    if (object instanceof @ArrayBuffer)
-        return @structuredCloneArrayBuffer(object);
-
-    if (@ArrayBuffer.@isView(object))
-        return @structuredCloneArrayBufferView(object);
-
-    @throwTypeError("structuredClone not implemented for: " + object);
-}
-
</del><span class="cx"> function readableStreamTeePullFunction(teeState, reader, shouldClone)
</span><span class="cx"> {
</span><span class="cx">     "use strict";
</span><span class="lines">@@ -473,7 +457,7 @@
</span><span class="cx">             if (!teeState.canceled1)
</span><span class="cx">                 @readableStreamDefaultControllerEnqueue(teeState.branch1.@readableStreamController, result.value);
</span><span class="cx">             if (!teeState.canceled2)
</span><del>-                @readableStreamDefaultControllerEnqueue(teeState.branch2.@readableStreamController, shouldClone ? @doStructuredClone(result.value) : result.value);
</del><ins>+                @readableStreamDefaultControllerEnqueue(teeState.branch2.@readableStreamController, shouldClone ? @structuredCloneForStream(result.value) : result.value);
</ins><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMGlobalObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp (279768 => 279769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp   2021-07-09 00:12:30 UTC (rev 279768)
+++ trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp      2021-07-09 00:38:41 UTC (rev 279769)
</span><span class="lines">@@ -195,10 +195,8 @@
</span><span class="cx">             JSFunction::create(vm, this, 2, String(), whenSignalAborted), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
</span><span class="cx">         JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().cloneArrayBufferPrivateName(),
</span><span class="cx">             JSFunction::create(vm, this, 3, String(), cloneArrayBuffer), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
</span><del>-        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().structuredCloneArrayBufferPrivateName(),
-            JSFunction::create(vm, this, 1, String(), structuredCloneArrayBuffer), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
-        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().structuredCloneArrayBufferViewPrivateName(),
-            JSFunction::create(vm, this, 1, String(), structuredCloneArrayBufferView), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
</del><ins>+        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().structuredCloneForStreamPrivateName(),
+            JSFunction::create(vm, this, 1, String(), structuredCloneForStream), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
</ins><span class="cx">         JSDOMGlobalObject::GlobalPropertyInfo(vm.propertyNames->builtinNames().ArrayBufferPrivateName(), arrayBufferConstructor(), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
</span><span class="cx">         JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().streamClosedPrivateName(), jsNumber(1), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
</span><span class="cx">         JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().streamClosingPrivateName(), jsNumber(2), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsStructuredClonecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/StructuredClone.cpp (279768 => 279769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/StructuredClone.cpp     2021-07-09 00:12:30 UTC (rev 279768)
+++ trunk/Source/WebCore/bindings/js/StructuredClone.cpp        2021-07-09 00:38:41 UTC (rev 279769)
</span><span class="lines">@@ -67,53 +67,47 @@
</span><span class="cx">     return cloneArrayBufferImpl(globalObject, callFrame, CloneMode::Partial);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSC_DEFINE_HOST_FUNCTION(structuredCloneArrayBuffer, (JSGlobalObject* globalObject, CallFrame* callFrame))
</del><ins>+JSC_DEFINE_HOST_FUNCTION(structuredCloneForStream, (JSGlobalObject* globalObject, CallFrame* callFrame))
</ins><span class="cx"> {
</span><del>-    return cloneArrayBufferImpl(globalObject, callFrame, CloneMode::Full);
-}
-
-JSC_DEFINE_HOST_FUNCTION(structuredCloneArrayBufferView, (JSGlobalObject* globalObject, CallFrame* callFrame))
-{
</del><span class="cx">     ASSERT(callFrame);
</span><span class="cx">     ASSERT(callFrame->argumentCount());
</span><span class="cx"> 
</span><del>-    JSValue value = callFrame->uncheckedArgument(0);
</del><span class="cx">     VM& vm = globalObject->vm();
</span><del>-    auto* bufferView = jsDynamicCast<JSArrayBufferView*>(vm, value);
-    ASSERT(bufferView);
</del><ins>+    auto scope = DECLARE_THROW_SCOPE(vm);
</ins><span class="cx"> 
</span><del>-    auto* buffer = bufferView->unsharedBuffer();
-    if (!buffer) {
-        auto scope = DECLARE_THROW_SCOPE(vm);
-        throwDataCloneError(*globalObject, scope);
-        return { };
</del><ins>+    JSValue value = callFrame->uncheckedArgument(0);
+
+    if (value.inherits<JSArrayBuffer>(vm))
+        RELEASE_AND_RETURN(scope, cloneArrayBufferImpl(globalObject, callFrame, CloneMode::Full));
+
+    if (value.inherits<JSArrayBufferView>(vm)) {
+        auto* bufferView = jsCast<JSArrayBufferView*>(value);
+        ASSERT(bufferView);
+
+        auto* buffer = bufferView->unsharedBuffer();
+        if (!buffer) {
+            throwDataCloneError(*globalObject, scope);
+            return { };
+        }
+        auto bufferClone = ArrayBuffer::tryCreate(buffer->data(), buffer->byteLength());
+        Structure* structure = bufferView->structure(vm);
+
+#define CLONE_TYPED_ARRAY(name) \
+        do { \
+            if (bufferView->inherits<JS##name##Array>(vm)) \
+                RELEASE_AND_RETURN(scope, JSValue::encode(JS##name##Array::create(globalObject, structure, WTFMove(bufferClone), bufferView->byteOffset(), bufferView->length()))); \
+        } while (0);
+
+        FOR_EACH_TYPED_ARRAY_TYPE_EXCLUDING_DATA_VIEW(CLONE_TYPED_ARRAY)
+
+#undef CLONE_TYPED_ARRAY
+
+        if (value.inherits<JSDataView>(vm))
+            RELEASE_AND_RETURN(scope, JSValue::encode(JSDataView::create(globalObject, structure, WTFMove(bufferClone), bufferView->byteOffset(), bufferView->length())));
</ins><span class="cx">     }
</span><del>-    auto bufferClone = ArrayBuffer::tryCreate(buffer->data(), buffer->byteLength());
-    Structure* structure = bufferView->structure(vm);
</del><span class="cx"> 
</span><del>-    if (jsDynamicCast<JSInt8Array*>(vm, value))
-        return JSValue::encode(JSInt8Array::create(globalObject, structure, WTFMove(bufferClone), bufferView->byteOffset(), bufferView->length()));
-    if (jsDynamicCast<JSInt16Array*>(vm, value))
-        return JSValue::encode(JSInt16Array::create(globalObject, structure, WTFMove(bufferClone), bufferView->byteOffset(), bufferView->length()));
-    if (jsDynamicCast<JSInt32Array*>(vm, value))
-        return JSValue::encode(JSInt32Array::create(globalObject, structure, WTFMove(bufferClone), bufferView->byteOffset(), bufferView->length()));
-    if (jsDynamicCast<JSUint8Array*>(vm, value))
-        return JSValue::encode(JSUint8Array::create(globalObject, structure, WTFMove(bufferClone), bufferView->byteOffset(), bufferView->length()));
-    if (jsDynamicCast<JSUint8ClampedArray*>(vm, value))
-        return JSValue::encode(JSUint8ClampedArray::create(globalObject, structure, WTFMove(bufferClone), bufferView->byteOffset(), bufferView->length()));
-    if (jsDynamicCast<JSUint16Array*>(vm, value))
-        return JSValue::encode(JSUint16Array::create(globalObject, structure, WTFMove(bufferClone), bufferView->byteOffset(), bufferView->length()));
-    if (jsDynamicCast<JSUint32Array*>(vm, value))
-        return JSValue::encode(JSUint32Array::create(globalObject, structure, WTFMove(bufferClone), bufferView->byteOffset(), bufferView->length()));
-    if (jsDynamicCast<JSFloat32Array*>(vm, value))
-        return JSValue::encode(JSFloat32Array::create(globalObject, structure, WTFMove(bufferClone), bufferView->byteOffset(), bufferView->length()));
-    if (jsDynamicCast<JSFloat64Array*>(vm, value))
-        return JSValue::encode(JSFloat64Array::create(globalObject, structure, WTFMove(bufferClone), bufferView->byteOffset(), bufferView->length()));
-    if (jsDynamicCast<JSDataView*>(vm, value))
-        return JSValue::encode(JSDataView::create(globalObject, structure, WTFMove(bufferClone), bufferView->byteOffset(), bufferView->length()));
-
-    ASSERT_NOT_REACHED();
-    return JSValue::encode(jsUndefined());
</del><ins>+    throwTypeError(globalObject, scope, "structuredClone not implemented for non-ArrayBuffer / non-ArrayBufferView"_s);
+    return { };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsStructuredCloneh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/StructuredClone.h (279768 => 279769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/StructuredClone.h       2021-07-09 00:12:30 UTC (rev 279768)
+++ trunk/Source/WebCore/bindings/js/StructuredClone.h  2021-07-09 00:38:41 UTC (rev 279769)
</span><span class="lines">@@ -35,7 +35,6 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> JSC_DECLARE_HOST_FUNCTION(cloneArrayBuffer);
</span><del>-JSC_DECLARE_HOST_FUNCTION(structuredCloneArrayBuffer);
-JSC_DECLARE_HOST_FUNCTION(structuredCloneArrayBufferView);
</del><ins>+JSC_DECLARE_HOST_FUNCTION(structuredCloneForStream);
</ins><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsWebCoreBuiltinNamesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h (279768 => 279769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h   2021-07-09 00:12:30 UTC (rev 279768)
+++ trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h      2021-07-09 00:38:41 UTC (rev 279769)
</span><span class="lines">@@ -452,8 +452,7 @@
</span><span class="cx">     macro(streamReadable) \
</span><span class="cx">     macro(streamWaiting) \
</span><span class="cx">     macro(streamWritable) \
</span><del>-    macro(structuredCloneArrayBuffer) \
-    macro(structuredCloneArrayBufferView) \
</del><ins>+    macro(structuredCloneForStream) \
</ins><span class="cx">     macro(timeline) \
</span><span class="cx">     macro(top) \
</span><span class="cx">     macro(textDecoderStreamDecoder) \
</span></span></pre>
</div>
</div>

</body>
</html>