summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/streams/readable-streams/garbage-collection.any.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/streams/readable-streams/garbage-collection.any.js
parentInitial commit. (diff)
downloadfirefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz
firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/streams/readable-streams/garbage-collection.any.js')
-rw-r--r--testing/web-platform/tests/streams/readable-streams/garbage-collection.any.js71
1 files changed, 71 insertions, 0 deletions
diff --git a/testing/web-platform/tests/streams/readable-streams/garbage-collection.any.js b/testing/web-platform/tests/streams/readable-streams/garbage-collection.any.js
new file mode 100644
index 0000000000..e578176777
--- /dev/null
+++ b/testing/web-platform/tests/streams/readable-streams/garbage-collection.any.js
@@ -0,0 +1,71 @@
+// META: global=window,worker
+// META: script=../resources/test-utils.js
+// META: script=/common/gc.js
+'use strict';
+
+promise_test(async () => {
+
+ let controller;
+ new ReadableStream({
+ start(c) {
+ controller = c;
+ }
+ });
+
+ await garbageCollect();
+
+ return delay(50).then(() => {
+ controller.close();
+ assert_throws_js(TypeError, () => controller.close(), 'close should throw a TypeError the second time');
+ controller.error();
+ });
+
+}, 'ReadableStreamController methods should continue working properly when scripts lose their reference to the ' +
+ 'readable stream');
+
+promise_test(async () => {
+
+ let controller;
+
+ const closedPromise = new ReadableStream({
+ start(c) {
+ controller = c;
+ }
+ }).getReader().closed;
+
+ await garbageCollect();
+
+ return delay(50).then(() => controller.close()).then(() => closedPromise);
+
+}, 'ReadableStream closed promise should fulfill even if the stream and reader JS references are lost');
+
+promise_test(async t => {
+
+ const theError = new Error('boo');
+ let controller;
+
+ const closedPromise = new ReadableStream({
+ start(c) {
+ controller = c;
+ }
+ }).getReader().closed;
+
+ await garbageCollect();
+
+ return delay(50).then(() => controller.error(theError))
+ .then(() => promise_rejects_exactly(t, theError, closedPromise));
+
+}, 'ReadableStream closed promise should reject even if stream and reader JS references are lost');
+
+promise_test(async () => {
+
+ const rs = new ReadableStream({});
+
+ rs.getReader();
+
+ await garbageCollect();
+
+ return delay(50).then(() => assert_throws_js(TypeError, () => rs.getReader(),
+ 'old reader should still be locking the stream even after garbage collection'));
+
+}, 'Garbage-collecting a ReadableStreamDefaultReader should not unlock its stream');