diff --git a/testing/web-platform/tests/streams/readable-byte-streams/general.any.js b/testing/web-platform/tests/streams/readable-byte-streams/general.any.js index e0ab01f88140..19da47ba3406 100644 --- a/testing/web-platform/tests/streams/readable-byte-streams/general.any.js +++ b/testing/web-platform/tests/streams/readable-byte-streams/general.any.js @@ -6451,7 +6451,6 @@ controller c ; } -async pull ( ) @@ -6479,7 +6478,6 @@ byobRequest const transferredView = -await transferArrayBufferView ( controller @@ -16287,7 +16285,6 @@ pullCalledPromise const transferredView = -await transferArrayBufferView ( controller @@ -16594,7 +16591,6 @@ pullCalledPromise const transferredView = -await transferArrayBufferView ( controller diff --git a/testing/web-platform/tests/streams/readable-byte-streams/patched-global.any.js b/testing/web-platform/tests/streams/readable-byte-streams/patched-global.any.js new file mode 100644 index 000000000000..03d70bb17639 --- /dev/null +++ b/testing/web-platform/tests/streams/readable-byte-streams/patched-global.any.js @@ -0,0 +1,374 @@ +' +use +strict +' +; +promise_test +( +async +( +t +) += +> +{ +let +controller +; +const +rs += +new +ReadableStream +( +{ +type +: +' +bytes +' +start +( +c +) +{ +controller += +c +; +} +} +) +; +const +reader += +rs +. +getReader +( +{ +mode +: +' +byob +' +} +) +; +const +length += +0x4000 +; +const +buffer += +new +ArrayBuffer +( +length +) +; +const +bigArray += +new +BigUint64Array +( +buffer +length +- +8 +1 +) +; +const +read1 += +reader +. +read +( +new +Uint8Array +( +new +ArrayBuffer +( +0x100 +) +) +) +; +const +read2 += +reader +. +read +( +bigArray +) +; +let +flag += +false +; +Object +. +defineProperty +( +Object +. +prototype +' +then +' +{ +get +: +t +. +step_func +( +( +) += +> +{ +if +( +! +flag +) +{ +flag += +true +; +assert_equals +( +controller +. +byobRequest +null +' +byobRequest +should +be +null +after +filling +both +views +' +) +; +} +} +) +configurable +: +true +} +) +; +t +. +add_cleanup +( +( +) += +> +{ +delete +Object +. +prototype +. +then +; +} +) +; +controller +. +enqueue +( +new +Uint8Array +( +0x110 +) +. +fill +( +0x42 +) +) +; +assert_true +( +flag +' +patched +then +( +) +should +be +called +' +) +; +const +result1 += +await +read1 +; +assert_false +( +result1 +. +done +' +result1 +. +done +' +) +; +assert_typed_array_equals +( +result1 +. +value +new +Uint8Array +( +0x100 +) +. +fill +( +0x42 +) +' +result1 +. +value +' +) +; +const +result2 += +await +read2 +; +assert_false +( +result2 +. +done +' +result2 +. +done +' +) +; +assert_equals +( +result2 +. +value +. +constructor +BigUint64Array +' +result2 +. +value +constructor +' +) +; +assert_equals +( +result2 +. +value +. +byteOffset +length +- +8 +' +result2 +. +value +byteOffset +' +) +; +assert_equals +( +result2 +. +value +. +length +1 +' +result2 +. +value +length +' +) +; +assert_array_equals +( +[ +. +. +. +result2 +. +value +] +[ +0x42424242_42424242n +] +' +result2 +. +value +contents +' +) +; +} +' +Patched +then +( +) +sees +byobRequest +after +filling +all +pending +pull +- +into +descriptors +' +) +; diff --git a/testing/web-platform/tests/streams/resources/rs-utils.js b/testing/web-platform/tests/streams/resources/rs-utils.js index f311ec993c75..96d88d7ee3ef 100644 --- a/testing/web-platform/tests/streams/resources/rs-utils.js +++ b/testing/web-platform/tests/streams/resources/rs-utils.js @@ -965,82 +965,19 @@ transferArrayBufferView view ) { -const -noopByteStream -= -new -ReadableStream -( -{ -type -: -' -bytes -' -pull -( -c -) -{ -c -. -byobRequest -. -respond +return +structuredClone ( -c -. -byobRequest -. view -. -byteLength -) -; -c -. -close -( -) -; -} -} -) -; -const -reader -= -noopByteStream -. -getReader -( { -mode +transfer : -' -byob -' -} -) -; -return -reader -. -read -( +[ view -) -. -then -( -( -result -) -= -> -result . -value +buffer +] +} ) ; }