diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /dom/workers/test/test_readableStream_when_closing.html | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/workers/test/test_readableStream_when_closing.html')
-rw-r--r-- | dom/workers/test/test_readableStream_when_closing.html | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/dom/workers/test/test_readableStream_when_closing.html b/dom/workers/test/test_readableStream_when_closing.html new file mode 100644 index 0000000000..24d5bf3821 --- /dev/null +++ b/dom/workers/test/test_readableStream_when_closing.html @@ -0,0 +1,61 @@ +<!DOCTYPE HTML> +<html> +<head> + <meta charset="utf-8"> + <title>Test for ReadableStream+fetch when the worker is closing</title> + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?> +</head> +<body> + <script> + +function workerCode() { + onmessage = () => { + const BIG_BUFFER_SIZE = 1000000; + const fibStream = new ReadableStream({ + start(controller) {}, + + pull(controller) { + const buffer = new Uint8Array(BIG_BUFFER_SIZE); + buffer.fill(42); + controller.enqueue(buffer); + } + }); + + const r = new Response(fibStream); + + const p = r.blob(); + self.postMessage("reading"); + + p.then(() => { + // really? + }); + } +} + +SimpleTest.waitForExplicitFinish(); + +const b = new Blob([workerCode+'workerCode();']); +const url = URL.createObjectURL(b); +const w = new Worker(url); +w.onmessage = function(e) { + ok(true, 'Worker is reading'); + + const wdm = Cc["@mozilla.org/dom/workers/workerdebuggermanager;1"]. + getService(Ci.nsIWorkerDebuggerManager); + wdm.addListener({ + onUnregister (dbg) { + if (dbg.url == url) { + ok(true, "Debugger with url " + url + " should be unregistered."); + wdm.removeListener(this); + SimpleTest.finish(); + } + } + }); + + w.terminate(); +} +w.postMessage("start"); + </script> +</body> +</html> |