summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/streams/readable-streams/read-task-handling.window.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/streams/readable-streams/read-task-handling.window.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/streams/readable-streams/read-task-handling.window.js')
-rw-r--r--testing/web-platform/tests/streams/readable-streams/read-task-handling.window.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/testing/web-platform/tests/streams/readable-streams/read-task-handling.window.js b/testing/web-platform/tests/streams/readable-streams/read-task-handling.window.js
new file mode 100644
index 0000000000..2edc0ddddf
--- /dev/null
+++ b/testing/web-platform/tests/streams/readable-streams/read-task-handling.window.js
@@ -0,0 +1,46 @@
+// META: global=window,worker
+'use strict';
+
+function performMicrotaskCheckpoint() {
+ document.createNodeIterator(document, -1, {
+ acceptNode() {
+ return NodeFilter.FILTER_ACCEPT;
+ }
+ }).nextNode();
+}
+
+test(() => {
+ // Add a getter for "then" that will incidentally be invoked
+ // during promise resolution.
+ Object.prototype.__defineGetter__('then', () => {
+ // Clean up behind ourselves.
+ delete Object.prototype.then;
+
+ // This promise should (like all promises) be resolved
+ // asynchronously.
+ var executed = false;
+ Promise.resolve().then(_ => { executed = true; });
+
+ // This shouldn't run microtasks! They should only run
+ // after the fetch is resolved.
+ performMicrotaskCheckpoint();
+
+ // The fulfill handler above shouldn't have run yet. If it has run,
+ // throw to reject this promise and fail the test.
+ assert_false(executed, "shouldn't have run microtasks yet");
+
+ // Otherwise act as if there's no "then" property so the promise
+ // fulfills and the test passes.
+ return undefined;
+ });
+
+ const readable = new ReadableStream({
+ pull(c) {
+ c.enqueue({});
+ }
+ }, { highWaterMark: 0 });
+
+ // Create a read request, incidentally resolving a promise with an
+ // object value, thereby invoking the getter installed above.
+ readable.getReader().read();
+}, "reading from a stream should occur in a microtask scope");