diff --git a/Cargo.lock b/Cargo.lock index 6b740fc663d5e6..379a165286b54b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1793,9 +1793,10 @@ dependencies = [ "http", "hyper 0.14.27", "once_cell", + "rustls", + "rustls-tokio-stream", "serde", "tokio", - "tokio-rustls", ] [[package]] @@ -4538,6 +4539,17 @@ dependencies = [ "base64 0.21.4", ] +[[package]] +name = "rustls-tokio-stream" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cfe0539bec890c4c4e9365f5dad49b609cabe9332213876d1110589c5be8df0" +dependencies = [ + "futures", + "rustls", + "tokio", +] + [[package]] name = "rustls-webpki" version = "0.101.6" diff --git a/Cargo.toml b/Cargo.toml index b28813f50f5e91..7c2c0f5a9471c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -124,6 +124,7 @@ ring = "=0.16.20" rusqlite = { version = "=0.29.0", features = ["unlock_notify", "bundled"] } rustls = "0.21.0" rustls-pemfile = "1.0.0" +rustls-tokio-stream = "0.2.1" rustls-webpki = "0.101.4" rustls-native-certs = "0.6.2" webpki-roots = "0.25.2" diff --git a/cli/tests/testdata/run/websocket_test.ts b/cli/tests/testdata/run/websocket_test.ts index d80f03c92aa126..43db15cceeb1d5 100644 --- a/cli/tests/testdata/run/websocket_test.ts +++ b/cli/tests/testdata/run/websocket_test.ts @@ -163,7 +163,7 @@ Deno.test("websocket error", async () => { // Error message got changed because we don't use warp in test_util assertEquals( err.message, - "InvalidData: received corrupt message of type InvalidContentType", + "InvalidData: invalid data", ); promise1.resolve(); }; diff --git a/cli/tests/unit/websocket_test.ts b/cli/tests/unit/websocket_test.ts index 11f0fd7dc314f0..4249eb4cee071b 100644 --- a/cli/tests/unit/websocket_test.ts +++ b/cli/tests/unit/websocket_test.ts @@ -21,7 +21,7 @@ Deno.test(async function websocketConstructorTakeURLObjectAsParameter() { const promise = deferred(); const ws = new WebSocket(new URL("ws://localhost:4242/")); assertEquals(ws.url, "ws://localhost:4242/"); - ws.onerror = () => fail(); + ws.onerror = (e) => promise.reject(e); ws.onopen = () => ws.close(); ws.onclose = () => { promise.resolve(); @@ -29,13 +29,69 @@ Deno.test(async function websocketConstructorTakeURLObjectAsParameter() { await promise; }); +// Ignored until split websocket +Deno.test({ ignore: true }, async function websocketSendLargePacket() { + const promise = deferred(); + const ws = new WebSocket(new URL("wss://localhost:4243/")); + assertEquals(ws.url, "wss://localhost:4243/"); + ws.onerror = (e) => promise.reject(e); + ws.onopen = () => { + ws.send("a".repeat(65000)); + }; + ws.onmessage = () => { + ws.close(); + }; + ws.onclose = () => { + promise.resolve(); + }; + await promise; +}); + +// Ignored until split websocket +Deno.test({ ignore: true }, async function websocketSendLargeBinaryPacket() { + const promise = deferred(); + const ws = new WebSocket(new URL("wss://localhost:4243/")); + assertEquals(ws.url, "wss://localhost:4243/"); + ws.onerror = (e) => promise.reject(e); + ws.onopen = () => { + ws.send(new Uint8Array(65000)); + }; + ws.onmessage = (msg) => { + console.log(msg); + ws.close(); + }; + ws.onclose = () => { + promise.resolve(); + }; + await promise; +}); + +// Ignored until split websocket +Deno.test({ ignore: true }, async function websocketSendLargeBlobPacket() { + const promise = deferred(); + const ws = new WebSocket(new URL("wss://localhost:4243/")); + assertEquals(ws.url, "wss://localhost:4243/"); + ws.onerror = (e) => promise.reject(e); + ws.onopen = () => { + ws.send(new Blob(["a".repeat(10)])); + }; + ws.onmessage = (msg) => { + console.log(msg); + ws.close(); + }; + ws.onclose = () => { + promise.resolve(); + }; + await promise; +}); + // https://github.com/denoland/deno/pull/17762 // https://github.com/denoland/deno/issues/17761 Deno.test(async function websocketPingPong() { const promise = deferred(); const ws = new WebSocket("ws://localhost:4245/"); assertEquals(ws.url, "ws://localhost:4245/"); - ws.onerror = () => fail(); + ws.onerror = (e) => promise.reject(e); ws.onmessage = (e) => { ws.send(e.data); }; diff --git a/ext/websocket/Cargo.toml b/ext/websocket/Cargo.toml index a144d016390e5a..b7d95ba9a8e59e 100644 --- a/ext/websocket/Cargo.toml +++ b/ext/websocket/Cargo.toml @@ -22,6 +22,7 @@ fastwebsockets = { workspace = true, features = ["upgrade"] } http.workspace = true hyper = { workspace = true, features = ["backports"] } once_cell.workspace = true +rustls.workspace = true +rustls-tokio-stream.workspace = true serde.workspace = true tokio.workspace = true -tokio-rustls.workspace = true diff --git a/ext/websocket/lib.rs b/ext/websocket/lib.rs index 48a22431bb46ff..34f9ec5e3cb99a 100644 --- a/ext/websocket/lib.rs +++ b/ext/websocket/lib.rs @@ -30,6 +30,9 @@ use http::Request; use http::Uri; use hyper::Body; use once_cell::sync::Lazy; +use rustls::RootCertStore; +use rustls::ServerName; +use rustls_tokio_stream::TlsStream; use serde::Serialize; use std::borrow::Cow; use std::cell::Cell; @@ -37,15 +40,13 @@ use std::cell::RefCell; use std::convert::TryFrom; use std::fmt; use std::future::Future; +use std::num::NonZeroUsize; use std::path::PathBuf; use std::rc::Rc; use std::sync::Arc; use tokio::io::AsyncRead; use tokio::io::AsyncWrite; use tokio::net::TcpStream; -use tokio_rustls::rustls::RootCertStore; -use tokio_rustls::rustls::ServerName; -use tokio_rustls::TlsConnector; use fastwebsockets::CloseCode; use fastwebsockets::FragmentCollector; @@ -281,11 +282,16 @@ where unsafely_ignore_certificate_errors, None, )?; - let tls_connector = TlsConnector::from(Arc::new(tls_config)); let dnsname = ServerName::try_from(domain.as_str()) .map_err(|_| invalid_hostname(domain))?; - let tls_socket = tls_connector.connect(dnsname, tcp_socket).await?; - handshake(cancel_resource, request, tls_socket).await? + let mut tls_connector = TlsStream::new_client_side( + tcp_socket, + tls_config.into(), + dnsname, + NonZeroUsize::new(65536), + ); + let _hs = tls_connector.handshake().await?; + handshake(cancel_resource, request, tls_connector).await? } _ => unreachable!(), }; @@ -630,7 +636,8 @@ pub async fn op_ws_next_event( let mut ws = RcRef::map(&resource, |r| &r.ws).borrow_mut().await; loop { - let val = match ws.read_frame().await { + let val = ws.read_frame().await; + let val = match val { Ok(val) => val, Err(err) => { // No message was received, socket closed while we waited. diff --git a/test_util/src/lib.rs b/test_util/src/lib.rs index 07ed558227a6d2..a971e3bb2943c0 100644 --- a/test_util/src/lib.rs +++ b/test_util/src/lib.rs @@ -338,6 +338,7 @@ async fn echo_websocket_handler( match frame.opcode { fastwebsockets::OpCode::Close => break, fastwebsockets::OpCode::Text | fastwebsockets::OpCode::Binary => { + println!("got frame! {}", frame.payload.len()); ws.write_frame(frame).await.unwrap(); } _ => {} diff --git a/tools/wpt.ts b/tools/wpt.ts index 07f6b6ba94e2a2..f81807a8e7787b 100755 --- a/tools/wpt.ts +++ b/tools/wpt.ts @@ -597,7 +597,7 @@ function reportVariation(result: TestResult, expectation: boolean | string[]) { const expectFail = expectation === false; const failReason = result.status !== 0 - ? "runner failed during test" + ? `runner failed during test: >>>>>>>\n${result.stderr}\n<<<<<<<\n` : "the event loop run out of tasks during the test"; console.log( `\nfile result: ${ diff --git a/tools/wpt/expectation.json b/tools/wpt/expectation.json index b6443f531caab5..917e0fb6d4b770 100644 --- a/tools/wpt/expectation.json +++ b/tools/wpt/expectation.json @@ -7762,128 +7762,88 @@ }, "websockets": { "Close-1000-reason.any.html?default": true, - "Close-1000-reason.any.html?wpt_flags=h2": false, "Close-1000-reason.any.html?wss": true, "Close-1000-reason.any.worker.html?default": true, - "Close-1000-reason.any.worker.html?wpt_flags=h2": false, "Close-1000-reason.any.worker.html?wss": true, "Close-1000-verify-code.any.html?default": true, - "Close-1000-verify-code.any.html?wpt_flags=h2": false, "Close-1000-verify-code.any.html?wss": true, "Close-1000-verify-code.any.worker.html?default": true, - "Close-1000-verify-code.any.worker.html?wpt_flags=h2": false, "Close-1000-verify-code.any.worker.html?wss": true, "Close-1000.any.html?default": true, - "Close-1000.any.html?wpt_flags=h2": false, "Close-1000.any.html?wss": true, "Close-1000.any.worker.html?default": true, - "Close-1000.any.worker.html?wpt_flags=h2": false, "Close-1000.any.worker.html?wss": true, "Close-1005-verify-code.any.html?default": true, - "Close-1005-verify-code.any.html?wpt_flags=h2": false, "Close-1005-verify-code.any.html?wss": true, "Close-1005-verify-code.any.worker.html?default": true, - "Close-1005-verify-code.any.worker.html?wpt_flags=h2": false, "Close-1005-verify-code.any.worker.html?wss": true, "Close-1005.any.html?default": true, - "Close-1005.any.html?wpt_flags=h2": false, "Close-1005.any.html?wss": true, "Close-1005.any.worker.html?default": true, - "Close-1005.any.worker.html?wpt_flags=h2": false, "Close-1005.any.worker.html?wss": true, "Close-2999-reason.any.html?default": true, - "Close-2999-reason.any.html?wpt_flags=h2": false, "Close-2999-reason.any.html?wss": true, "Close-2999-reason.any.worker.html?default": true, - "Close-2999-reason.any.worker.html?wpt_flags=h2": false, "Close-2999-reason.any.worker.html?wss": true, "Close-3000-reason.any.html?default": true, - "Close-3000-reason.any.html?wpt_flags=h2": false, "Close-3000-reason.any.html?wss": true, "Close-3000-reason.any.worker.html?default": true, - "Close-3000-reason.any.worker.html?wpt_flags=h2": false, "Close-3000-reason.any.worker.html?wss": true, "Close-3000-verify-code.any.html?default": true, - "Close-3000-verify-code.any.html?wpt_flags=h2": false, "Close-3000-verify-code.any.html?wss": true, "Close-3000-verify-code.any.worker.html?default": true, - "Close-3000-verify-code.any.worker.html?wpt_flags=h2": false, "Close-3000-verify-code.any.worker.html?wss": true, "Close-4999-reason.any.html?default": true, - "Close-4999-reason.any.html?wpt_flags=h2": false, "Close-4999-reason.any.html?wss": true, "Close-4999-reason.any.worker.html?default": true, - "Close-4999-reason.any.worker.html?wpt_flags=h2": false, "Close-4999-reason.any.worker.html?wss": true, "Close-Reason-124Bytes.any.html?default": true, - "Close-Reason-124Bytes.any.html?wpt_flags=h2": false, "Close-Reason-124Bytes.any.html?wss": true, "Close-Reason-124Bytes.any.worker.html?default": true, - "Close-Reason-124Bytes.any.worker.html?wpt_flags=h2": false, "Close-Reason-124Bytes.any.worker.html?wss": true, "Close-delayed.any.html?default": true, - "Close-delayed.any.html?wpt_flags=h2": false, "Close-delayed.any.html?wss": true, "Close-delayed.any.worker.html?default": true, - "Close-delayed.any.worker.html?wpt_flags=h2": false, "Close-delayed.any.worker.html?wss": true, "Close-onlyReason.any.html?default": true, - "Close-onlyReason.any.html?wpt_flags=h2": false, "Close-onlyReason.any.html?wss": true, "Close-onlyReason.any.worker.html?default": true, - "Close-onlyReason.any.worker.html?wpt_flags=h2": false, "Close-onlyReason.any.worker.html?wss": true, "Close-readyState-Closed.any.html?default": true, - "Close-readyState-Closed.any.html?wpt_flags=h2": false, "Close-readyState-Closed.any.html?wss": true, "Close-readyState-Closed.any.worker.html?default": true, - "Close-readyState-Closed.any.worker.html?wpt_flags=h2": false, "Close-readyState-Closed.any.worker.html?wss": true, "Close-readyState-Closing.any.html?default": true, - "Close-readyState-Closing.any.html?wpt_flags=h2": false, "Close-readyState-Closing.any.html?wss": true, "Close-readyState-Closing.any.worker.html?default": true, - "Close-readyState-Closing.any.worker.html?wpt_flags=h2": false, "Close-readyState-Closing.any.worker.html?wss": true, "Close-reason-unpaired-surrogates.any.html?default": true, - "Close-reason-unpaired-surrogates.any.html?wpt_flags=h2": false, "Close-reason-unpaired-surrogates.any.html?wss": true, "Close-reason-unpaired-surrogates.any.worker.html?default": true, - "Close-reason-unpaired-surrogates.any.worker.html?wpt_flags=h2": false, "Close-reason-unpaired-surrogates.any.worker.html?wss": true, "Close-server-initiated-close.any.html?default": true, - "Close-server-initiated-close.any.html?wpt_flags=h2": false, "Close-server-initiated-close.any.html?wss": true, "Close-server-initiated-close.any.worker.html?default": true, - "Close-server-initiated-close.any.worker.html?wpt_flags=h2": false, "Close-server-initiated-close.any.worker.html?wss": true, "Close-undefined.any.html?default": true, - "Close-undefined.any.html?wpt_flags=h2": false, "Close-undefined.any.html?wss": true, "Close-undefined.any.worker.html?default": true, - "Close-undefined.any.worker.html?wpt_flags=h2": false, "Close-undefined.any.worker.html?wss": true, "Create-asciiSep-protocol-string.any.html?default": true, - "Create-asciiSep-protocol-string.any.html?wpt_flags=h2": true, "Create-asciiSep-protocol-string.any.html?wss": true, "Create-asciiSep-protocol-string.any.worker.html?default": true, - "Create-asciiSep-protocol-string.any.worker.html?wpt_flags=h2": true, "Create-asciiSep-protocol-string.any.worker.html?wss": true, "Create-blocked-port.any.html?default": true, - "Create-blocked-port.any.html?wpt_flags=h2": [ "Basic check" ], "Create-blocked-port.any.html?wss": true, "Create-blocked-port.any.worker.html?default": true, - "Create-blocked-port.any.worker.html?wpt_flags=h2": [ "Basic check" ], "Create-blocked-port.any.worker.html?wss": true, "Create-extensions-empty.any.html?default": true, - "Create-extensions-empty.any.html?wpt_flags=h2": false, "Create-extensions-empty.any.html?wss": true, "Create-extensions-empty.any.worker.html?default": true, - "Create-extensions-empty.any.worker.html?wpt_flags=h2": false, "Create-extensions-empty.any.worker.html?wss": true, "Create-http-urls.any.html": true, "Create-http-urls.any.worker.html": true, @@ -7892,239 +7852,162 @@ "Create-non-absolute-url.any.html": true, "Create-non-absolute-url.any.worker.html": true, "Create-nonAscii-protocol-string.any.html?default": true, - "Create-nonAscii-protocol-string.any.html?wpt_flags=h2": true, "Create-nonAscii-protocol-string.any.html?wss": true, "Create-nonAscii-protocol-string.any.worker.html?default": true, - "Create-nonAscii-protocol-string.any.worker.html?wpt_flags=h2": true, "Create-nonAscii-protocol-string.any.worker.html?wss": true, "Create-on-worker-shutdown.any.html": false, "Create-on-worker-shutdown.any.worker.html": false, "Create-protocol-with-space.any.html?default": true, - "Create-protocol-with-space.any.html?wpt_flags=h2": true, "Create-protocol-with-space.any.html?wss": true, "Create-protocol-with-space.any.worker.html?default": true, - "Create-protocol-with-space.any.worker.html?wpt_flags=h2": true, "Create-protocol-with-space.any.worker.html?wss": true, "Create-protocols-repeated-case-insensitive.any.html?default": true, - "Create-protocols-repeated-case-insensitive.any.html?wpt_flags=h2": true, "Create-protocols-repeated-case-insensitive.any.html?wss": true, "Create-protocols-repeated-case-insensitive.any.worker.html?default": true, - "Create-protocols-repeated-case-insensitive.any.worker.html?wpt_flags=h2": true, "Create-protocols-repeated-case-insensitive.any.worker.html?wss": true, "Create-protocols-repeated.any.html?default": true, - "Create-protocols-repeated.any.html?wpt_flags=h2": true, "Create-protocols-repeated.any.html?wss": true, "Create-protocols-repeated.any.worker.html?default": true, - "Create-protocols-repeated.any.worker.html?wpt_flags=h2": true, "Create-protocols-repeated.any.worker.html?wss": true, "Create-url-with-space.any.html?default": true, - "Create-url-with-space.any.html?wpt_flags=h2": true, "Create-url-with-space.any.html?wss": true, "Create-url-with-space.any.worker.html?default": true, - "Create-url-with-space.any.worker.html?wpt_flags=h2": true, "Create-url-with-space.any.worker.html?wss": true, "Create-valid-url-array-protocols.any.html?default": true, - "Create-valid-url-array-protocols.any.html?wpt_flags=h2": false, "Create-valid-url-array-protocols.any.html?wss": true, "Create-valid-url-array-protocols.any.worker.html?default": true, - "Create-valid-url-array-protocols.any.worker.html?wpt_flags=h2": false, "Create-valid-url-array-protocols.any.worker.html?wss": true, "Create-valid-url-binaryType-blob.any.html?default": true, - "Create-valid-url-binaryType-blob.any.html?wpt_flags=h2": false, "Create-valid-url-binaryType-blob.any.html?wss": true, "Create-valid-url-binaryType-blob.any.worker.html?default": true, - "Create-valid-url-binaryType-blob.any.worker.html?wpt_flags=h2": false, "Create-valid-url-binaryType-blob.any.worker.html?wss": true, "Create-valid-url-protocol-empty.any.html?default": true, - "Create-valid-url-protocol-empty.any.html?wpt_flags=h2": true, "Create-valid-url-protocol-empty.any.html?wss": true, "Create-valid-url-protocol-empty.any.worker.html?default": true, - "Create-valid-url-protocol-empty.any.worker.html?wpt_flags=h2": true, "Create-valid-url-protocol-empty.any.worker.html?wss": true, "Create-valid-url-protocol-setCorrectly.any.html?default": true, - "Create-valid-url-protocol-setCorrectly.any.html?wpt_flags=h2": false, "Create-valid-url-protocol-setCorrectly.any.html?wss": true, "Create-valid-url-protocol-setCorrectly.any.worker.html?default": true, - "Create-valid-url-protocol-setCorrectly.any.worker.html?wpt_flags=h2": false, "Create-valid-url-protocol-setCorrectly.any.worker.html?wss": true, "Create-valid-url-protocol-string.any.html?default": true, - "Create-valid-url-protocol-string.any.html?wpt_flags=h2": false, "Create-valid-url-protocol-string.any.html?wss": true, "Create-valid-url-protocol-string.any.worker.html?default": true, - "Create-valid-url-protocol-string.any.worker.html?wpt_flags=h2": false, "Create-valid-url-protocol-string.any.worker.html?wss": true, "Create-valid-url-protocol.any.html?default": true, - "Create-valid-url-protocol.any.html?wpt_flags=h2": false, "Create-valid-url-protocol.any.html?wss": true, "Create-valid-url-protocol.any.worker.html?default": true, - "Create-valid-url-protocol.any.worker.html?wpt_flags=h2": false, "Create-valid-url-protocol.any.worker.html?wss": true, "Create-valid-url.any.html?default": true, - "Create-valid-url.any.html?wpt_flags=h2": false, "Create-valid-url.any.html?wss": true, "Create-valid-url.any.worker.html?default": true, - "Create-valid-url.any.worker.html?wpt_flags=h2": false, "Create-valid-url.any.worker.html?wss": true, "Send-0byte-data.any.html?default": true, - "Send-0byte-data.any.html?wpt_flags=h2": false, "Send-0byte-data.any.html?wss": true, "Send-0byte-data.any.worker.html?default": true, - "Send-0byte-data.any.worker.html?wpt_flags=h2": false, "Send-0byte-data.any.worker.html?wss": true, "Send-65K-data.any.html?default": true, - "Send-65K-data.any.html?wpt_flags=h2": false, "Send-65K-data.any.html?wss": true, "Send-65K-data.any.worker.html?default": true, - "Send-65K-data.any.worker.html?wpt_flags=h2": false, "Send-65K-data.any.worker.html?wss": true, "Send-before-open.any.html?default": true, - "Send-before-open.any.html?wpt_flags=h2": true, "Send-before-open.any.html?wss": true, "Send-before-open.any.worker.html?default": true, - "Send-before-open.any.worker.html?wpt_flags=h2": true, "Send-before-open.any.worker.html?wss": true, "Send-binary-65K-arraybuffer.any.html?default": true, - "Send-binary-65K-arraybuffer.any.html?wpt_flags=h2": false, "Send-binary-65K-arraybuffer.any.html?wss": true, "Send-binary-65K-arraybuffer.any.worker.html?default": true, - "Send-binary-65K-arraybuffer.any.worker.html?wpt_flags=h2": false, "Send-binary-65K-arraybuffer.any.worker.html?wss": true, "Send-binary-arraybuffer.any.html?default": true, - "Send-binary-arraybuffer.any.html?wpt_flags=h2": false, "Send-binary-arraybuffer.any.html?wss": true, "Send-binary-arraybuffer.any.worker.html?default": true, - "Send-binary-arraybuffer.any.worker.html?wpt_flags=h2": false, "Send-binary-arraybuffer.any.worker.html?wss": true, "Send-binary-arraybufferview-float32.any.html?default": true, - "Send-binary-arraybufferview-float32.any.html?wpt_flags=h2": false, "Send-binary-arraybufferview-float32.any.html?wss": true, "Send-binary-arraybufferview-float32.any.worker.html?default": true, - "Send-binary-arraybufferview-float32.any.worker.html?wpt_flags=h2": false, "Send-binary-arraybufferview-float32.any.worker.html?wss": true, "Send-binary-arraybufferview-float64.any.html?default": true, - "Send-binary-arraybufferview-float64.any.html?wpt_flags=h2": false, "Send-binary-arraybufferview-float64.any.html?wss": true, "Send-binary-arraybufferview-float64.any.worker.html?default": true, - "Send-binary-arraybufferview-float64.any.worker.html?wpt_flags=h2": false, "Send-binary-arraybufferview-float64.any.worker.html?wss": true, "Send-binary-arraybufferview-int16-offset.any.html?default": true, - "Send-binary-arraybufferview-int16-offset.any.html?wpt_flags=h2": false, "Send-binary-arraybufferview-int16-offset.any.html?wss": true, "Send-binary-arraybufferview-int16-offset.any.worker.html?default": true, - "Send-binary-arraybufferview-int16-offset.any.worker.html?wpt_flags=h2": false, "Send-binary-arraybufferview-int16-offset.any.worker.html?wss": true, "Send-binary-arraybufferview-int32.any.html?default": true, - "Send-binary-arraybufferview-int32.any.html?wpt_flags=h2": false, "Send-binary-arraybufferview-int32.any.html?wss": true, "Send-binary-arraybufferview-int32.any.worker.html?default": true, - "Send-binary-arraybufferview-int32.any.worker.html?wpt_flags=h2": false, "Send-binary-arraybufferview-int32.any.worker.html?wss": true, "Send-binary-arraybufferview-int8.any.html?default": true, - "Send-binary-arraybufferview-int8.any.html?wpt_flags=h2": false, "Send-binary-arraybufferview-int8.any.html?wss": true, "Send-binary-arraybufferview-int8.any.worker.html?default": true, - "Send-binary-arraybufferview-int8.any.worker.html?wpt_flags=h2": false, "Send-binary-arraybufferview-int8.any.worker.html?wss": true, "Send-binary-arraybufferview-uint16-offset-length.any.html?default": true, - "Send-binary-arraybufferview-uint16-offset-length.any.html?wpt_flags=h2": false, "Send-binary-arraybufferview-uint16-offset-length.any.html?wss": true, "Send-binary-arraybufferview-uint16-offset-length.any.worker.html?default": true, - "Send-binary-arraybufferview-uint16-offset-length.any.worker.html?wpt_flags=h2": false, "Send-binary-arraybufferview-uint16-offset-length.any.worker.html?wss": true, "Send-binary-arraybufferview-uint32-offset.any.html?default": true, - "Send-binary-arraybufferview-uint32-offset.any.html?wpt_flags=h2": false, "Send-binary-arraybufferview-uint32-offset.any.html?wss": true, "Send-binary-arraybufferview-uint32-offset.any.worker.html?default": true, - "Send-binary-arraybufferview-uint32-offset.any.worker.html?wpt_flags=h2": false, "Send-binary-arraybufferview-uint32-offset.any.worker.html?wss": true, "Send-binary-arraybufferview-uint8-offset-length.any.html?default": true, - "Send-binary-arraybufferview-uint8-offset-length.any.html?wpt_flags=h2": false, "Send-binary-arraybufferview-uint8-offset-length.any.html?wss": true, "Send-binary-arraybufferview-uint8-offset-length.any.worker.html?default": true, - "Send-binary-arraybufferview-uint8-offset-length.any.worker.html?wpt_flags=h2": false, "Send-binary-arraybufferview-uint8-offset-length.any.worker.html?wss": true, "Send-binary-arraybufferview-uint8-offset.any.html?default": true, - "Send-binary-arraybufferview-uint8-offset.any.html?wpt_flags=h2": false, "Send-binary-arraybufferview-uint8-offset.any.html?wss": true, "Send-binary-arraybufferview-uint8-offset.any.worker.html?default": true, - "Send-binary-arraybufferview-uint8-offset.any.worker.html?wpt_flags=h2": false, "Send-binary-arraybufferview-uint8-offset.any.worker.html?wss": true, "Send-binary-blob.any.html?default": true, - "Send-binary-blob.any.html?wpt_flags=h2": false, "Send-binary-blob.any.html?wss": true, "Send-binary-blob.any.worker.html?default": true, - "Send-binary-blob.any.worker.html?wpt_flags=h2": false, "Send-binary-blob.any.worker.html?wss": true, "Send-data.any.html?default": true, - "Send-data.any.html?wpt_flags=h2": false, "Send-data.any.html?wss": true, "Send-data.any.worker.html?default": true, - "Send-data.any.worker.html?wpt_flags=h2": false, "Send-data.any.worker.html?wss": true, "Send-data.worker.html?default": true, - "Send-data.worker.html?wpt_flags=h2": false, "Send-data.worker.html?wss": true, "Send-null.any.html?default": true, - "Send-null.any.html?wpt_flags=h2": false, "Send-null.any.html?wss": true, "Send-null.any.worker.html?default": true, - "Send-null.any.worker.html?wpt_flags=h2": false, "Send-null.any.worker.html?wss": true, "Send-paired-surrogates.any.html?default": true, - "Send-paired-surrogates.any.html?wpt_flags=h2": false, "Send-paired-surrogates.any.html?wss": true, "Send-paired-surrogates.any.worker.html?default": true, - "Send-paired-surrogates.any.worker.html?wpt_flags=h2": false, "Send-paired-surrogates.any.worker.html?wss": true, "Send-unicode-data.any.html?default": true, - "Send-unicode-data.any.html?wpt_flags=h2": false, "Send-unicode-data.any.html?wss": true, "Send-unicode-data.any.worker.html?default": true, - "Send-unicode-data.any.worker.html?wpt_flags=h2": false, "Send-unicode-data.any.worker.html?wss": true, "Send-unpaired-surrogates.any.html?default": true, - "Send-unpaired-surrogates.any.html?wpt_flags=h2": false, "Send-unpaired-surrogates.any.html?wss": true, "Send-unpaired-surrogates.any.worker.html?default": true, - "Send-unpaired-surrogates.any.worker.html?wpt_flags=h2": false, "Send-unpaired-surrogates.any.worker.html?wss": true, "back-forward-cache-with-closed-websocket-connection-ccns.tentative.window.html": false, "back-forward-cache-with-closed-websocket-connection.window.html": false, "back-forward-cache-with-open-websocket-connection-ccns.tentative.window.html": false, "back-forward-cache-with-open-websocket-connection.window.html": false, - "basic-auth.any.html?wpt_flags=h2": false, "basic-auth.any.html?wss": false, - "basic-auth.any.worker.html?wpt_flags=h2": false, "basic-auth.any.worker.html?wss": false, "binaryType-wrong-value.any.html?default": true, - "binaryType-wrong-value.any.html?wpt_flags=h2": false, "binaryType-wrong-value.any.html?wss": true, "binaryType-wrong-value.any.worker.html?default": true, - "binaryType-wrong-value.any.worker.html?wpt_flags=h2": false, "binaryType-wrong-value.any.worker.html?wss": true, "bufferedAmount-unchanged-by-sync-xhr.any.html?default": false, - "bufferedAmount-unchanged-by-sync-xhr.any.html?wpt_flags=h2": false, "bufferedAmount-unchanged-by-sync-xhr.any.html?wss": false, "bufferedAmount-unchanged-by-sync-xhr.any.worker.html?default": false, - "bufferedAmount-unchanged-by-sync-xhr.any.worker.html?wpt_flags=h2": false, "bufferedAmount-unchanged-by-sync-xhr.any.worker.html?wss": false, "close-invalid.any.html?default": true, - "close-invalid.any.html?wpt_flags=h2": true, "close-invalid.any.html?wss": true, "close-invalid.any.worker.html?default": true, - "close-invalid.any.worker.html?wpt_flags=h2": true, "close-invalid.any.worker.html?wss": true, "constructor.any.html?default": true, - "constructor.any.html?wpt_flags=h2": true, "constructor.any.html?wss": true, "constructor.any.worker.html?default": true, - "constructor.any.worker.html?wpt_flags=h2": true, "constructor.any.worker.html?wss": true, "eventhandlers.any.html?default": true, - "eventhandlers.any.html?wpt_flags=h2": true, "eventhandlers.any.html?wss": true, "eventhandlers.any.worker.html?default": true, - "eventhandlers.any.worker.html?wpt_flags=h2": true, "eventhandlers.any.worker.html?wss": true, "idlharness.any.html": [ "WebSocket interface: constant CONNECTING on interface object", @@ -8170,39 +8053,26 @@ "referrer.any.html": true, "referrer.any.worker.html": true, "remove-own-iframe-during-onerror.window.html?default": false, - "remove-own-iframe-during-onerror.window.html?wpt_flags=h2": false, "remove-own-iframe-during-onerror.window.html?wss": false, "send-many-64K-messages-with-backpressure.any.html?default": true, - "send-many-64K-messages-with-backpressure.any.html?wpt_flags=h2": false, "send-many-64K-messages-with-backpressure.any.html?wss": true, "send-many-64K-messages-with-backpressure.any.worker.html?default": true, - "send-many-64K-messages-with-backpressure.any.worker.html?wpt_flags=h2": false, "send-many-64K-messages-with-backpressure.any.worker.html?wss": true, "stream": { "tentative": { - "abort.any.html?wpt_flags=h2": [ "abort after connect should do nothing" ], "abort.any.html?wss": true, - "abort.any.worker.html?wpt_flags=h2": [ "abort after connect should do nothing" ], "abort.any.worker.html?wss": true, - "backpressure-receive.any.html?wpt_flags=h2": false, "backpressure-receive.any.html?wss": true, - "backpressure-receive.any.worker.html?wpt_flags=h2": false, "backpressure-receive.any.worker.html?wss": true, - "backpressure-send.any.html?wpt_flags=h2": false, "backpressure-send.any.html?wss": true, - "backpressure-send.any.worker.html?wpt_flags=h2": false, "backpressure-send.any.worker.html?wss": true, - "close.any.html?wpt_flags=h2": false, "close.any.html?wss": true, - "close.any.worker.html?wpt_flags=h2": false, "close.any.worker.html?wss": true, - "constructor.any.html?wpt_flags=h2": false, "constructor.any.html?wss": true, - "constructor.any.worker.html?wpt_flags=h2": false, "constructor.any.worker.html?wss": true } } @@ -10662,4 +10532,4 @@ "media-sniff.window.html": false } } -} \ No newline at end of file +} diff --git a/tools/wpt/runner.ts b/tools/wpt/runner.ts index fb39ddfa49099f..99a297dc3a26e9 100644 --- a/tools/wpt/runner.ts +++ b/tools/wpt/runner.ts @@ -54,6 +54,7 @@ export interface TestResult { duration: number; status: number; stderr: string; + stdout: string; } export interface TestHarnessStatus { @@ -124,7 +125,7 @@ export async function runSingleTest( env: { NO_COLOR: "1", }, - stdout: "null", + stdout: "piped", stderr: "piped", }).spawn(); @@ -136,12 +137,22 @@ export async function runSingleTest( const lines = proc.stderr.pipeThrough(new TextDecoderStream()).pipeThrough( new TextLineStream(), ); + const stdoutLines = proc.stdout.pipeThrough(new TextDecoderStream()) + .pipeThrough( + new TextLineStream(), + ); interval = setInterval(() => { const passedTime = performance.now() - start; if (passedTime > timeout) { proc.kill("SIGINT"); } }, 1000); + let stdout = ""; + (async () => { + for await (const line of stdoutLines) { + stdout += line + "\n"; + } + })(); for await (const line of lines) { if (line.startsWith("{")) { const data = JSON.parse(line); @@ -167,6 +178,7 @@ export async function runSingleTest( duration, cases, stderr, + stdout, }; } finally { clearInterval(interval);