From 341e1e0bee3604d898708546391602e672a1b3ba Mon Sep 17 00:00:00 2001 From: QuiiBz Date: Sun, 7 May 2023 08:05:28 +0200 Subject: [PATCH 01/18] feat(js-runtime,wpt): improve conformance --- crates/runtime_http/src/lib.rs | 3 +- crates/runtime_http/src/request.rs | 11 +-- crates/runtime_http/src/response.rs | 3 +- crates/wpt-runner/current-results.md | 95 +------------------ crates/wpt-runner/src/main.rs | 9 +- .../js-runtime/src/runtime/global/file.ts | 2 +- 6 files changed, 18 insertions(+), 105 deletions(-) diff --git a/crates/runtime_http/src/lib.rs b/crates/runtime_http/src/lib.rs index 8d321f415..533e00887 100644 --- a/crates/runtime_http/src/lib.rs +++ b/crates/runtime_http/src/lib.rs @@ -1,6 +1,5 @@ -use std::time::Duration; - use anyhow::Result; +use std::time::Duration; mod headers; mod method; diff --git a/crates/runtime_http/src/request.rs b/crates/runtime_http/src/request.rs index 6c218e5b2..4f80a4d12 100644 --- a/crates/runtime_http/src/request.rs +++ b/crates/runtime_http/src/request.rs @@ -1,18 +1,13 @@ +use super::{FromV8, IntoV8, Method}; +use crate::{Headers, X_LAGON_ID}; use anyhow::{anyhow, Result}; use hyper::{ body::{self, Bytes}, - header::HeaderName, - http::{self, HeaderValue}, - Body, Request as HyperRequest, + http, Body, Request as HyperRequest, }; use lagon_runtime_v8_utils::{ extract_v8_headers_object, extract_v8_string, v8_headers_object, v8_string, }; -use std::str::FromStr; - -use crate::{Headers, X_LAGON_ID}; - -use super::{FromV8, IntoV8, Method}; #[derive(Debug)] pub struct Request { diff --git a/crates/runtime_http/src/response.rs b/crates/runtime_http/src/response.rs index 334aade6d..5fc6892ea 100644 --- a/crates/runtime_http/src/response.rs +++ b/crates/runtime_http/src/response.rs @@ -1,3 +1,4 @@ +use crate::{FromV8, Headers, IntoV8}; use anyhow::{anyhow, Result}; use hyper::{ body::{self, Bytes}, @@ -8,8 +9,6 @@ use lagon_runtime_v8_utils::{ v8_integer, v8_string, }; -use crate::{FromV8, Headers, IntoV8}; - static READABLE_STREAM_STR: &[u8] = b"[object ReadableStream]"; #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/crates/wpt-runner/current-results.md b/crates/wpt-runner/current-results.md index 17ce97a3c..8b7beda9e 100644 --- a/crates/wpt-runner/current-results.md +++ b/crates/wpt-runner/current-results.md @@ -20,39 +20,7 @@ TEST DONE 0 Headers.prototype.getSetCookie with two equal headers TEST DONE 0 Headers.prototype.getSetCookie ignores set-cookie2 headers TEST DONE 0 Headers.prototype.getSetCookie preserves header ordering TEST DONE 1 Set-Cookie is a forbidden response header -Running ../../tools/wpt/fetch/api/headers/header-values-normalize.any.js -TEST DONE 1 XMLHttpRequest with value %00 -TEST DONE 1 XMLHttpRequest with value %01 -TEST DONE 1 XMLHttpRequest with value %02 -TEST DONE 1 XMLHttpRequest with value %03 -TEST DONE 1 XMLHttpRequest with value %04 -TEST DONE 1 XMLHttpRequest with value %05 -TEST DONE 1 XMLHttpRequest with value %06 -TEST DONE 1 XMLHttpRequest with value %07 -TEST DONE 1 XMLHttpRequest with value %08 -TEST DONE 1 XMLHttpRequest with value %09 -TEST DONE 1 XMLHttpRequest with value %0A -TEST DONE 1 XMLHttpRequest with value %0D -TEST DONE 1 XMLHttpRequest with value %0E -TEST DONE 1 XMLHttpRequest with value %0F -TEST DONE 1 XMLHttpRequest with value %10 -TEST DONE 1 XMLHttpRequest with value %11 -TEST DONE 1 XMLHttpRequest with value %12 -TEST DONE 1 XMLHttpRequest with value %13 -TEST DONE 1 XMLHttpRequest with value %14 -TEST DONE 1 XMLHttpRequest with value %15 -TEST DONE 1 XMLHttpRequest with value %16 -TEST DONE 1 XMLHttpRequest with value %17 -TEST DONE 1 XMLHttpRequest with value %18 -TEST DONE 1 XMLHttpRequest with value %19 -TEST DONE 1 XMLHttpRequest with value %1A -TEST DONE 1 XMLHttpRequest with value %1B -TEST DONE 1 XMLHttpRequest with value %1C -TEST DONE 1 XMLHttpRequest with value %1D -TEST DONE 1 XMLHttpRequest with value %1E -TEST DONE 1 XMLHttpRequest with value %1F -TEST DONE 1 XMLHttpRequest with value %20 -TEST DONE 1 fetch() with value %00 +Skipping ../../tools/wpt/fetch/api/headers/header-values-normalize.any.js Running ../../tools/wpt/fetch/api/headers/header-values.any.js TEST DONE 1 XMLHttpRequest with value x%00x needs to throw TEST DONE 1 XMLHttpRequest with value x%0Ax needs to throw @@ -543,69 +511,14 @@ TEST DONE 1 ReadableStream with non-Uint8Array chunk passed to Response.json() c TEST DONE 1 ReadableStream with non-Uint8Array chunk passed to Response.text() causes TypeError Running ../../tools/wpt/fetch/api/response/response-stream-disturbed-1.any.js TEST DONE 1 Getting blob after getting the Response body - not disturbed, not locked (body source: fetch) -TEST DONE 1 Getting text after getting the Response body - not disturbed, not locked (body source: fetch) -TEST DONE 1 Getting json after getting the Response body - not disturbed, not locked (body source: fetch) -TEST DONE 1 Getting arrayBuffer after getting the Response body - not disturbed, not locked (body source: fetch) -TEST DONE 1 Getting blob after getting the Response body - not disturbed, not locked (body source: stream) -TEST DONE 1 Getting text after getting the Response body - not disturbed, not locked (body source: stream) -TEST DONE 1 Getting json after getting the Response body - not disturbed, not locked (body source: stream) -TEST DONE 1 Getting arrayBuffer after getting the Response body - not disturbed, not locked (body source: stream) -TEST DONE 1 Getting blob after getting the Response body - not disturbed, not locked (body source: string) -TEST DONE 1 Getting text after getting the Response body - not disturbed, not locked (body source: string) -TEST DONE 1 Getting json after getting the Response body - not disturbed, not locked (body source: string) -TEST DONE 1 Getting arrayBuffer after getting the Response body - not disturbed, not locked (body source: string) Running ../../tools/wpt/fetch/api/response/response-stream-disturbed-2.any.js TEST DONE 1 Getting blob after getting a locked Response body (body source: fetch) -TEST DONE 1 Getting text after getting a locked Response body (body source: fetch) -TEST DONE 1 Getting json after getting a locked Response body (body source: fetch) -TEST DONE 1 Getting arrayBuffer after getting a locked Response body (body source: fetch) -TEST DONE 1 Getting blob after getting a locked Response body (body source: stream) -TEST DONE 1 Getting text after getting a locked Response body (body source: stream) -TEST DONE 1 Getting json after getting a locked Response body (body source: stream) -TEST DONE 1 Getting arrayBuffer after getting a locked Response body (body source: stream) -TEST DONE 1 Getting blob after getting a locked Response body (body source: string) -TEST DONE 1 Getting text after getting a locked Response body (body source: string) -TEST DONE 1 Getting json after getting a locked Response body (body source: string) -TEST DONE 1 Getting arrayBuffer after getting a locked Response body (body source: string) Running ../../tools/wpt/fetch/api/response/response-stream-disturbed-3.any.js TEST DONE 1 Getting blob after reading the Response body (body source: fetch) -TEST DONE 1 Getting text after reading the Response body (body source: fetch) -TEST DONE 1 Getting json after reading the Response body (body source: fetch) -TEST DONE 1 Getting arrayBuffer after reading the Response body (body source: fetch) -TEST DONE 1 Getting blob after reading the Response body (body source: stream) -TEST DONE 1 Getting text after reading the Response body (body source: stream) -TEST DONE 1 Getting json after reading the Response body (body source: stream) -TEST DONE 1 Getting arrayBuffer after reading the Response body (body source: stream) -TEST DONE 1 Getting blob after reading the Response body (body source: string) -TEST DONE 1 Getting text after reading the Response body (body source: string) -TEST DONE 1 Getting json after reading the Response body (body source: string) -TEST DONE 1 Getting arrayBuffer after reading the Response body (body source: string) Running ../../tools/wpt/fetch/api/response/response-stream-disturbed-4.any.js TEST DONE 1 Getting blob after cancelling the Response body (body source: fetch) -TEST DONE 1 Getting text after cancelling the Response body (body source: fetch) -TEST DONE 1 Getting json after cancelling the Response body (body source: fetch) -TEST DONE 1 Getting arrayBuffer after cancelling the Response body (body source: fetch) -TEST DONE 1 Getting blob after cancelling the Response body (body source: stream) -TEST DONE 1 Getting text after cancelling the Response body (body source: stream) -TEST DONE 1 Getting json after cancelling the Response body (body source: stream) -TEST DONE 1 Getting arrayBuffer after cancelling the Response body (body source: stream) -TEST DONE 1 Getting blob after cancelling the Response body (body source: string) -TEST DONE 1 Getting text after cancelling the Response body (body source: string) -TEST DONE 1 Getting json after cancelling the Response body (body source: string) -TEST DONE 1 Getting arrayBuffer after cancelling the Response body (body source: string) Running ../../tools/wpt/fetch/api/response/response-stream-disturbed-5.any.js TEST DONE 1 Getting a body reader after consuming as blob (body source: fetch) -TEST DONE 1 Getting a body reader after consuming as text (body source: fetch) -TEST DONE 1 Getting a body reader after consuming as json (body source: fetch) -TEST DONE 1 Getting a body reader after consuming as arrayBuffer (body source: fetch) -TEST DONE 1 Getting a body reader after consuming as blob (body source: stream) -TEST DONE 1 Getting a body reader after consuming as text (body source: stream) -TEST DONE 1 Getting a body reader after consuming as json (body source: stream) -TEST DONE 1 Getting a body reader after consuming as arrayBuffer (body source: stream) -TEST DONE 1 Getting a body reader after consuming as blob (body source: string) -TEST DONE 1 Getting a body reader after consuming as text (body source: string) -TEST DONE 1 Getting a body reader after consuming as json (body source: string) -TEST DONE 1 Getting a body reader after consuming as arrayBuffer (body source: string) Running ../../tools/wpt/fetch/api/response/response-stream-disturbed-6.any.js TEST DONE 1 A non-closed stream on which read() has been called TEST DONE 1 A non-closed stream on which cancel() has been called @@ -1638,7 +1551,7 @@ Running ../../tools/wpt/FileAPI/reading-data-section/filereader_result.any.js TEST DONE 0 readAsText TEST DONE 0 readAsDataURL TEST DONE 0 readAsArrayBuffer -TEST DONE 1 readAsBinaryString +TEST DONE 0 readAsBinaryString TEST DONE 1 result is null during "loadstart" event for readAsText TEST DONE 1 result is null during "loadstart" event for readAsDataURL TEST DONE 1 result is null during "loadstart" event for readAsArrayBuffer @@ -1700,5 +1613,5 @@ Running ../../tools/wpt/urlpattern/urlpattern-compare.https.any.js Running ../../tools/wpt/urlpattern/urlpattern.any.js Running ../../tools/wpt/urlpattern/urlpattern.https.any.js -1576 tests, 464 passed, 1103 failed - -> 29% conformance +1493 tests, 465 passed, 1015 failed + -> 31% conformance diff --git a/crates/wpt-runner/src/main.rs b/crates/wpt-runner/src/main.rs index 2b482eb0e..13dddf61f 100644 --- a/crates/wpt-runner/src/main.rs +++ b/crates/wpt-runner/src/main.rs @@ -38,6 +38,8 @@ const DECODING_HELPERS: &str = const SUPPORT_BLOB: &str = include_str!("../../../tools/wpt/FileAPI/support/Blob.js"); const SUPPORT_FORMDATA: &str = include_str!("../../../tools/wpt/FileAPI/support/send-file-formdata-helper.js"); +const STREAM_DISTURBED_UTIL: &str = + include_str!("../../../tools/wpt/fetch/api/response/response-stream-disturbed-util.js"); static RESULT: Lazy> = Lazy::new(|| Mutex::new((0, 0, 0))); static TEST_HARNESS: Lazy = Lazy::new(|| { @@ -47,7 +49,7 @@ static TEST_HARNESS: Lazy = Lazy::new(|| { .replace("debug: false", "debug: true") }); -const SKIP_TESTS: [&str; 16] = [ +const SKIP_TESTS: [&str; 17] = [ // request "request-error.any.js", // "badRequestArgTests is not defined" "request-init-stream.any.js", // "request.body.getReader is not a function" @@ -69,6 +71,8 @@ const SKIP_TESTS: [&str; 16] = [ "textdecoder-fatal-single-byte.any.js", // have a random number of tests? // event "EventTarget-removeEventListener.any.js", // removeEventListener does not exists on the global object + // headers + "header-values-normalize.any.js", // XMLHttpRequest isn't supported ]; async fn run_test(path: &Path) { @@ -103,6 +107,7 @@ export function handler() {{ {DECODING_HELPERS} {SUPPORT_BLOB} {SUPPORT_FORMDATA} + {STREAM_DISTURBED_UTIL} {code} return new Response() }}", @@ -134,6 +139,8 @@ export function handler() {{ println!("{}", content.red()); } else if content.starts_with("TEST START") { RESULT.lock().unwrap().0 += 1; + } else { + // println!("{}", content); } } }); diff --git a/packages/js-runtime/src/runtime/global/file.ts b/packages/js-runtime/src/runtime/global/file.ts index 41778e4ac..55f6f380b 100644 --- a/packages/js-runtime/src/runtime/global/file.ts +++ b/packages/js-runtime/src/runtime/global/file.ts @@ -48,7 +48,7 @@ } readAsBinaryString(blob: Blob) { - this.read(blob.arrayBuffer()); + this.read(blob.text()); } readAsDataURL(blob: Blob) { From 1e7c0556eeee040f9f557f032f59a8017194bc04 Mon Sep 17 00:00:00 2001 From: QuiiBz Date: Sun, 7 May 2023 09:15:09 +0200 Subject: [PATCH 02/18] feat(js-runtime): rewrite URLSearchParams --- crates/wpt-runner/current-results.md | 93 ++++----- .../src/runtime/http/URLSearchParams.ts | 186 ++++++++++++------ 2 files changed, 175 insertions(+), 104 deletions(-) diff --git a/crates/wpt-runner/current-results.md b/crates/wpt-runner/current-results.md index 8b7beda9e..ccf22df69 100644 --- a/crates/wpt-runner/current-results.md +++ b/crates/wpt-runner/current-results.md @@ -811,36 +811,36 @@ Skipping ../../tools/wpt/url/url-setters.any.js Running ../../tools/wpt/url/url-tojson.any.js TEST DONE 0 Untitled Running ../../tools/wpt/url/urlencoded-parser.any.js -TEST DONE 1 URLSearchParams constructed with: test +TEST DONE 0 URLSearchParams constructed with: test TEST DONE 0 URLSearchParams constructed with: test= -TEST DONE 1 URLSearchParams constructed with: %EF%BB%BFtest=%EF%BB%BF +TEST DONE 0 URLSearchParams constructed with: %EF%BB%BFtest=%EF%BB%BF TEST DONE 1 URLSearchParams constructed with: %FE%FF TEST DONE 1 URLSearchParams constructed with: %FF%FE -TEST DONE 1 URLSearchParams constructed with: †&†=x +TEST DONE 0 URLSearchParams constructed with: †&†=x TEST DONE 1 URLSearchParams constructed with: %C2 TEST DONE 1 URLSearchParams constructed with: %C2x TEST DONE 1 URLSearchParams constructed with: _charset_=windows-1252&test=%C2x TEST DONE 0 URLSearchParams constructed with: -TEST DONE 1 URLSearchParams constructed with: a +TEST DONE 0 URLSearchParams constructed with: a TEST DONE 0 URLSearchParams constructed with: a=b TEST DONE 0 URLSearchParams constructed with: a= TEST DONE 0 URLSearchParams constructed with: =b -TEST DONE 1 URLSearchParams constructed with: & -TEST DONE 1 URLSearchParams constructed with: &a -TEST DONE 1 URLSearchParams constructed with: a& -TEST DONE 1 URLSearchParams constructed with: a&a -TEST DONE 1 URLSearchParams constructed with: a&b&c +TEST DONE 0 URLSearchParams constructed with: & +TEST DONE 0 URLSearchParams constructed with: &a +TEST DONE 0 URLSearchParams constructed with: a& +TEST DONE 0 URLSearchParams constructed with: a&a +TEST DONE 0 URLSearchParams constructed with: a&b&c TEST DONE 0 URLSearchParams constructed with: a=b&c=d -TEST DONE 1 URLSearchParams constructed with: a=b&c=d& -TEST DONE 1 URLSearchParams constructed with: &&&a=b&&&&c=d& +TEST DONE 0 URLSearchParams constructed with: a=b&c=d& +TEST DONE 0 URLSearchParams constructed with: &&&a=b&&&&c=d& TEST DONE 0 URLSearchParams constructed with: a=a&a=b&a=c TEST DONE 1 URLSearchParams constructed with: a==a -TEST DONE 1 URLSearchParams constructed with: a=a+b+c+d -TEST DONE 0 URLSearchParams constructed with: %=a -TEST DONE 0 URLSearchParams constructed with: %a=a -TEST DONE 0 URLSearchParams constructed with: %a_=a -TEST DONE 1 URLSearchParams constructed with: %61=a -TEST DONE 1 URLSearchParams constructed with: %61+%4d%4D= +TEST DONE 0 URLSearchParams constructed with: a=a+b+c+d +TEST DONE 1 URLSearchParams constructed with: %=a +TEST DONE 1 URLSearchParams constructed with: %a=a +TEST DONE 1 URLSearchParams constructed with: %a_=a +TEST DONE 0 URLSearchParams constructed with: %61=a +TEST DONE 0 URLSearchParams constructed with: %61+%4d%4D= TEST DONE 1 URLSearchParams constructed with: id=0&value=% TEST DONE 1 URLSearchParams constructed with: b=%2sf%2a TEST DONE 1 URLSearchParams constructed with: b=%2%2af%2a @@ -920,7 +920,7 @@ TEST DONE 1 Append null TEST DONE 1 Append multiple Running ../../tools/wpt/url/urlsearchparams-constructor.any.js TEST DONE 1 Basic URLSearchParams construction -TEST DONE 0 URLSearchParams constructor, no arguments +TEST DONE 1 URLSearchParams constructor, no arguments TEST DONE 0 URLSearchParams constructor, remove leading "?" TEST DONE 1 URLSearchParams constructor, DOMException as argument TEST DONE 0 URLSearchParams constructor, empty string as argument @@ -928,17 +928,17 @@ TEST DONE 0 URLSearchParams constructor, {} as argument TEST DONE 1 URLSearchParams constructor, string. TEST DONE 1 URLSearchParams constructor, object. TEST DONE 1 URLSearchParams constructor, FormData. -TEST DONE 1 Parse + +TEST DONE 0 Parse + TEST DONE 1 Parse encoded + TEST DONE 0 Parse space -TEST DONE 1 Parse %20 +TEST DONE 0 Parse %20 TEST DONE 0 Parse \0 -TEST DONE 1 Parse %00 +TEST DONE 0 Parse %00 TEST DONE 0 Parse ⎄ -TEST DONE 1 Parse %e2%8e%84 +TEST DONE 0 Parse %e2%8e%84 TEST DONE 0 Parse 💩 -TEST DONE 1 Parse %f0%9f%92%a9 -TEST DONE 1 Constructor with sequence of sequences of strings +TEST DONE 0 Parse %f0%9f%92%a9 +TEST DONE 0 Constructor with sequence of sequences of strings TEST DONE 0 Construct with object with + TEST DONE 0 Construct with object with two keys TEST DONE 0 Construct with array with two keys @@ -948,43 +948,48 @@ TEST DONE 1 Construct with object with NULL, non-ASCII, and surrogate keys TEST DONE 1 Custom [Symbol.iterator] Running ../../tools/wpt/url/urlsearchparams-delete.any.js TEST DONE 1 Delete basics -TEST DONE 1 Deleting appended multiple +TEST DONE 0 Deleting appended multiple TEST DONE 0 Deleting all params removes ? from URL -TEST DONE 1 Removing non-existent param removes ? from URL +TEST DONE 0 Removing non-existent param removes ? from URL TEST DONE 1 Changing the query of a URL with an opaque path can impact the path TEST DONE 1 Changing the query of a URL with an opaque path can impact the path if the URL has no fragment Running ../../tools/wpt/url/urlsearchparams-foreach.any.js TEST DONE 0 ForEach Check +TEST DONE 1 For-of Check +TEST DONE 0 empty +TEST DONE 1 delete next param during iteration +TEST DONE 1 delete current param during iteration +TEST DONE 1 delete every param seen during iteration Running ../../tools/wpt/url/urlsearchparams-get.any.js TEST DONE 1 Get basics TEST DONE 1 More get() basics Running ../../tools/wpt/url/urlsearchparams-getall.any.js TEST DONE 0 getAll() basics -TEST DONE 1 getAll() multiples +TEST DONE 0 getAll() multiples Running ../../tools/wpt/url/urlsearchparams-has.any.js TEST DONE 1 Has basics TEST DONE 0 has() following delete() Running ../../tools/wpt/url/urlsearchparams-set.any.js TEST DONE 0 Set basics -TEST DONE 1 URLSearchParams.set +TEST DONE 0 URLSearchParams.set Running ../../tools/wpt/url/urlsearchparams-sort.any.js TEST DONE 0 Parse and sort: z=b&a=b&z=a&a=a -TEST DONE 1 URL parse and sort: z=b&a=b&z=a&a=a -TEST DONE 1 Parse and sort: �=x&&�=a -TEST DONE 1 URL parse and sort: �=x&&�=a -TEST DONE 1 Parse and sort: ffi&🌈 -TEST DONE 1 URL parse and sort: ffi&🌈 +TEST DONE 0 URL parse and sort: z=b&a=b&z=a&a=a +TEST DONE 0 Parse and sort: �=x&&�=a +TEST DONE 0 URL parse and sort: �=x&&�=a +TEST DONE 0 Parse and sort: ffi&🌈 +TEST DONE 0 URL parse and sort: ffi&🌈 TEST DONE 1 Parse and sort: é&e�&é TEST DONE 1 URL parse and sort: é&e�&é TEST DONE 0 Parse and sort: z=z&a=a&z=y&a=b&z=x&a=c&z=w&a=d&z=v&a=e&z=u&a=f&z=t&a=g -TEST DONE 1 URL parse and sort: z=z&a=a&z=y&a=b&z=x&a=c&z=w&a=d&z=v&a=e&z=u&a=f&z=t&a=g -TEST DONE 1 Parse and sort: bbb&bb&aaa&aa=x&aa=y -TEST DONE 1 URL parse and sort: bbb&bb&aaa&aa=x&aa=y +TEST DONE 0 URL parse and sort: z=z&a=a&z=y&a=b&z=x&a=c&z=w&a=d&z=v&a=e&z=u&a=f&z=t&a=g +TEST DONE 0 Parse and sort: bbb&bb&aaa&aa=x&aa=y +TEST DONE 0 URL parse and sort: bbb&bb&aaa&aa=x&aa=y TEST DONE 0 Parse and sort: z=z&=f&=t&=x -TEST DONE 1 URL parse and sort: z=z&=f&=t&=x -TEST DONE 1 Parse and sort: a🌈&a💩 -TEST DONE 1 URL parse and sort: a🌈&a💩 -TEST DONE 1 Sorting non-existent params removes ? from URL +TEST DONE 0 URL parse and sort: z=z&=f&=t&=x +TEST DONE 0 Parse and sort: a🌈&a💩 +TEST DONE 0 URL parse and sort: a🌈&a💩 +TEST DONE 0 Sorting non-existent params removes ? from URL Running ../../tools/wpt/url/urlsearchparams-stringifier.any.js TEST DONE 1 Serialize space TEST DONE 1 Serialize empty value @@ -993,13 +998,13 @@ TEST DONE 1 Serialize empty name and value TEST DONE 1 Serialize + TEST DONE 1 Serialize = TEST DONE 1 Serialize & -TEST DONE 0 Serialize *-._ +TEST DONE 1 Serialize *-._ TEST DONE 1 Serialize % TEST DONE 1 Serialize \0 TEST DONE 1 Serialize 💩 TEST DONE 1 URLSearchParams.toString TEST DONE 1 URLSearchParams connected to URL -TEST DONE 1 URLSearchParams must not do newline normalization +TEST DONE 0 URLSearchParams must not do newline normalization Running ../../tools/wpt/encoding/api-basics.any.js TEST DONE 0 Default encodings TEST DONE 0 Default inputs @@ -1613,5 +1618,5 @@ Running ../../tools/wpt/urlpattern/urlpattern-compare.https.any.js Running ../../tools/wpt/urlpattern/urlpattern.any.js Running ../../tools/wpt/urlpattern/urlpattern.https.any.js -1493 tests, 465 passed, 1015 failed - -> 31% conformance +1497 tests, 498 passed, 987 failed + -> 33% conformance diff --git a/packages/js-runtime/src/runtime/http/URLSearchParams.ts b/packages/js-runtime/src/runtime/http/URLSearchParams.ts index 9c67499d4..4ed31371d 100644 --- a/packages/js-runtime/src/runtime/http/URLSearchParams.ts +++ b/packages/js-runtime/src/runtime/http/URLSearchParams.ts @@ -1,106 +1,172 @@ (globalThis => { globalThis.URLSearchParams = class { - private params: Map = new Map(); + private list: [string, string][] = []; + private url: URL | null = null; constructor(init?: string[][] | Record | string | URLSearchParams) { - if (init) { - if (typeof init === 'string') { - init - .replace('?', '') - .split('&') - .forEach(entry => { - const [key, value] = entry.split('='); - - this.addValue(key, decodeURIComponent(value)); - }); - } else if (typeof init === 'object') { - if (Array.isArray(init)) { - init.forEach(([key, value]) => { - this.addValue(key, value); - }); - } else { - Object.entries(init).forEach(([key, value]) => { - this.addValue(key, value); - }); - } - } + if (typeof init === 'string' && init.startsWith('?')) { + init = init.slice(1); } + + this.initialize(init); } - private addValue(name: string, value: string) { - const values = this.params.get(name); + private parse(init: string): [string, string][] { + const sequences = init.split('&'); + const output: [string, string][] = []; - if (values) { - values.push(value); - } else { - this.params.set(name, [value]); + for (const sequence of sequences) { + if (sequence.length === 0) { + continue; + } + + let name: string; + let value: string; + + if (sequence.includes('=')) { + const [a, b] = sequence.split('='); + name = a; + value = b; + } else { + name = sequence; + value = ''; + } + + name = decodeURIComponent(name.replaceAll('+', ' ')); + value = decodeURIComponent(value.replaceAll('+', ' ')); + + output.push([name, value]); } + + return output; } - append(name: string, value: string) { - this.addValue(name, value); + private initialize(init?: string[][] | Record | string | URLSearchParams) { + if (typeof init === 'object') { + if (Array.isArray(init)) { + for (const inner of init) { + if (inner.length !== 2) { + throw new TypeError( + "Failed to construct 'URLSearchParams': Sequence initializer must only contain pair elements", + ); + } + + this.list.push([inner[0], inner[1]]); + } + } else { + Object.entries(init).forEach(([name, value]) => { + this.list.push([name, value]); + }); + } + } else { + this.list = this.parse(String(init)); + } } - delete(name: string) { - this.params.delete(name); + private serialize(list: [string, string][]): string { + return list.map(([name, value]) => `${encodeURIComponent(name)}=${encodeURIComponent(value)}`).join('&'); } - *entries(): IterableIterator<[string, string]> { - for (const [key, values] of this.params) { - for (const value of values) { - yield [key, value]; - } + private update() { + if (this.url === null) { + return; + } + + let serialized: string | null = this.serialize(this.list); + + if (serialized.length === 0) { + serialized = null; } + + // this.url.query = serialized; } - forEach(callbackfn: (value: string, key: string, parent: URLSearchParams) => void, thisArg?: any) { - this.params.forEach((values, key) => { - values.forEach(value => { - callbackfn.call(thisArg, value, key, this); - }); - }); + get size(): number { + return this.list.length; + } + + append(name: string, value: string) { + this.list.push([name, String(value)]); + this.update(); + } + + delete(name: string) { + this.list = this.list.filter(([currentName]) => currentName !== name); + this.update(); } get(name: string): string | null { - return this.params.get(name)?.[0] || null; + return this.list.find(([currentName]) => currentName === name)?.[1] || null; } getAll(name: string): string[] { - return this.params.get(name) || []; + return this.list.filter(([currentName]) => currentName === name).map(([, currentValue]) => currentValue); } has(name: string): boolean { - return this.params.has(name); - } - - keys(): IterableIterator { - return this.params.keys(); + return this.list.some(([currentName]) => currentName === name); } set(name: string, value: string) { - this.params.set(name, [value]); + if (this.has(name)) { + let found = false; + + this.list = this.list.reduce((acc, [currentName, currentValue]) => { + if (currentName === name) { + if (found) { + return acc; + } + + found = true; + acc.push([name, String(value)]); + } else { + acc.push([currentName, currentValue]); + } + + return acc; + }, [] as [string, string][]); + } else { + this.append(name, value); + } + + this.update(); } sort() { - this.params = new Map([...this.params].sort()); + this.list.sort(([a], [b]) => a.localeCompare(b)); + this.update(); } - toString(): string { - return Array.from(this.params.entries()) - .map(([key, value]) => `${key}=${value}`) - .join('&'); + *entries(): IterableIterator<[string, string]> { + for (const [name, value] of this.list) { + yield [name, value]; + } + } + + forEach(callbackfn: (value: string, key: string, parent: URLSearchParams) => void, thisArg?: any) { + for (const [name, value] of this.list) { + callbackfn.call(thisArg, value, name, this); + } + } + + *keys(): IterableIterator { + for (const [name] of this.list) { + yield name; + } } *values(): IterableIterator { - for (const [, values] of this.params) { - for (const value of values) { - yield value; - } + for (const [, value] of this.list) { + yield value; } } [Symbol.iterator](): IterableIterator<[string, string]> { return this.entries(); } + + toString(): string { + return this.serialize(this.list); + } }; })(globalThis); From 05e7a210a07128ab4ee3431e6848c900063ce0cd Mon Sep 17 00:00:00 2001 From: QuiiBz Date: Sun, 7 May 2023 09:22:46 +0200 Subject: [PATCH 03/18] fix: basics --- crates/wpt-runner/current-results.md | 6 +++--- packages/js-runtime/src/runtime/http/URLSearchParams.ts | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/wpt-runner/current-results.md b/crates/wpt-runner/current-results.md index ccf22df69..70ef3bfa4 100644 --- a/crates/wpt-runner/current-results.md +++ b/crates/wpt-runner/current-results.md @@ -947,7 +947,7 @@ TEST DONE 1 Construct with 3 unpaired surrogates (no leading) TEST DONE 1 Construct with object with NULL, non-ASCII, and surrogate keys TEST DONE 1 Custom [Symbol.iterator] Running ../../tools/wpt/url/urlsearchparams-delete.any.js -TEST DONE 1 Delete basics +TEST DONE 0 Delete basics TEST DONE 0 Deleting appended multiple TEST DONE 0 Deleting all params removes ? from URL TEST DONE 0 Removing non-existent param removes ? from URL @@ -967,7 +967,7 @@ Running ../../tools/wpt/url/urlsearchparams-getall.any.js TEST DONE 0 getAll() basics TEST DONE 0 getAll() multiples Running ../../tools/wpt/url/urlsearchparams-has.any.js -TEST DONE 1 Has basics +TEST DONE 0 Has basics TEST DONE 0 has() following delete() Running ../../tools/wpt/url/urlsearchparams-set.any.js TEST DONE 0 Set basics @@ -1618,5 +1618,5 @@ Running ../../tools/wpt/urlpattern/urlpattern-compare.https.any.js Running ../../tools/wpt/urlpattern/urlpattern.any.js Running ../../tools/wpt/urlpattern/urlpattern.https.any.js -1497 tests, 498 passed, 987 failed +1497 tests, 500 passed, 985 failed -> 33% conformance diff --git a/packages/js-runtime/src/runtime/http/URLSearchParams.ts b/packages/js-runtime/src/runtime/http/URLSearchParams.ts index 4ed31371d..e960d4736 100644 --- a/packages/js-runtime/src/runtime/http/URLSearchParams.ts +++ b/packages/js-runtime/src/runtime/http/URLSearchParams.ts @@ -86,24 +86,28 @@ } append(name: string, value: string) { - this.list.push([name, String(value)]); + this.list.push([String(name), String(value)]); this.update(); } delete(name: string) { + name = String(name); this.list = this.list.filter(([currentName]) => currentName !== name); this.update(); } get(name: string): string | null { + name = String(name); return this.list.find(([currentName]) => currentName === name)?.[1] || null; } getAll(name: string): string[] { + name = String(name); return this.list.filter(([currentName]) => currentName === name).map(([, currentValue]) => currentValue); } has(name: string): boolean { + name = String(name); return this.list.some(([currentName]) => currentName === name); } @@ -118,7 +122,7 @@ } found = true; - acc.push([name, String(value)]); + acc.push([String(name), String(value)]); } else { acc.push([currentName, currentValue]); } From 5817985b4e622f9666dea2cdecbb13f5800726e3 Mon Sep 17 00:00:00 2001 From: QuiiBz Date: Sun, 7 May 2023 09:27:59 +0200 Subject: [PATCH 04/18] fix: get --- crates/wpt-runner/current-results.md | 8 ++++---- packages/js-runtime/src/runtime/http/URLSearchParams.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/wpt-runner/current-results.md b/crates/wpt-runner/current-results.md index 70ef3bfa4..59c6af5dc 100644 --- a/crates/wpt-runner/current-results.md +++ b/crates/wpt-runner/current-results.md @@ -917,7 +917,7 @@ Running ../../tools/wpt/url/urlsearchparams-append.any.js TEST DONE 1 Append same name TEST DONE 1 Append empty strings TEST DONE 1 Append null -TEST DONE 1 Append multiple +TEST DONE 0 Append multiple Running ../../tools/wpt/url/urlsearchparams-constructor.any.js TEST DONE 1 Basic URLSearchParams construction TEST DONE 1 URLSearchParams constructor, no arguments @@ -961,8 +961,8 @@ TEST DONE 1 delete next param during iteration TEST DONE 1 delete current param during iteration TEST DONE 1 delete every param seen during iteration Running ../../tools/wpt/url/urlsearchparams-get.any.js -TEST DONE 1 Get basics -TEST DONE 1 More get() basics +TEST DONE 0 Get basics +TEST DONE 0 More get() basics Running ../../tools/wpt/url/urlsearchparams-getall.any.js TEST DONE 0 getAll() basics TEST DONE 0 getAll() multiples @@ -1618,5 +1618,5 @@ Running ../../tools/wpt/urlpattern/urlpattern-compare.https.any.js Running ../../tools/wpt/urlpattern/urlpattern.any.js Running ../../tools/wpt/urlpattern/urlpattern.https.any.js -1497 tests, 500 passed, 985 failed +1497 tests, 503 passed, 982 failed -> 33% conformance diff --git a/packages/js-runtime/src/runtime/http/URLSearchParams.ts b/packages/js-runtime/src/runtime/http/URLSearchParams.ts index e960d4736..d76f4113a 100644 --- a/packages/js-runtime/src/runtime/http/URLSearchParams.ts +++ b/packages/js-runtime/src/runtime/http/URLSearchParams.ts @@ -98,7 +98,7 @@ get(name: string): string | null { name = String(name); - return this.list.find(([currentName]) => currentName === name)?.[1] || null; + return this.list.find(([currentName]) => currentName === name)?.[1] ?? null; } getAll(name: string): string[] { From b5454a516d270b53ad5ba6caeda6cd9c73268467 Mon Sep 17 00:00:00 2001 From: QuiiBz Date: Sun, 7 May 2023 12:06:01 +0200 Subject: [PATCH 05/18] fix: URLSearchParams toString --- crates/wpt-runner/current-results.md | 32 +++++++++---------- .../src/runtime/http/URLSearchParams.ts | 11 +++++-- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/crates/wpt-runner/current-results.md b/crates/wpt-runner/current-results.md index 59c6af5dc..2a5040fee 100644 --- a/crates/wpt-runner/current-results.md +++ b/crates/wpt-runner/current-results.md @@ -914,13 +914,13 @@ TEST DONE 1 response.formData() with input: b=%2%2af%2a TEST DONE 1 request.formData() with input: b=%%2a TEST DONE 1 response.formData() with input: b=%%2a Running ../../tools/wpt/url/urlsearchparams-append.any.js -TEST DONE 1 Append same name -TEST DONE 1 Append empty strings -TEST DONE 1 Append null +TEST DONE 0 Append same name +TEST DONE 0 Append empty strings +TEST DONE 0 Append null TEST DONE 0 Append multiple Running ../../tools/wpt/url/urlsearchparams-constructor.any.js TEST DONE 1 Basic URLSearchParams construction -TEST DONE 1 URLSearchParams constructor, no arguments +TEST DONE 0 URLSearchParams constructor, no arguments TEST DONE 0 URLSearchParams constructor, remove leading "?" TEST DONE 1 URLSearchParams constructor, DOMException as argument TEST DONE 0 URLSearchParams constructor, empty string as argument @@ -929,7 +929,7 @@ TEST DONE 1 URLSearchParams constructor, string. TEST DONE 1 URLSearchParams constructor, object. TEST DONE 1 URLSearchParams constructor, FormData. TEST DONE 0 Parse + -TEST DONE 1 Parse encoded + +TEST DONE 0 Parse encoded + TEST DONE 0 Parse space TEST DONE 0 Parse %20 TEST DONE 0 Parse \0 @@ -992,16 +992,16 @@ TEST DONE 0 URL parse and sort: a🌈&a💩 TEST DONE 0 Sorting non-existent params removes ? from URL Running ../../tools/wpt/url/urlsearchparams-stringifier.any.js TEST DONE 1 Serialize space -TEST DONE 1 Serialize empty value -TEST DONE 1 Serialize empty name -TEST DONE 1 Serialize empty name and value -TEST DONE 1 Serialize + -TEST DONE 1 Serialize = -TEST DONE 1 Serialize & -TEST DONE 1 Serialize *-._ +TEST DONE 0 Serialize empty value +TEST DONE 0 Serialize empty name +TEST DONE 0 Serialize empty name and value +TEST DONE 0 Serialize + +TEST DONE 0 Serialize = +TEST DONE 0 Serialize & +TEST DONE 0 Serialize *-._ TEST DONE 1 Serialize % -TEST DONE 1 Serialize \0 -TEST DONE 1 Serialize 💩 +TEST DONE 0 Serialize \0 +TEST DONE 0 Serialize 💩 TEST DONE 1 URLSearchParams.toString TEST DONE 1 URLSearchParams connected to URL TEST DONE 0 URLSearchParams must not do newline normalization @@ -1618,5 +1618,5 @@ Running ../../tools/wpt/urlpattern/urlpattern-compare.https.any.js Running ../../tools/wpt/urlpattern/urlpattern.any.js Running ../../tools/wpt/urlpattern/urlpattern.https.any.js -1497 tests, 503 passed, 982 failed - -> 33% conformance +1497 tests, 517 passed, 968 failed + -> 34% conformance diff --git a/packages/js-runtime/src/runtime/http/URLSearchParams.ts b/packages/js-runtime/src/runtime/http/URLSearchParams.ts index d76f4113a..8566ed581 100644 --- a/packages/js-runtime/src/runtime/http/URLSearchParams.ts +++ b/packages/js-runtime/src/runtime/http/URLSearchParams.ts @@ -3,7 +3,7 @@ private list: [string, string][] = []; private url: URL | null = null; - constructor(init?: string[][] | Record | string | URLSearchParams) { + constructor(init: string[][] | Record | string | URLSearchParams = '') { if (typeof init === 'string' && init.startsWith('?')) { init = init.slice(1); } @@ -41,7 +41,7 @@ return output; } - private initialize(init?: string[][] | Record | string | URLSearchParams) { + private initialize(init: string[][] | Record | string | URLSearchParams = '') { if (typeof init === 'object') { if (Array.isArray(init)) { for (const inner of init) { @@ -64,7 +64,12 @@ } private serialize(list: [string, string][]): string { - return list.map(([name, value]) => `${encodeURIComponent(name)}=${encodeURIComponent(value)}`).join('&'); + return list + .map( + ([name, value]) => + `${encodeURIComponent(name.replaceAll(' ', '+'))}=${encodeURIComponent(value.replaceAll(' ', '+'))}`, + ) + .join('&'); } private update() { From 585741e4240b05467db5b5aef59904640f1e93d1 Mon Sep 17 00:00:00 2001 From: QuiiBz Date: Sun, 7 May 2023 14:17:45 +0200 Subject: [PATCH 06/18] fix: multipart --- crates/wpt-runner/current-results.md | 84 ++++++++++++------------- packages/js-runtime/src/runtime/core.ts | 2 +- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/crates/wpt-runner/current-results.md b/crates/wpt-runner/current-results.md index 2a5040fee..a454381f3 100644 --- a/crates/wpt-runner/current-results.md +++ b/crates/wpt-runner/current-results.md @@ -845,18 +845,18 @@ TEST DONE 1 URLSearchParams constructed with: id=0&value=% TEST DONE 1 URLSearchParams constructed with: b=%2sf%2a TEST DONE 1 URLSearchParams constructed with: b=%2%2af%2a TEST DONE 1 URLSearchParams constructed with: b=%%2a -TEST DONE 1 request.formData() with input: test -TEST DONE 1 response.formData() with input: test -TEST DONE 1 request.formData() with input: test= -TEST DONE 1 response.formData() with input: test= -TEST DONE 1 request.formData() with input: %EF%BB%BFtest=%EF%BB%BF -TEST DONE 1 response.formData() with input: %EF%BB%BFtest=%EF%BB%BF +TEST DONE 0 request.formData() with input: test +TEST DONE 0 response.formData() with input: test +TEST DONE 0 request.formData() with input: test= +TEST DONE 0 response.formData() with input: test= +TEST DONE 0 request.formData() with input: %EF%BB%BFtest=%EF%BB%BF +TEST DONE 0 response.formData() with input: %EF%BB%BFtest=%EF%BB%BF TEST DONE 1 request.formData() with input: %FE%FF TEST DONE 1 response.formData() with input: %FE%FF TEST DONE 1 request.formData() with input: %FF%FE TEST DONE 1 response.formData() with input: %FF%FE -TEST DONE 1 request.formData() with input: †&†=x -TEST DONE 1 response.formData() with input: †&†=x +TEST DONE 0 request.formData() with input: †&†=x +TEST DONE 0 response.formData() with input: †&†=x TEST DONE 1 request.formData() with input: %C2 TEST DONE 1 response.formData() with input: %C2 TEST DONE 1 request.formData() with input: %C2x @@ -865,46 +865,46 @@ TEST DONE 1 request.formData() with input: _charset_=windows-1252&test=%C2x TEST DONE 1 response.formData() with input: _charset_=windows-1252&test=%C2x TEST DONE 0 request.formData() with input: TEST DONE 0 response.formData() with input: -TEST DONE 1 request.formData() with input: a -TEST DONE 1 response.formData() with input: a -TEST DONE 1 request.formData() with input: a=b -TEST DONE 1 response.formData() with input: a=b -TEST DONE 1 request.formData() with input: a= -TEST DONE 1 response.formData() with input: a= -TEST DONE 1 request.formData() with input: =b -TEST DONE 1 response.formData() with input: =b -TEST DONE 1 request.formData() with input: & -TEST DONE 1 response.formData() with input: & -TEST DONE 1 request.formData() with input: &a -TEST DONE 1 response.formData() with input: &a -TEST DONE 1 request.formData() with input: a& -TEST DONE 1 response.formData() with input: a& -TEST DONE 1 request.formData() with input: a&a -TEST DONE 1 response.formData() with input: a&a -TEST DONE 1 request.formData() with input: a&b&c -TEST DONE 1 response.formData() with input: a&b&c -TEST DONE 1 request.formData() with input: a=b&c=d -TEST DONE 1 response.formData() with input: a=b&c=d -TEST DONE 1 request.formData() with input: a=b&c=d& -TEST DONE 1 response.formData() with input: a=b&c=d& -TEST DONE 1 request.formData() with input: &&&a=b&&&&c=d& -TEST DONE 1 response.formData() with input: &&&a=b&&&&c=d& -TEST DONE 1 request.formData() with input: a=a&a=b&a=c -TEST DONE 1 response.formData() with input: a=a&a=b&a=c +TEST DONE 0 request.formData() with input: a +TEST DONE 0 response.formData() with input: a +TEST DONE 0 request.formData() with input: a=b +TEST DONE 0 response.formData() with input: a=b +TEST DONE 0 request.formData() with input: a= +TEST DONE 0 response.formData() with input: a= +TEST DONE 0 request.formData() with input: =b +TEST DONE 0 response.formData() with input: =b +TEST DONE 0 request.formData() with input: & +TEST DONE 0 response.formData() with input: & +TEST DONE 0 request.formData() with input: &a +TEST DONE 0 response.formData() with input: &a +TEST DONE 0 request.formData() with input: a& +TEST DONE 0 response.formData() with input: a& +TEST DONE 0 request.formData() with input: a&a +TEST DONE 0 response.formData() with input: a&a +TEST DONE 0 request.formData() with input: a&b&c +TEST DONE 0 response.formData() with input: a&b&c +TEST DONE 0 request.formData() with input: a=b&c=d +TEST DONE 0 response.formData() with input: a=b&c=d +TEST DONE 0 request.formData() with input: a=b&c=d& +TEST DONE 0 response.formData() with input: a=b&c=d& +TEST DONE 0 request.formData() with input: &&&a=b&&&&c=d& +TEST DONE 0 response.formData() with input: &&&a=b&&&&c=d& +TEST DONE 0 request.formData() with input: a=a&a=b&a=c +TEST DONE 0 response.formData() with input: a=a&a=b&a=c TEST DONE 1 request.formData() with input: a==a TEST DONE 1 response.formData() with input: a==a -TEST DONE 1 request.formData() with input: a=a+b+c+d -TEST DONE 1 response.formData() with input: a=a+b+c+d +TEST DONE 0 request.formData() with input: a=a+b+c+d +TEST DONE 0 response.formData() with input: a=a+b+c+d TEST DONE 1 request.formData() with input: %=a TEST DONE 1 response.formData() with input: %=a TEST DONE 1 request.formData() with input: %a=a TEST DONE 1 response.formData() with input: %a=a TEST DONE 1 request.formData() with input: %a_=a TEST DONE 1 response.formData() with input: %a_=a -TEST DONE 1 request.formData() with input: %61=a -TEST DONE 1 response.formData() with input: %61=a -TEST DONE 1 request.formData() with input: %61+%4d%4D= -TEST DONE 1 response.formData() with input: %61+%4d%4D= +TEST DONE 0 request.formData() with input: %61=a +TEST DONE 0 response.formData() with input: %61=a +TEST DONE 0 request.formData() with input: %61+%4d%4D= +TEST DONE 0 response.formData() with input: %61+%4d%4D= TEST DONE 1 request.formData() with input: id=0&value=% TEST DONE 1 response.formData() with input: id=0&value=% TEST DONE 1 request.formData() with input: b=%2sf%2a @@ -1618,5 +1618,5 @@ Running ../../tools/wpt/urlpattern/urlpattern-compare.https.any.js Running ../../tools/wpt/urlpattern/urlpattern.any.js Running ../../tools/wpt/urlpattern/urlpattern.https.any.js -1497 tests, 517 passed, 968 failed - -> 34% conformance +1497 tests, 557 passed, 928 failed + -> 37% conformance diff --git a/packages/js-runtime/src/runtime/core.ts b/packages/js-runtime/src/runtime/core.ts index 04ab5fe96..163ab6177 100644 --- a/packages/js-runtime/src/runtime/core.ts +++ b/packages/js-runtime/src/runtime/core.ts @@ -15,7 +15,7 @@ const contentTypeHeader = headers.get('content-type'); - if (contentTypeHeader === APPLICATION_X_WWW_FORM_URLENCODED) { + if (contentTypeHeader?.startsWith(APPLICATION_X_WWW_FORM_URLENCODED)) { const params = new URLSearchParams(body); for (const [key, value] of params) { From 97c0c65b2579e567f8ae061ac69369ab73e66e00 Mon Sep 17 00:00:00 2001 From: QuiiBz Date: Sun, 7 May 2023 15:01:31 +0200 Subject: [PATCH 07/18] feat: enable more tests --- .changeset/spicy-insects-hug.md | 5 + crates/wpt-runner/current-results.md | 378 ++++++++------------------- crates/wpt-runner/src/main.rs | 28 +- 3 files changed, 130 insertions(+), 281 deletions(-) create mode 100644 .changeset/spicy-insects-hug.md diff --git a/.changeset/spicy-insects-hug.md b/.changeset/spicy-insects-hug.md new file mode 100644 index 000000000..5ae72a213 --- /dev/null +++ b/.changeset/spicy-insects-hug.md @@ -0,0 +1,5 @@ +--- +'@lagon/wpt-runner': patch +--- + +Add not completed tests to results diff --git a/crates/wpt-runner/current-results.md b/crates/wpt-runner/current-results.md index a454381f3..106742b50 100644 --- a/crates/wpt-runner/current-results.md +++ b/crates/wpt-runner/current-results.md @@ -245,8 +245,60 @@ TEST DONE 1 RequestCache "reload" mode does store the response in the cache even TEST DONE 1 RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with Last-Modified and stale response TEST DONE 1 RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with Etag and fresh response TEST DONE 1 RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with Last-Modified and fresh response -Skipping ../../tools/wpt/fetch/api/request/request-consume-empty.any.js -Skipping ../../tools/wpt/fetch/api/request/request-consume.any.js +Running ../../tools/wpt/fetch/api/request/request-consume-empty.any.js +TEST DONE 1 Consume request's body as text +TEST DONE 1 Consume request's body as blob +TEST DONE 1 Consume request's body as arrayBuffer +TEST DONE 1 Consume request's body as json (error case) +TEST DONE 1 Consume request's body as formData with correct multipart type (error case) +TEST DONE 1 Consume request's body as formData with correct urlencoded type +TEST DONE 1 Consume request's body as formData without correct type (error case) +TEST DONE 0 Consume empty blob request body as arrayBuffer +TEST DONE 0 Consume empty text request body as arrayBuffer +TEST DONE 0 Consume empty blob request body as text +TEST DONE 0 Consume empty text request body as text +TEST DONE 0 Consume empty URLSearchParams request body as text +TEST DONE 1 Consume empty FormData request body as text +TEST DONE 0 Consume empty ArrayBuffer request body as text +Running ../../tools/wpt/fetch/api/request/request-consume.any.js +TEST DONE 0 Consume String request's body as text +TEST DONE 0 Consume String request's body as blob +TEST DONE 1 Consume String request's body as arrayBuffer +TEST DONE 0 Consume String request's body as JSON +TEST DONE 0 Consume ArrayBuffer request's body as text +TEST DONE 0 Consume ArrayBuffer request's body as blob +TEST DONE 1 Consume ArrayBuffer request's body as arrayBuffer +TEST DONE 0 Consume ArrayBuffer request's body as JSON +TEST DONE 0 Consume Uint8Array request's body as text +TEST DONE 0 Consume Uint8Array request's body as blob +TEST DONE 1 Consume Uint8Array request's body as arrayBuffer +TEST DONE 0 Consume Uint8Array request's body as JSON +TEST DONE 1 Consume Int8Array request's body as text +TEST DONE 1 Consume Int8Array request's body as blob +TEST DONE 1 Consume Int8Array request's body as arrayBuffer +TEST DONE 1 Consume Int8Array request's body as JSON +TEST DONE 1 Consume Float32Array request's body as text +TEST DONE 1 Consume Float32Array request's body as blob +TEST DONE 1 Consume Float32Array request's body as arrayBuffer +TEST DONE 1 Consume Float32Array request's body as JSON +TEST DONE 1 Consume DataView request's body as text +TEST DONE 1 Consume DataView request's body as blob +TEST DONE 1 Consume DataView request's body as arrayBuffer +TEST DONE 1 Consume DataView request's body as JSON +TEST DONE 1 Consume FormData request's body as FormData +TEST DONE 0 Consume blob response's body as blob +TEST DONE 0 Consume blob response's body as text +TEST DONE 0 Consume blob response's body as json +TEST DONE 1 Consume blob response's body as arrayBuffer +TEST DONE 0 Consume blob response's body as blob (empty blob as input) +TEST DONE 0 Consume JSON from text: '"null"' +TEST DONE 0 Consume JSON from text: '"1"' +TEST DONE 0 Consume JSON from text: '"true"' +TEST DONE 0 Consume JSON from text: '"\"string\""' +TEST DONE 0 Trying to consume bad JSON text as JSON: 'undefined' +TEST DONE 0 Trying to consume bad JSON text as JSON: '{' +TEST DONE 0 Trying to consume bad JSON text as JSON: 'a' +TEST DONE 0 Trying to consume bad JSON text as JSON: '[' Running ../../tools/wpt/fetch/api/request/request-disturbed.any.js TEST DONE 1 Request's body: initial state TEST DONE 1 Request without body cannot be disturbed @@ -257,7 +309,29 @@ TEST DONE 1 Check creating a new request with a new body from a disturbed reques TEST DONE 1 Input request used for creating new request became disturbed TEST DONE 1 Input request used for creating new request became disturbed even if body is not used TEST DONE 0 Check consuming a disturbed request -Skipping ../../tools/wpt/fetch/api/request/request-error.any.js +Running ../../tools/wpt/fetch/api/request/request-error.any.js +TEST DONE 1 RequestInit's window is not null +TEST DONE 1 Input URL is not valid +TEST DONE 1 Input URL has credentials +TEST DONE 1 RequestInit's mode is navigate +TEST DONE 1 RequestInit's referrer is invalid +TEST DONE 1 RequestInit's method is invalid +TEST DONE 1 RequestInit's method is forbidden +TEST DONE 1 RequestInit's mode is no-cors and method is not simple +TEST DONE 1 RequestInit's cache mode is only-if-cached and mode is not same-origin +TEST DONE 1 Request with cache mode: only-if-cached and fetch mode cors +TEST DONE 1 Request with cache mode: only-if-cached and fetch mode no-cors +TEST DONE 1 Bad referrerPolicy init parameter value +TEST DONE 1 Bad mode init parameter value +TEST DONE 1 Bad credentials init parameter value +TEST DONE 1 Bad cache init parameter value +TEST DONE 1 Bad redirect init parameter value +TEST DONE 0 Untitled +TEST DONE 1 Request should get its content-type from the init request +TEST DONE 0 Request should not get its content-type from the init request if init headers are provided +TEST DONE 1 Request should get its content-type from the body if none is provided +TEST DONE 1 Request should get its content-type from init headers if one is provided +TEST DONE 0 Request with cache mode: only-if-cached and fetch mode: same-origin Running ../../tools/wpt/fetch/api/request/request-headers.any.js TEST DONE 0 Adding valid request header "Content-Type: OK" TEST DONE 0 Adding valid request header "Potato: OK" @@ -348,8 +422,36 @@ TEST DONE 0 Can override Content-Type for Request with URLSearchParams body TEST DONE 0 Can override Content-Type for Request with string body TEST DONE 0 Can override Content-Type for Request with ReadableStream body TEST DONE 1 Default Content-Type for Request with FormData body -Skipping ../../tools/wpt/fetch/api/request/request-init-priority.any.js -Skipping ../../tools/wpt/fetch/api/request/request-init-stream.any.js +Running ../../tools/wpt/fetch/api/request/request-init-priority.any.js +TEST DONE 0 new Request() with a 'high' priority does not throw an error +TEST DONE 0 new Request() with a 'low' priority does not throw an error +TEST DONE 0 new Request() with a 'auto' priority does not throw an error +TEST DONE 1 new Request() throws a TypeError if any of RequestInit's members' values are invalid +TEST DONE 1 fetch() with a 'high' priority completes successfully +Running ../../tools/wpt/fetch/api/request/request-init-stream.any.js +TEST DONE 1 Constructing a Request with a stream holds the original object. +TEST DONE 1 Constructing a Request with a stream on which getReader() is called +TEST DONE 1 Constructing a Request with a stream on which read() is called +TEST DONE 1 Constructing a Request with a Request on which body.getReader() is called +TEST DONE 1 Constructing a Request with a Request on which body.getReader().read() is called +TEST DONE 0 It is OK to omit .duplex when the body is null. +TEST DONE 0 It is OK to omit .duplex when the body is a string. +TEST DONE 0 It is OK to omit .duplex when the body is a Uint8Array. +TEST DONE 0 It is OK to omit .duplex when the body is a Blob. +TEST DONE 1 It is error to omit .duplex when the body is a ReadableStream. +TEST DONE 0 It is OK to set .duplex = 'half' when the body is null. +TEST DONE 0 It is OK to set .duplex = 'half' when the body is a string. +TEST DONE 0 It is OK to set .duplex = 'half' when the body is a Uint8Array. +TEST DONE 0 It is OK to set .duplex = 'half' when the body is a Blob. +TEST DONE 0 It is OK to set .duplex = 'half' when the body is a ReadableStream. +TEST DONE 1 It is error to set .duplex = 'full' when the body is null. +TEST DONE 1 It is error to set .duplex = 'full' when the body is a string. +TEST DONE 1 It is error to set .duplex = 'full' when the body is a Uint8Array. +TEST DONE 1 It is error to set .duplex = 'full' when the body is a Blob. +TEST DONE 1 It is error to set .duplex = 'full' when the body is a ReadableStream. +TEST DONE 0 It is OK to omit duplex when init.body is not given and input.body is given. +TEST DONE 1 Constructing a Request with a stream on which read() and releaseLock() are called +TEST DONE 1 Constructing a Request with a Request on which read() and releaseLock() are called Running ../../tools/wpt/fetch/api/request/request-keepalive.any.js TEST DONE 1 keepalive flag TEST DONE 1 keepalive flag with stream body @@ -546,267 +648,7 @@ TEST DONE 0 URL.searchParams getter TEST DONE 0 URL.searchParams updating, clearing TEST DONE 1 URL.searchParams setter, invalid values TEST DONE 1 URL.searchParams and URL.search setters, update propagation -Running ../../tools/wpt/url/url-setters-stripping.any.js -TEST DONE 1 Setting protocol with leading U+0000 (https:) -TEST DONE 1 Setting protocol with U+0000 before inserted colon (https:) -TEST DONE 1 Setting username with leading U+0000 (https:) -TEST DONE 1 Setting username with middle U+0000 (https:) -TEST DONE 1 Setting username with trailing U+0000 (https:) -TEST DONE 1 Setting password with leading U+0000 (https:) -TEST DONE 1 Setting password with middle U+0000 (https:) -TEST DONE 1 Setting password with trailing U+0000 (https:) -TEST DONE 1 Setting host with leading U+0000 (https:) -TEST DONE 1 Setting hostname with leading U+0000 (https:) -TEST DONE 1 Setting host with middle U+0000 (https:) -TEST DONE 1 Setting hostname with middle U+0000 (https:) -TEST DONE 1 Setting host with trailing U+0000 (https:) -TEST DONE 1 Setting hostname with trailing U+0000 (https:) -TEST DONE 1 Setting port with leading U+0000 (https:) -TEST DONE 1 Setting port with middle U+0000 (https:) -TEST DONE 1 Setting port with trailing U+0000 (https:) -TEST DONE 1 Setting pathname with leading U+0000 (https:) -TEST DONE 1 Setting pathname with middle U+0000 (https:) -TEST DONE 1 Setting pathname with trailing U+0000 (https:) -TEST DONE 1 Setting search with leading U+0000 (https:) -TEST DONE 1 Setting search with middle U+0000 (https:) -TEST DONE 1 Setting search with trailing U+0000 (https:) -TEST DONE 1 Setting hash with leading U+0000 (https:) -TEST DONE 1 Setting hash with middle U+0000 (https:) -TEST DONE 1 Setting hash with trailing U+0000 (https:) -TEST DONE 1 Setting protocol with leading U+0009 (https:) -TEST DONE 1 Setting protocol with U+0009 before inserted colon (https:) -TEST DONE 1 Setting username with leading U+0009 (https:) -TEST DONE 1 Setting username with middle U+0009 (https:) -TEST DONE 1 Setting username with trailing U+0009 (https:) -TEST DONE 1 Setting password with leading U+0009 (https:) -TEST DONE 1 Setting password with middle U+0009 (https:) -TEST DONE 1 Setting password with trailing U+0009 (https:) -TEST DONE 1 Setting host with leading U+0009 (https:) -TEST DONE 1 Setting hostname with leading U+0009 (https:) -TEST DONE 1 Setting host with middle U+0009 (https:) -TEST DONE 1 Setting hostname with middle U+0009 (https:) -TEST DONE 1 Setting host with trailing U+0009 (https:) -TEST DONE 1 Setting hostname with trailing U+0009 (https:) -TEST DONE 1 Setting port with leading U+0009 (https:) -TEST DONE 1 Setting port with middle U+0009 (https:) -TEST DONE 1 Setting port with trailing U+0009 (https:) -TEST DONE 1 Setting pathname with leading U+0009 (https:) -TEST DONE 1 Setting pathname with middle U+0009 (https:) -TEST DONE 1 Setting pathname with trailing U+0009 (https:) -TEST DONE 1 Setting search with leading U+0009 (https:) -TEST DONE 1 Setting search with middle U+0009 (https:) -TEST DONE 1 Setting search with trailing U+0009 (https:) -TEST DONE 1 Setting hash with leading U+0009 (https:) -TEST DONE 1 Setting hash with middle U+0009 (https:) -TEST DONE 1 Setting hash with trailing U+0009 (https:) -TEST DONE 1 Setting protocol with leading U+000A (https:) -TEST DONE 1 Setting protocol with U+000A before inserted colon (https:) -TEST DONE 1 Setting username with leading U+000A (https:) -TEST DONE 1 Setting username with middle U+000A (https:) -TEST DONE 1 Setting username with trailing U+000A (https:) -TEST DONE 1 Setting password with leading U+000A (https:) -TEST DONE 1 Setting password with middle U+000A (https:) -TEST DONE 1 Setting password with trailing U+000A (https:) -TEST DONE 1 Setting host with leading U+000A (https:) -TEST DONE 1 Setting hostname with leading U+000A (https:) -TEST DONE 1 Setting host with middle U+000A (https:) -TEST DONE 1 Setting hostname with middle U+000A (https:) -TEST DONE 1 Setting host with trailing U+000A (https:) -TEST DONE 1 Setting hostname with trailing U+000A (https:) -TEST DONE 1 Setting port with leading U+000A (https:) -TEST DONE 1 Setting port with middle U+000A (https:) -TEST DONE 1 Setting port with trailing U+000A (https:) -TEST DONE 1 Setting pathname with leading U+000A (https:) -TEST DONE 1 Setting pathname with middle U+000A (https:) -TEST DONE 1 Setting pathname with trailing U+000A (https:) -TEST DONE 1 Setting search with leading U+000A (https:) -TEST DONE 1 Setting search with middle U+000A (https:) -TEST DONE 1 Setting search with trailing U+000A (https:) -TEST DONE 1 Setting hash with leading U+000A (https:) -TEST DONE 1 Setting hash with middle U+000A (https:) -TEST DONE 1 Setting hash with trailing U+000A (https:) -TEST DONE 1 Setting protocol with leading U+000D (https:) -TEST DONE 1 Setting protocol with U+000D before inserted colon (https:) -TEST DONE 1 Setting username with leading U+000D (https:) -TEST DONE 1 Setting username with middle U+000D (https:) -TEST DONE 1 Setting username with trailing U+000D (https:) -TEST DONE 1 Setting password with leading U+000D (https:) -TEST DONE 1 Setting password with middle U+000D (https:) -TEST DONE 1 Setting password with trailing U+000D (https:) -TEST DONE 1 Setting host with leading U+000D (https:) -TEST DONE 1 Setting hostname with leading U+000D (https:) -TEST DONE 1 Setting host with middle U+000D (https:) -TEST DONE 1 Setting hostname with middle U+000D (https:) -TEST DONE 1 Setting host with trailing U+000D (https:) -TEST DONE 1 Setting hostname with trailing U+000D (https:) -TEST DONE 1 Setting port with leading U+000D (https:) -TEST DONE 1 Setting port with middle U+000D (https:) -TEST DONE 1 Setting port with trailing U+000D (https:) -TEST DONE 1 Setting pathname with leading U+000D (https:) -TEST DONE 1 Setting pathname with middle U+000D (https:) -TEST DONE 1 Setting pathname with trailing U+000D (https:) -TEST DONE 1 Setting search with leading U+000D (https:) -TEST DONE 1 Setting search with middle U+000D (https:) -TEST DONE 1 Setting search with trailing U+000D (https:) -TEST DONE 1 Setting hash with leading U+000D (https:) -TEST DONE 1 Setting hash with middle U+000D (https:) -TEST DONE 1 Setting hash with trailing U+000D (https:) -TEST DONE 1 Setting protocol with leading U+001F (https:) -TEST DONE 1 Setting protocol with U+001F before inserted colon (https:) -TEST DONE 1 Setting username with leading U+001F (https:) -TEST DONE 1 Setting username with middle U+001F (https:) -TEST DONE 1 Setting username with trailing U+001F (https:) -TEST DONE 1 Setting password with leading U+001F (https:) -TEST DONE 1 Setting password with middle U+001F (https:) -TEST DONE 1 Setting password with trailing U+001F (https:) -TEST DONE 1 Setting host with leading U+001F (https:) -TEST DONE 1 Setting hostname with leading U+001F (https:) -TEST DONE 1 Setting host with middle U+001F (https:) -TEST DONE 1 Setting hostname with middle U+001F (https:) -TEST DONE 1 Setting host with trailing U+001F (https:) -TEST DONE 1 Setting hostname with trailing U+001F (https:) -TEST DONE 1 Setting port with leading U+001F (https:) -TEST DONE 1 Setting port with middle U+001F (https:) -TEST DONE 1 Setting port with trailing U+001F (https:) -TEST DONE 1 Setting pathname with leading U+001F (https:) -TEST DONE 1 Setting pathname with middle U+001F (https:) -TEST DONE 1 Setting pathname with trailing U+001F (https:) -TEST DONE 1 Setting search with leading U+001F (https:) -TEST DONE 1 Setting search with middle U+001F (https:) -TEST DONE 1 Setting search with trailing U+001F (https:) -TEST DONE 1 Setting hash with leading U+001F (https:) -TEST DONE 1 Setting hash with middle U+001F (https:) -TEST DONE 1 Setting hash with trailing U+001F (https:) -TEST DONE 1 Setting protocol with leading U+0000 (wpt++:) -TEST DONE 1 Setting protocol with U+0000 before inserted colon (wpt++:) -TEST DONE 1 Setting username with leading U+0000 (wpt++:) -TEST DONE 1 Setting username with middle U+0000 (wpt++:) -TEST DONE 1 Setting username with trailing U+0000 (wpt++:) -TEST DONE 1 Setting password with leading U+0000 (wpt++:) -TEST DONE 1 Setting password with middle U+0000 (wpt++:) -TEST DONE 1 Setting password with trailing U+0000 (wpt++:) -TEST DONE 1 Setting host with leading U+0000 (wpt++:) -TEST DONE 1 Setting hostname with leading U+0000 (wpt++:) -TEST DONE 1 Setting host with middle U+0000 (wpt++:) -TEST DONE 1 Setting hostname with middle U+0000 (wpt++:) -TEST DONE 1 Setting host with trailing U+0000 (wpt++:) -TEST DONE 1 Setting hostname with trailing U+0000 (wpt++:) -TEST DONE 1 Setting port with leading U+0000 (wpt++:) -TEST DONE 1 Setting port with middle U+0000 (wpt++:) -TEST DONE 1 Setting port with trailing U+0000 (wpt++:) -TEST DONE 1 Setting pathname with leading U+0000 (wpt++:) -TEST DONE 1 Setting pathname with middle U+0000 (wpt++:) -TEST DONE 1 Setting pathname with trailing U+0000 (wpt++:) -TEST DONE 1 Setting search with leading U+0000 (wpt++:) -TEST DONE 1 Setting search with middle U+0000 (wpt++:) -TEST DONE 1 Setting search with trailing U+0000 (wpt++:) -TEST DONE 1 Setting hash with leading U+0000 (wpt++:) -TEST DONE 1 Setting hash with middle U+0000 (wpt++:) -TEST DONE 1 Setting hash with trailing U+0000 (wpt++:) -TEST DONE 1 Setting protocol with leading U+0009 (wpt++:) -TEST DONE 1 Setting protocol with U+0009 before inserted colon (wpt++:) -TEST DONE 1 Setting username with leading U+0009 (wpt++:) -TEST DONE 1 Setting username with middle U+0009 (wpt++:) -TEST DONE 1 Setting username with trailing U+0009 (wpt++:) -TEST DONE 1 Setting password with leading U+0009 (wpt++:) -TEST DONE 1 Setting password with middle U+0009 (wpt++:) -TEST DONE 1 Setting password with trailing U+0009 (wpt++:) -TEST DONE 1 Setting host with leading U+0009 (wpt++:) -TEST DONE 1 Setting hostname with leading U+0009 (wpt++:) -TEST DONE 1 Setting host with middle U+0009 (wpt++:) -TEST DONE 1 Setting hostname with middle U+0009 (wpt++:) -TEST DONE 1 Setting host with trailing U+0009 (wpt++:) -TEST DONE 1 Setting hostname with trailing U+0009 (wpt++:) -TEST DONE 1 Setting port with leading U+0009 (wpt++:) -TEST DONE 1 Setting port with middle U+0009 (wpt++:) -TEST DONE 1 Setting port with trailing U+0009 (wpt++:) -TEST DONE 1 Setting pathname with leading U+0009 (wpt++:) -TEST DONE 1 Setting pathname with middle U+0009 (wpt++:) -TEST DONE 1 Setting pathname with trailing U+0009 (wpt++:) -TEST DONE 1 Setting search with leading U+0009 (wpt++:) -TEST DONE 1 Setting search with middle U+0009 (wpt++:) -TEST DONE 1 Setting search with trailing U+0009 (wpt++:) -TEST DONE 1 Setting hash with leading U+0009 (wpt++:) -TEST DONE 1 Setting hash with middle U+0009 (wpt++:) -TEST DONE 1 Setting hash with trailing U+0009 (wpt++:) -TEST DONE 1 Setting protocol with leading U+000A (wpt++:) -TEST DONE 1 Setting protocol with U+000A before inserted colon (wpt++:) -TEST DONE 1 Setting username with leading U+000A (wpt++:) -TEST DONE 1 Setting username with middle U+000A (wpt++:) -TEST DONE 1 Setting username with trailing U+000A (wpt++:) -TEST DONE 1 Setting password with leading U+000A (wpt++:) -TEST DONE 1 Setting password with middle U+000A (wpt++:) -TEST DONE 1 Setting password with trailing U+000A (wpt++:) -TEST DONE 1 Setting host with leading U+000A (wpt++:) -TEST DONE 1 Setting hostname with leading U+000A (wpt++:) -TEST DONE 1 Setting host with middle U+000A (wpt++:) -TEST DONE 1 Setting hostname with middle U+000A (wpt++:) -TEST DONE 1 Setting host with trailing U+000A (wpt++:) -TEST DONE 1 Setting hostname with trailing U+000A (wpt++:) -TEST DONE 1 Setting port with leading U+000A (wpt++:) -TEST DONE 1 Setting port with middle U+000A (wpt++:) -TEST DONE 1 Setting port with trailing U+000A (wpt++:) -TEST DONE 1 Setting pathname with leading U+000A (wpt++:) -TEST DONE 1 Setting pathname with middle U+000A (wpt++:) -TEST DONE 1 Setting pathname with trailing U+000A (wpt++:) -TEST DONE 1 Setting search with leading U+000A (wpt++:) -TEST DONE 1 Setting search with middle U+000A (wpt++:) -TEST DONE 1 Setting search with trailing U+000A (wpt++:) -TEST DONE 1 Setting hash with leading U+000A (wpt++:) -TEST DONE 1 Setting hash with middle U+000A (wpt++:) -TEST DONE 1 Setting hash with trailing U+000A (wpt++:) -TEST DONE 1 Setting protocol with leading U+000D (wpt++:) -TEST DONE 1 Setting protocol with U+000D before inserted colon (wpt++:) -TEST DONE 1 Setting username with leading U+000D (wpt++:) -TEST DONE 1 Setting username with middle U+000D (wpt++:) -TEST DONE 1 Setting username with trailing U+000D (wpt++:) -TEST DONE 1 Setting password with leading U+000D (wpt++:) -TEST DONE 1 Setting password with middle U+000D (wpt++:) -TEST DONE 1 Setting password with trailing U+000D (wpt++:) -TEST DONE 1 Setting host with leading U+000D (wpt++:) -TEST DONE 1 Setting hostname with leading U+000D (wpt++:) -TEST DONE 1 Setting host with middle U+000D (wpt++:) -TEST DONE 1 Setting hostname with middle U+000D (wpt++:) -TEST DONE 1 Setting host with trailing U+000D (wpt++:) -TEST DONE 1 Setting hostname with trailing U+000D (wpt++:) -TEST DONE 1 Setting port with leading U+000D (wpt++:) -TEST DONE 1 Setting port with middle U+000D (wpt++:) -TEST DONE 1 Setting port with trailing U+000D (wpt++:) -TEST DONE 1 Setting pathname with leading U+000D (wpt++:) -TEST DONE 1 Setting pathname with middle U+000D (wpt++:) -TEST DONE 1 Setting pathname with trailing U+000D (wpt++:) -TEST DONE 1 Setting search with leading U+000D (wpt++:) -TEST DONE 1 Setting search with middle U+000D (wpt++:) -TEST DONE 1 Setting search with trailing U+000D (wpt++:) -TEST DONE 1 Setting hash with leading U+000D (wpt++:) -TEST DONE 1 Setting hash with middle U+000D (wpt++:) -TEST DONE 1 Setting hash with trailing U+000D (wpt++:) -TEST DONE 1 Setting protocol with leading U+001F (wpt++:) -TEST DONE 1 Setting protocol with U+001F before inserted colon (wpt++:) -TEST DONE 1 Setting username with leading U+001F (wpt++:) -TEST DONE 1 Setting username with middle U+001F (wpt++:) -TEST DONE 1 Setting username with trailing U+001F (wpt++:) -TEST DONE 1 Setting password with leading U+001F (wpt++:) -TEST DONE 1 Setting password with middle U+001F (wpt++:) -TEST DONE 1 Setting password with trailing U+001F (wpt++:) -TEST DONE 1 Setting host with leading U+001F (wpt++:) -TEST DONE 1 Setting hostname with leading U+001F (wpt++:) -TEST DONE 1 Setting host with middle U+001F (wpt++:) -TEST DONE 1 Setting hostname with middle U+001F (wpt++:) -TEST DONE 1 Setting host with trailing U+001F (wpt++:) -TEST DONE 1 Setting hostname with trailing U+001F (wpt++:) -TEST DONE 1 Setting port with leading U+001F (wpt++:) -TEST DONE 1 Setting port with middle U+001F (wpt++:) -TEST DONE 1 Setting port with trailing U+001F (wpt++:) -TEST DONE 1 Setting pathname with leading U+001F (wpt++:) -TEST DONE 1 Setting pathname with middle U+001F (wpt++:) -TEST DONE 1 Setting pathname with trailing U+001F (wpt++:) -TEST DONE 1 Setting search with leading U+001F (wpt++:) -TEST DONE 1 Setting search with middle U+001F (wpt++:) -TEST DONE 1 Setting search with trailing U+001F (wpt++:) -TEST DONE 1 Setting hash with leading U+001F (wpt++:) -TEST DONE 1 Setting hash with middle U+001F (wpt++:) -TEST DONE 1 Setting hash with trailing U+001F (wpt++:) +Skipping ../../tools/wpt/url/url-setters-stripping.any.js Skipping ../../tools/wpt/url/url-setters.any.js Running ../../tools/wpt/url/url-tojson.any.js TEST DONE 0 Untitled @@ -1618,5 +1460,5 @@ Running ../../tools/wpt/urlpattern/urlpattern-compare.https.any.js Running ../../tools/wpt/urlpattern/urlpattern.any.js Running ../../tools/wpt/urlpattern/urlpattern.https.any.js -1497 tests, 557 passed, 928 failed - -> 37% conformance +1340 tests, 600 passed, 727 failed (13 not completed) + -> 45% conformance diff --git a/crates/wpt-runner/src/main.rs b/crates/wpt-runner/src/main.rs index 13dddf61f..c38f86033 100644 --- a/crates/wpt-runner/src/main.rs +++ b/crates/wpt-runner/src/main.rs @@ -32,6 +32,7 @@ const ENCODING_TABLE: &str = r#"const encodings_table = } ]"#; const REQUEST_CACHE: &str = include_str!("../../../tools/wpt/fetch/api/request/request-cache.js"); +const REQUEST_ERROR: &str = include_str!("../../../tools/wpt/fetch/api/request/request-error.js"); const SUBSET_TESTS: &str = include_str!("../../../tools/wpt/common/subset-tests.js"); const DECODING_HELPERS: &str = include_str!("../../../tools/wpt/encoding/resources/decoding-helpers.js"); @@ -49,26 +50,21 @@ static TEST_HARNESS: Lazy = Lazy::new(|| { .replace("debug: false", "debug: true") }); -const SKIP_TESTS: [&str; 17] = [ - // request - "request-error.any.js", // "badRequestArgTests is not defined" - "request-init-stream.any.js", // "request.body.getReader is not a function" - "request-consume-empty.any.js", // "Unexpected end of JSON input" - "request-consume.any.js", // "Unexpected end of JSON input" - "request-init-priority.any.js", // "idx is not defined" +const SKIP_TESTS: [&str; 13] = [ // response "response-cancel-stream.any.js", // "undefined" "response-error-from-stream.any.js", // "Start error" "response-stream-with-broken-then.any.js", // "Cannot destructure property 'done' of 'undefined' as it is undefine" // url - "idlharness.any.js", // load webidl stuff, not supported - "url-setters.any.js", // fetch an json file, find a way to run it + "idlharness.any.js", // load webidl stuff, not supported + "url-setters.any.js", // fetch an json file, find a way to run it + "url-setters-stripping.any.js", // stripping every field is not supported // encoding "textdecoder-utf16-surrogates.any.js", // we only support utf-8 "textencoder-utf16-surrogates.any.js", // we only support utf-8 "iso-2022-jp-decoder.any.js", // we only support utf-8 "encodeInto.any.js", // TextEncoder#encodeInto isn't implemented yet - "textdecoder-fatal-single-byte.any.js", // have a random number of tests? + "textdecoder-fatal-single-byte.any.js", // lots of test that we don't really need // event "EventTarget-removeEventListener.any.js", // removeEventListener does not exists on the global object // headers @@ -98,11 +94,13 @@ async fn run_test(path: &Path) { isWindow: () => false, }} globalThis.location = {{}} +globalThis.idx = undefined; export function handler() {{ {} {ENCODING_TABLE} {REQUEST_CACHE} + {REQUEST_ERROR} {SUBSET_TESTS} {DECODING_HELPERS} {SUPPORT_BLOB} @@ -212,16 +210,20 @@ async fn main() { let result = RESULT.lock().unwrap(); println!(); println!( - "{} tests, {} passed, {} failed", + "{} tests, {} passed, {} failed ({} not completed)", result.0, result.1.to_string().green(), - result.2.to_string().red() + result.2.to_string().red(), + result.0 - (result.1 + result.2) ); if result.2 == 0 { println!(" -> 100% conformance"); } else { - println!(" -> {}% conformance", (result.1 * 100) / result.0); + println!( + " -> {}% conformance", + (result.1 * 100) / (result.1 + result.2) + ); } runtime.dispose(); From ae260f4b9c3c188eb322dfa9ab125f386a41f498 Mon Sep 17 00:00:00 2001 From: QuiiBz Date: Sun, 7 May 2023 16:40:03 +0200 Subject: [PATCH 08/18] feat: ignore non-utf8 textencoder --- crates/wpt-runner/current-results.md | 18 ++---------------- crates/wpt-runner/src/main.rs | 3 ++- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/crates/wpt-runner/current-results.md b/crates/wpt-runner/current-results.md index 106742b50..612d71178 100644 --- a/crates/wpt-runner/current-results.md +++ b/crates/wpt-runner/current-results.md @@ -1063,21 +1063,7 @@ Running ../../tools/wpt/encoding/textencoder-constructor-non-utf.any.js TEST DONE 0 Encoding argument supported for decode: UTF-8 TEST DONE 0 Encoding argument not considered for encode: UTF-8 Skipping ../../tools/wpt/encoding/textencoder-utf16-surrogates.any.js -Running ../../tools/wpt/encoding/unsupported-encodings.any.js -TEST DONE 1 UTF-7 should not be supported -TEST DONE 1 utf-7 should not be supported -TEST DONE 1 UTF-32 with BOM should decode as UTF-16LE -TEST DONE 1 UTF-32 with no BOM should decode as UTF-8 -TEST DONE 1 utf-32 with BOM should decode as UTF-16LE -TEST DONE 1 utf-32 with no BOM should decode as UTF-8 -TEST DONE 1 UTF-32LE with BOM should decode as UTF-16LE -TEST DONE 1 UTF-32LE with no BOM should decode as UTF-8 -TEST DONE 1 utf-32le with BOM should decode as UTF-16LE -TEST DONE 1 utf-32le with no BOM should decode as UTF-8 -TEST DONE 1 UTF-32be with no BOM should decode as UTF-8 -TEST DONE 1 UTF-32be with BOM should decode as UTF-8 -TEST DONE 1 utf-32be with no BOM should decode as UTF-8 -TEST DONE 1 utf-32be with BOM should decode as UTF-8 +Skipping ../../tools/wpt/encoding/unsupported-encodings.any.js Running ../../tools/wpt/FileAPI/blob/Blob-array-buffer.any.js TEST DONE 0 Blob.arrayBuffer() TEST DONE 0 Blob.arrayBuffer() empty Blob data @@ -1460,5 +1446,5 @@ Running ../../tools/wpt/urlpattern/urlpattern-compare.https.any.js Running ../../tools/wpt/urlpattern/urlpattern.any.js Running ../../tools/wpt/urlpattern/urlpattern.https.any.js -1340 tests, 600 passed, 727 failed (13 not completed) +1326 tests, 600 passed, 713 failed (13 not completed) -> 45% conformance diff --git a/crates/wpt-runner/src/main.rs b/crates/wpt-runner/src/main.rs index c38f86033..5c66f0fa5 100644 --- a/crates/wpt-runner/src/main.rs +++ b/crates/wpt-runner/src/main.rs @@ -50,7 +50,7 @@ static TEST_HARNESS: Lazy = Lazy::new(|| { .replace("debug: false", "debug: true") }); -const SKIP_TESTS: [&str; 13] = [ +const SKIP_TESTS: [&str; 14] = [ // response "response-cancel-stream.any.js", // "undefined" "response-error-from-stream.any.js", // "Start error" @@ -65,6 +65,7 @@ const SKIP_TESTS: [&str; 13] = [ "iso-2022-jp-decoder.any.js", // we only support utf-8 "encodeInto.any.js", // TextEncoder#encodeInto isn't implemented yet "textdecoder-fatal-single-byte.any.js", // lots of test that we don't really need + "unsupported-encodings.any.js", // we only support utf-8 // event "EventTarget-removeEventListener.any.js", // removeEventListener does not exists on the global object // headers From 624e79eaf1833099979f668bef5f1d79e73d0a42 Mon Sep 17 00:00:00 2001 From: Tom Lienard Date: Mon, 8 May 2023 08:51:25 +0200 Subject: [PATCH 09/18] feat(cli): design & UX overhaul (#840) --- .changeset/funny-waves-confess.md | 5 ++ .changeset/great-cars-design.md | 5 ++ .changeset/tame-planets-wave.md | 5 ++ Cargo.lock | 45 ++--------- crates/cli/Cargo.toml | 4 +- crates/cli/src/commands/build.rs | 33 ++++---- crates/cli/src/commands/deploy.rs | 37 ++++----- crates/cli/src/commands/dev.rs | 81 ++++++++++++-------- crates/cli/src/commands/link.rs | 27 ++++--- crates/cli/src/commands/login.rs | 38 +++++---- crates/cli/src/commands/logout.rs | 19 +++-- crates/cli/src/commands/ls.rs | 45 +++++------ crates/cli/src/commands/promote.rs | 29 ++++--- crates/cli/src/commands/rm.rs | 28 +++---- crates/cli/src/commands/undeploy.rs | 24 +++--- crates/cli/src/main.rs | 13 ++-- crates/cli/src/utils/console.rs | 80 +++++++++++-------- crates/cli/src/utils/deployments.rs | 115 ++++++++++++++++------------ crates/cli/src/utils/mod.rs | 6 +- crates/cli/src/utils/trpc.rs | 5 +- crates/runtime_http/src/lib.rs | 3 +- crates/runtime_http/src/request.rs | 11 +-- crates/runtime_http/src/response.rs | 3 +- crates/wpt-runner/Cargo.toml | 2 +- crates/wpt-runner/src/main.rs | 14 ++-- 25 files changed, 355 insertions(+), 322 deletions(-) create mode 100644 .changeset/funny-waves-confess.md create mode 100644 .changeset/great-cars-design.md create mode 100644 .changeset/tame-planets-wave.md diff --git a/.changeset/funny-waves-confess.md b/.changeset/funny-waves-confess.md new file mode 100644 index 000000000..c52988e1a --- /dev/null +++ b/.changeset/funny-waves-confess.md @@ -0,0 +1,5 @@ +--- +'@lagon/cli': minor +--- + +Introduce a brand new design diff --git a/.changeset/great-cars-design.md b/.changeset/great-cars-design.md new file mode 100644 index 000000000..e59c2d9d6 --- /dev/null +++ b/.changeset/great-cars-design.md @@ -0,0 +1,5 @@ +--- +'@lagon/cli': patch +--- + +Pre-select confirmation inputs diff --git a/.changeset/tame-planets-wave.md b/.changeset/tame-planets-wave.md new file mode 100644 index 000000000..8dc07b316 --- /dev/null +++ b/.changeset/tame-planets-wave.md @@ -0,0 +1,5 @@ +--- +'@lagon/cli': patch +--- + +Improve UX by showing file errors instead of exiting immediately diff --git a/Cargo.lock b/Cargo.lock index c8923b2df..833e8ecfa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -193,17 +193,6 @@ dependencies = [ "url", ] -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -618,17 +607,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" -[[package]] -name = "colored" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd" -dependencies = [ - "atty", - "lazy_static", - "winapi", -] - [[package]] name = "combine" version = "4.6.6" @@ -645,16 +623,15 @@ dependencies = [ [[package]] name = "console" -version = "0.15.1" +version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89eab4d20ce20cea182308bca13088fecea9c05f6776cf287205d41a0ed3c847" +checksum = "c3d79fbe8970a77e3e34151cc13d3b3e248aa0faaecb9f6091fa07ebefe5ad60" dependencies = [ "encode_unicode", + "lazy_static", "libc", - "once_cell", - "terminal_size", "unicode-width", - "winapi", + "windows-sys 0.42.0", ] [[package]] @@ -1622,7 +1599,6 @@ dependencies = [ "anyhow", "chrono", "clap", - "colored", "dialoguer", "dirs 5.0.1", "envfile", @@ -1635,6 +1611,7 @@ dependencies = [ "lagon-runtime-isolate", "lagon-runtime-utils", "notify", + "once_cell", "pathdiff", "serde", "serde_json", @@ -1794,7 +1771,7 @@ dependencies = [ name = "lagon-wpt-runner" version = "0.1.0" dependencies = [ - "colored", + "console", "flume", "lagon-runtime", "lagon-runtime-http", @@ -3316,16 +3293,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "terminal_size" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "thiserror" version = "1.0.34" diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 8877671a4..487e844e2 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -9,9 +9,8 @@ lagon-runtime-http = { path = "../runtime_http" } lagon-runtime-isolate = { path = "../runtime_isolate" } lagon-runtime-utils = { path = "../runtime_utils" } clap = { version = "4.2.7", features = ["derive"] } -dialoguer = "0.10.4" +dialoguer = { version = "0.10.4", features = ["password"] } indicatif = "0.17.3" -colored = "2.0.0" dirs = "5.0.1" webbrowser = "0.8.9" tokio = { version = "1", features = ["rt-multi-thread", "macros", "sync"] } @@ -27,3 +26,4 @@ notify = "5.1.0" envfile = "0.2.1" anyhow = "1.0.71" urlencoding = "2.1.2" +once_cell = "1.17.1" diff --git a/crates/cli/src/commands/build.rs b/crates/cli/src/commands/build.rs index 5b5a2401c..a36aede2a 100644 --- a/crates/cli/src/commands/build.rs +++ b/crates/cli/src/commands/build.rs @@ -1,8 +1,7 @@ -use std::{fs, path::PathBuf}; - +use crate::utils::{bundle_function, print_progress, resolve_path}; use anyhow::{anyhow, Result}; - -use crate::utils::{bundle_function, debug, print_progress, resolve_path, success}; +use dialoguer::console::style; +use std::{fs, path::PathBuf}; pub fn build( path: Option, @@ -12,33 +11,29 @@ pub fn build( let (root, function_config) = resolve_path(path, client, public_dir)?; let (index, assets) = bundle_function(&function_config, &root, true)?; - let end_progress = print_progress("Writting index.js..."); - - fs::create_dir_all(root.join(".lagon"))?; - fs::write(root.join(".lagon").join("index.js"), index)?; + let end_progress = print_progress("Writting files"); + let root = root.join(".lagon"); - end_progress(); + fs::create_dir_all(&root)?; + fs::write(root.join("index.js"), index)?; for (path, content) in assets { - let message = format!("Writting {path}..."); - let end_progress = print_progress(&message); - - let dir = root.join(".lagon").join("public").join( + let dir = root.join("public").join( PathBuf::from(&path) .parent() .ok_or_else(|| anyhow!("Could not find parent of {}", path))?, ); fs::create_dir_all(dir)?; - fs::write(root.join(".lagon").join("public").join(path), content)?; - - end_progress(); + fs::write(root.join("public").join(path), content)?; } + end_progress(); + println!(); + println!(" {} Build successful!", style("◼").magenta()); println!( - "{} {}", - success("Build successful!"), - debug("You can find it in .lagon folder.") + " {}", + style(format!("You can find it in {:?}", root)).black() ); Ok(()) diff --git a/crates/cli/src/commands/deploy.rs b/crates/cli/src/commands/deploy.rs index 1ee29f460..99ed47968 100644 --- a/crates/cli/src/commands/deploy.rs +++ b/crates/cli/src/commands/deploy.rs @@ -1,16 +1,12 @@ +use crate::utils::{create_deployment, print_progress, resolve_path, Config, TrpcClient, THEME}; +use anyhow::{anyhow, Result}; +use dialoguer::{console::style, Confirm, Input, Select}; +use serde::{Deserialize, Serialize}; use std::{ fmt::{Display, Formatter}, path::PathBuf, }; -use anyhow::{anyhow, Result}; -use dialoguer::{Confirm, Input, Select}; -use serde::{Deserialize, Serialize}; - -use crate::utils::{ - create_deployment, debug, info, print_progress, resolve_path, Config, TrpcClient, -}; - #[derive(Deserialize, Debug)] pub struct Organization { pub name: String, @@ -69,7 +65,10 @@ pub async fn deploy( let (root, mut function_config) = resolve_path(path, client, public_dir)?; if function_config.function_id.is_empty() { - println!("{}", debug("No deployment config found...")); + println!( + "{}", + style("No previous Deployment found...").black().bright() + ); println!(); let trpc_client = TrpcClient::new(config.clone()); @@ -78,15 +77,16 @@ pub async fn deploy( .await?; let organizations = response.result.data; - let index = Select::new() + let index = Select::with_theme(&*THEME) .items(&organizations) .default(0) - .with_prompt(info("Select an Organization to deploy to")) + .with_prompt("Which Organization would you like to deploy to?") .interact()?; let organization = &organizations[index]; - match Confirm::new() - .with_prompt(info("Link to an existing Function?")) + match Confirm::with_theme(&*THEME) + .with_prompt("Link to an existing Function?") + .default(false) .interact()? { true => { @@ -95,10 +95,10 @@ pub async fn deploy( .await?; let functions = response.result.data; - let index = Select::new() + let index = Select::with_theme(&*THEME) .items(&functions) .default(0) - .with_prompt(info("Select a Function to link from")) + .with_prompt("Which Function would you like to link?") .interact()?; let function = &functions[index]; @@ -106,15 +106,16 @@ pub async fn deploy( function_config.organization_id = organization.id.clone(); function_config.write(&root)?; + println!(); create_deployment(config, &function_config, is_production, &root, true).await?; } false => { - let name = Input::::new() - .with_prompt(info("What is the name of this new Function?")) + let name = Input::::with_theme(&*THEME) + .with_prompt("What's the name of this new Function?") .interact_text()?; println!(); - let message = format!("Creating Function {name}..."); + let message = format!("Creating Function {name}"); let end_progress = print_progress(&message); let response = trpc_client diff --git a/crates/cli/src/commands/dev.rs b/crates/cli/src/commands/dev.rs index 4db4e0d8f..85b99df92 100644 --- a/crates/cli/src/commands/dev.rs +++ b/crates/cli/src/commands/dev.rs @@ -1,6 +1,7 @@ +use crate::utils::{bundle_function, resolve_path, Assets}; use anyhow::{anyhow, Error, Result}; use chrono::offset::Local; -use colored::Colorize; +use dialoguer::console::style; use envfile::EnvFile; use hyper::server::conn::AddrStream; use hyper::service::{make_service_fn, service_fn}; @@ -21,10 +22,6 @@ use std::time::Duration; use tokio::runtime::Handle; use tokio::sync::Mutex; -use crate::utils::{ - bundle_function, debug, error, info, input, resolve_path, success, warn, Assets, -}; - const LOCAL_REGION: &str = "local"; fn parse_environment_variables( @@ -39,12 +36,17 @@ fn parse_environment_variables( for (key, value) in envfile.store { environment_variables.insert(key, value); } + + println!("{}", style("Loaded .env file...").black().bright()); } else if let Ok(envfile) = EnvFile::new(root.join(".env")) { for (key, value) in envfile.store { environment_variables.insert(key, value); } - println!("{}", debug("Automatically loaded .env file...")); + println!( + "{}", + style("Automatically loaded .env file...").black().bright() + ); } Ok(environment_variables) @@ -62,20 +64,19 @@ async fn handle_request( ) -> Result> { let url = req.uri().path(); - println!( - "{} {} {}", - format!("{}", Local::now().time()).bright_black(), - req.method().to_string().blue(), - url - ); - let (tx, rx) = flume::unbounded(); let assets = assets.lock().await.to_owned(); let is_favicon = url == FAVICON_URL; if let Some(asset) = find_asset(url, &assets.keys().cloned().collect()) { - println!(" {}", input("Asset found")); + println!( + "{} {} {} {}", + style(format!("{}", Local::now().time())).black(), + style(req.method().to_string()).blue(), + style(url).black().bright(), + style("(asset)").black().bright() + ); let run_result = match handle_asset(public_dir.unwrap(), asset) { Ok(response) => RunResult::Response(response, None), @@ -94,6 +95,13 @@ async fn handle_request( .await .unwrap_or(()); } else { + println!( + "{} {} {}", + style(format!("{}", Local::now().time())).black(), + style(req.method().to_string()).blue(), + url + ); + match Request::from_hyper(req).await { Ok(mut request) => { request.set_header(X_FORWARDED_FOR.to_string(), ip); @@ -121,22 +129,29 @@ async fn handle_request( match event { ResponseEvent::StreamDoneNoDataError => { println!( - "{}", - error("The stream was done before sending a response/data") + "{} The stream was done before sending a response/data", + style("✕").red() ); } ResponseEvent::UnexpectedStreamResult(result) => { - println!("{} {:?}", error("Unexpected stream result:"), result); + println!( + "{} Unexpected stream result: {:?}", + style("✕").red(), + result + ); } ResponseEvent::LimitsReached(result) => { if result == RunResult::Timeout { - println!("{}", error("Function execution timed out")); + println!("{} Function execution timed out", style("✕").red()); } else { - println!("{}", error("Function execution reached memory limit")); + println!( + "{} Function execution reached memory limit", + style("✕").red() + ); } } ResponseEvent::Error(result) => { - println!("{}", error(result.as_error().as_str())); + println!("{} {}", style("✕").red(), result.as_error().as_str()); } _ => {} } @@ -220,9 +235,9 @@ pub async fn dev( while let Ok(log) = log_receiver.recv_async().await { let (level, message, ..) = log; let level = match level.as_str() { - "error" => "ERROR".red(), - "warn" => "WARN".yellow(), - _ => level.to_uppercase().blue(), + "error" => style("ERROR".into()).red(), + "warn" => style("WARN".into()).yellow(), + _ => style(level.to_uppercase()).blue(), }; println!("{} {}", level, message); @@ -273,12 +288,16 @@ pub async fn dev( if should_update { // Clear the screen and put the cursor at first row & first col of the screen. print!("\x1B[2J\x1B[1;1H"); - println!("{}", info("Found change, updating...")); + println!("{}", style("File modified, updating...").black().bright()); let (new_index, new_assets) = bundle_function(&function_config, &root, prod)?; *assets.lock().await = new_assets; index_tx.send_async(new_index).await.unwrap(); + + println!(); + println!(" {} Dev Server ready!", style("◼").magenta()); + println!(); } } @@ -286,21 +305,23 @@ pub async fn dev( }); println!(); - println!("{}", success("Dev Server started!")); + println!(" {} Dev Server started!", style("◼").magenta()); if allow_code_generation { println!( - "{}", - warn("Code generation is allowed due to `--allow-code-generation`") + " {} {}", + style("Code generation is allowed due to").yellow(), + style("--allow-code-generation").black().bright() ); } println!(); println!( - " {} {}", - "➤".bright_black(), - format!("http://{addr}").blue() + "{} {}", + style("›").black().bright(), + style(format!("http://{addr}")).blue().underlined() ); + println!(); server.await?; runtime.dispose(); diff --git a/crates/cli/src/commands/link.rs b/crates/cli/src/commands/link.rs index ca72e768e..7d1967b58 100644 --- a/crates/cli/src/commands/link.rs +++ b/crates/cli/src/commands/link.rs @@ -1,13 +1,10 @@ -use std::path::PathBuf; - -use anyhow::{anyhow, Result}; - -use dialoguer::Select; - use crate::{ commands::deploy::{FunctionsResponse, OrganizationsResponse}, - utils::{get_root, info, success, Config, FunctionConfig, TrpcClient}, + utils::{get_root, Config, FunctionConfig, TrpcClient, THEME}, }; +use anyhow::{anyhow, Result}; +use dialoguer::{console::style, Select}; +use std::path::PathBuf; pub async fn link(directory: Option) -> Result<()> { let config = Config::new()?; @@ -19,9 +16,10 @@ pub async fn link(directory: Option) -> Result<()> { } let root = get_root(directory); + let function_config = FunctionConfig::load(&root, None, None)?; - match root.join(".lagon").join("config.json").exists() { - true => Err(anyhow!("This directory is already linked to a Function.")), + match !function_config.function_id.is_empty() { + true => Err(anyhow!("This directory is already linked to a Function")), false => { let trpc_client = TrpcClient::new(config); let response = trpc_client @@ -29,10 +27,10 @@ pub async fn link(directory: Option) -> Result<()> { .await?; let organizations = response.result.data; - let index = Select::new() + let index = Select::with_theme(&*THEME) .items(&organizations) .default(0) - .with_prompt(info("Select an Organization to link from")) + .with_prompt("Which Organization would you like to link from?") .interact()?; let organization = &organizations[index]; @@ -41,10 +39,10 @@ pub async fn link(directory: Option) -> Result<()> { .await?; let functions = response.result.data; - let index = Select::new() + let index = Select::with_theme(&*THEME) .items(&functions) .default(0) - .with_prompt(info("Select a Function to link from")) + .with_prompt("Which Function would you like to link?") .interact()?; let function = &functions[index]; @@ -53,7 +51,8 @@ pub async fn link(directory: Option) -> Result<()> { function_config.organization_id = organization.id.clone(); function_config.write(&root)?; - println!("{}", success("Function linked!")); + println!(); + println!(" {} Function linked!", style("◼").magenta()); Ok(()) } diff --git a/crates/cli/src/commands/login.rs b/crates/cli/src/commands/login.rs index abdaddd93..73c1965d0 100644 --- a/crates/cli/src/commands/login.rs +++ b/crates/cli/src/commands/login.rs @@ -1,9 +1,8 @@ +use crate::utils::{print_progress, Config, TrpcClient, THEME}; use anyhow::{anyhow, Result}; -use dialoguer::{Confirm, Password}; +use dialoguer::{console::style, Confirm, Password}; use serde::{Deserialize, Serialize}; -use crate::utils::{debug, error, info, input, print_progress, success, Config, TrpcClient}; - #[derive(Deserialize, Debug)] struct CliResponse { token: String, @@ -18,34 +17,36 @@ pub async fn login() -> Result<()> { let mut config = Config::new()?; if config.token.is_some() - && !Confirm::new() - .with_prompt(info( - "You are already logged in. Are you sure you want to log in again?", - )) + && !Confirm::with_theme(&*THEME) + .with_prompt("You are already logged in. Do you want to log out and log in again?") + .default(true) .interact()? { - return Err(anyhow!("Login aborted.")); + println!(); + println!("{} Login aborted", style("✕").red()); + return Ok(()); } println!(); - let end_progress = print_progress("Opening browser..."); + let end_progress = print_progress("Opening browser"); let url = config.site_url.clone() + "/cli"; if webbrowser::open(&url).is_err() { - println!("{}", error("Couldn't open browser.")); + println!("{} Could not open browser", style("✕").red()); } end_progress(); - - println!(); println!( "{}", - info(&format!("Please copy and paste the verification from your browser. You can also manually visit {}", url)) + style(format!(" You can also manually access {}", url)) + .black() + .bright() ); + println!(); - let code = Password::new() - .with_prompt(input("Verification code")) + let code = Password::with_theme(&*THEME) + .with_prompt("Paste the verification code from your browser here") .interact()?; config.set_token(Some(code.clone())); @@ -62,11 +63,8 @@ pub async fn login() -> Result<()> { config.save()?; println!(); - println!( - "{} {}", - success("You are now logged in."), - debug("You can close your browser tab.") - ); + println!(" {} You are now logged in!", style("◼").magenta()); + println!(" {}", style("You can now close the browser tab").black()); Ok(()) } diff --git a/crates/cli/src/commands/logout.rs b/crates/cli/src/commands/logout.rs index 393f249d3..6b216ad35 100644 --- a/crates/cli/src/commands/logout.rs +++ b/crates/cli/src/commands/logout.rs @@ -1,8 +1,6 @@ +use crate::utils::{Config, THEME}; use anyhow::{anyhow, Result}; - -use dialoguer::Confirm; - -use crate::utils::{info, success, Config}; +use dialoguer::{console::style, Confirm}; pub fn logout() -> Result<()> { let mut config = Config::new()?; @@ -11,8 +9,9 @@ pub fn logout() -> Result<()> { return Err(anyhow!("You are not logged in.")); } - match Confirm::new() - .with_prompt(info("Are you sure you want to log out?")) + match Confirm::with_theme(&*THEME) + .with_prompt("Do you really want to log out?") + .default(true) .interact()? { true => { @@ -20,10 +19,14 @@ pub fn logout() -> Result<()> { config.save()?; println!(); - println!("{}", success("You have been logged out.")); + println!(" {} You have been logged out!", style("◼").magenta()); Ok(()) } - false => Err(anyhow!("Logout aborted.")), + false => { + println!(); + println!("{} Logout aborted", style("✕").red()); + Ok(()) + } } } diff --git a/crates/cli/src/commands/ls.rs b/crates/cli/src/commands/ls.rs index 72c739d35..90e38ba2d 100644 --- a/crates/cli/src/commands/ls.rs +++ b/crates/cli/src/commands/ls.rs @@ -1,11 +1,8 @@ -use std::path::PathBuf; - +use crate::utils::{get_root, print_progress, Config, FunctionConfig, TrpcClient}; use anyhow::{anyhow, Result}; -use colored::Colorize; - +use dialoguer::console::style; use serde::{Deserialize, Serialize}; - -use crate::utils::{error, get_root, print_progress, Config, FunctionConfig, TrpcClient}; +use std::path::PathBuf; #[derive(Deserialize, Debug)] struct Function { @@ -39,7 +36,7 @@ pub async fn ls(directory: Option) -> Result<()> { let root = get_root(directory); let function_config = FunctionConfig::load(&root, None, None)?; - let end_progress = print_progress("Fetching deployments..."); + let end_progress = print_progress("Fetching Deployments"); let function = TrpcClient::new(config) .query::( @@ -52,32 +49,36 @@ pub async fn ls(directory: Option) -> Result<()> { end_progress(); println!(); + println!(" {} List of Deployments:", style("◼").magenta()); + println!(); let deployments = function.result.data.deployments; if deployments.is_empty() { - println!("{}", error("No deployments found.")); + println!("{} No deployments found", style("✕").red()); } else { for deployment in deployments { if deployment.is_production { println!( - "{} {} {}{}, {}{}", - "•".green(), - deployment.id, - "(".bright_black(), - deployment.created_at.bright_black(), - "production".green(), - ")".bright_black() + "{} Production: {} {}", + style("●").black().bright(), + style(format!("https://{}.lagon.dev", deployment.id)) + .blue() + .underlined(), + style(format!("({})", deployment.created_at)) + .black() + .bright(), ); } else { println!( - "{} {} {}{}, {}{}", - "•".blue(), - deployment.id, - "(".bright_black(), - deployment.created_at.bright_black(), - "preview".blue(), - ")".bright_black() + "{} Preview: {} {}", + style("○").black().bright(), + style(format!("https://{}.lagon.dev", deployment.id)) + .blue() + .underlined(), + style(format!("({})", deployment.created_at)) + .black() + .bright(), ); } } diff --git a/crates/cli/src/commands/promote.rs b/crates/cli/src/commands/promote.rs index 2db892c9a..33bbe6657 100644 --- a/crates/cli/src/commands/promote.rs +++ b/crates/cli/src/commands/promote.rs @@ -1,10 +1,8 @@ +use crate::utils::{get_root, print_progress, Config, FunctionConfig, TrpcClient, THEME}; use anyhow::{anyhow, Result}; -use dialoguer::Confirm; -use std::path::PathBuf; - +use dialoguer::{console::style, Confirm}; use serde::{Deserialize, Serialize}; - -use crate::utils::{get_root, info, print_progress, success, Config, FunctionConfig, TrpcClient}; +use std::path::PathBuf; #[derive(Serialize, Debug)] #[serde(rename_all = "camelCase")] @@ -31,14 +29,14 @@ pub async fn promote(deployment_id: String, directory: Option) -> Resul let root = get_root(directory); let function_config = FunctionConfig::load(&root, None, None)?; - match Confirm::new() - .with_prompt(info( - "Are you sure you want to promote this Deployment to production?", - )) + match Confirm::with_theme(&*THEME) + .with_prompt("Do you really want to promote this Deployment to production?") + .default(true) .interact()? { true => { - let end_progress = print_progress("Promoting Deployment..."); + println!(); + let end_progress = print_progress("Promoting Deployment"); TrpcClient::new(config) .mutation::( "deploymentPromote", @@ -51,10 +49,17 @@ pub async fn promote(deployment_id: String, directory: Option) -> Resul end_progress(); println!(); - println!("{}", success("Deployment promoted to production!")); + println!( + " {} Deployment promoted to production!", + style("◼").magenta() + ); Ok(()) } - false => Err(anyhow!("Promotion aborted.")), + false => { + println!(); + println!("{} Promotion aborted", style("✕").red()); + Ok(()) + } } } diff --git a/crates/cli/src/commands/rm.rs b/crates/cli/src/commands/rm.rs index 47fdb72ae..00f11b4af 100644 --- a/crates/cli/src/commands/rm.rs +++ b/crates/cli/src/commands/rm.rs @@ -1,11 +1,8 @@ -use std::path::PathBuf; - +use crate::utils::{get_root, print_progress, Config, FunctionConfig, TrpcClient, THEME}; use anyhow::{anyhow, Result}; - -use dialoguer::Confirm; +use dialoguer::{console::style, Confirm}; use serde::{Deserialize, Serialize}; - -use crate::utils::{get_root, info, print_progress, success, Config, FunctionConfig, TrpcClient}; +use std::path::PathBuf; #[derive(Serialize, Debug)] #[serde(rename_all = "camelCase")] @@ -31,14 +28,15 @@ pub async fn rm(directory: Option) -> Result<()> { let root = get_root(directory); let function_config = FunctionConfig::load(&root, None, None)?; - match Confirm::new() - .with_prompt(info( - "Are you sure you want to completely delete this Function?", - )) + match Confirm::with_theme(&*THEME) + .with_prompt( + "Do you really want to completely delete this Function, its Deployments, statistics and logs?", + ) + .default(false) .interact()? { true => { - let end_progress = print_progress("Deleting Function..."); + let end_progress = print_progress("Deleting Function"); TrpcClient::new(config) .mutation::( "functionDelete", @@ -52,10 +50,14 @@ pub async fn rm(directory: Option) -> Result<()> { function_config.delete(&root)?; println!(); - println!("{}", success("Function deleted.")); + println!(" {} Function deleted!", style("◼").magenta()); Ok(()) } - false => Err(anyhow!("Deletion aborted.")), + false => { + println!(); + println!("{} Deletion aborted", style("✕").red()); + Ok(()) + }, } } diff --git a/crates/cli/src/commands/undeploy.rs b/crates/cli/src/commands/undeploy.rs index cc39da4d9..18af0fdf9 100644 --- a/crates/cli/src/commands/undeploy.rs +++ b/crates/cli/src/commands/undeploy.rs @@ -1,11 +1,8 @@ -use std::path::PathBuf; - +use crate::utils::{get_root, print_progress, Config, FunctionConfig, TrpcClient, THEME}; use anyhow::{anyhow, Result}; -use dialoguer::Confirm; - +use dialoguer::{console::style, Confirm}; use serde::{Deserialize, Serialize}; - -use crate::utils::{get_root, info, print_progress, success, Config, FunctionConfig, TrpcClient}; +use std::path::PathBuf; #[derive(Serialize, Debug)] #[serde(rename_all = "camelCase")] @@ -32,12 +29,13 @@ pub async fn undeploy(deployment_id: String, directory: Option) -> Resu let root = get_root(directory); let function_config = FunctionConfig::load(&root, None, None)?; - match Confirm::new() - .with_prompt(info("Are you sure you want to delete this Deployment?")) + match Confirm::with_theme(&*THEME) + .with_prompt("Do you really want to delete this Deployment?") + .default(false) .interact()? { true => { - let end_progress = print_progress("Deleting Deployment..."); + let end_progress = print_progress("Deleting Deployment"); TrpcClient::new(config) .mutation::( "deploymentUndeploy", @@ -50,10 +48,14 @@ pub async fn undeploy(deployment_id: String, directory: Option) -> Resu end_progress(); println!(); - println!("{}", success("Deployment deleted.")); + println!(" {} Deployment deleted!", style("◼").magenta()); Ok(()) } - false => Err(anyhow!("Deletion aborted.")), + false => { + println!(); + println!("{} Deletion aborted", style("✕").red()); + Ok(()) + } } } diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index 23cee34d6..6e69fd80f 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -1,9 +1,7 @@ -use std::{path::PathBuf, process::exit}; - use clap::{Parser, Subcommand}; +use dialoguer::console::style; use serde::Deserialize; - -use crate::utils::error; +use std::{path::PathBuf, process::exit}; mod commands; mod utils; @@ -174,7 +172,7 @@ async fn main() { directory, } => commands::promote(deployment_id, directory).await, } { - println!("{}", error(&err.to_string())); + println!("{} {}", style("✕").red(), err); exit(1); } } else { @@ -183,7 +181,10 @@ async fn main() { println!("{version}"); } _ => { - println!("{}", error("Couldn't extract version from package.json")); + println!( + "{} Couldn't extract version from package.json", + style("✕").red(), + ); exit(1); } } diff --git a/crates/cli/src/utils/console.rs b/crates/cli/src/utils/console.rs index e2fd7a773..b6def7431 100644 --- a/crates/cli/src/utils/console.rs +++ b/crates/cli/src/utils/console.rs @@ -1,41 +1,59 @@ -use colored::Colorize; +use dialoguer::{ + console::{style, Style}, + theme::ColorfulTheme, +}; use indicatif::{ProgressBar, ProgressStyle}; - -pub fn info(message: &str) -> String { - format!("{} {}", "?".blue(), message) -} - -pub fn input(message: &str) -> String { - format!(" {} {}", "↳".bright_black(), message.bright_black()) -} - -pub fn debug(message: &str) -> String { - message.bright_black().to_string() -} - -pub fn debug_success(message: &str) -> String { - format!("{} {}", "✓".green(), message.bright_black()) -} - -pub fn success(message: &str) -> String { - format!("{} {}", "✓".green(), message) -} - -pub fn error(message: &str) -> String { - format!("{} {}", "✖".red(), message) -} - -pub fn warn(message: &str) -> String { - format!("{} {}", "○".yellow(), message) -} +use once_cell::sync::Lazy; +use std::time::Duration; pub fn print_progress(message: &str) -> impl Fn() + '_ { let index_progress = ProgressBar::new_spinner(); index_progress.set_style(ProgressStyle::default_spinner()); - index_progress.set_message(debug(message)); + index_progress.set_message( + style(format!("{}...", message)) + .black() + .bright() + .to_string(), + ); + index_progress.tick(); + + let handle = index_progress.clone(); + + tokio::task::spawn(async move { + loop { + if handle.is_finished() { + break; + } + + handle.tick(); + tokio::time::sleep(Duration::from_millis(10)).await; + } + }); move || { index_progress.finish_and_clear(); - println!("{}", debug_success(message)); + println!("{} {}", style("✓").green(), style(message).black().bright()); } } + +pub static THEME: Lazy = Lazy::new(|| ColorfulTheme { + defaults_style: Style::new().for_stderr().blue(), + prompt_style: Style::new().for_stderr().bold(), + prompt_prefix: style(" ○".to_string()).for_stderr().magenta(), + prompt_suffix: style("›".to_string()).for_stderr().black(), + success_prefix: style(" ●".to_string()).for_stderr().magenta(), + success_suffix: style("›".to_string()).for_stderr().black(), + error_prefix: style("✕".to_string()).for_stderr().red(), + error_style: Style::new().for_stderr(), + hint_style: Style::new().for_stderr().black().bright(), + values_style: Style::new().for_stderr().blue(), + active_item_style: Style::new().for_stderr().blue(), + inactive_item_style: Style::new().for_stderr(), + active_item_prefix: style("›".to_string()).for_stderr().blue(), + inactive_item_prefix: style(" ".to_string()).for_stderr(), + checked_item_prefix: style("✔".to_string()).for_stderr().green(), + unchecked_item_prefix: style("✔".to_string()).for_stderr().black(), + picked_item_prefix: style("❯".to_string()).for_stderr().green(), + unpicked_item_prefix: style(" ".to_string()).for_stderr(), + inline_selections: true, +}); diff --git a/crates/cli/src/utils/deployments.rs b/crates/cli/src/utils/deployments.rs index 7616a9505..632e8b319 100644 --- a/crates/cli/src/utils/deployments.rs +++ b/crates/cli/src/utils/deployments.rs @@ -1,7 +1,13 @@ +use super::{ + validate_assets_dir, validate_code_file, Config, MAX_ASSET_SIZE_MB, MAX_FUNCTION_SIZE_MB, +}; +use crate::utils::{print_progress, TrpcClient, THEME}; use anyhow::{anyhow, Result}; -use colored::Colorize; +use dialoguer::console::style; use dialoguer::{Confirm, Input}; use hyper::{Body, Method, Request}; +use pathdiff::diff_paths; +use serde::{Deserialize, Serialize}; use std::sync::Arc; use std::{ collections::HashMap, @@ -12,15 +18,6 @@ use std::{ }; use walkdir::{DirEntry, WalkDir}; -use pathdiff::diff_paths; -use serde::{Deserialize, Serialize}; - -use crate::utils::{debug, info, print_progress, success, TrpcClient}; - -use super::{ - validate_assets_dir, validate_code_file, Config, MAX_ASSET_SIZE_MB, MAX_FUNCTION_SIZE_MB, -}; - pub type Assets = HashMap>; #[cfg(windows)] @@ -49,57 +46,63 @@ impl FunctionConfig { if !path.exists() { println!( "{}", - debug("No configuration found in current directory...") + style("No configuration found in directory...") + .black() + .bright() ); println!(); let index = match client_override { Some(index) => { - println!("{}", debug("Using custom entrypoint...")); + println!("{}", style("Using custom entrypoint...").black().bright()); index } None => { - let index = Input::::new() + let index = Input::::with_theme(&*THEME) .with_prompt(format!( - "{} {}", - info("Path to your Function's entrypoint?"), - debug( - format!("(relative to {:?})", root.canonicalize().unwrap()) - .as_str() - ), + "Path to your Function's entrypoint? {}", + style(format!("(relative to {:?})", root.canonicalize()?)) + .bright() + .black(), )) + .validate_with(|input: &String| -> std::result::Result<(), String> { + validate_code_file(&root.join(input), root) + .map_err(|err| err.to_string()) + }) .interact_text()?; + PathBuf::from(index) } }; - validate_code_file(&root.join(&index), root)?; - let assets = match assets_override { Some(assets) => { - println!("{}", debug("Using custom public directory...")); + println!( + "{}", + style("Using custom public directory...").black().bright() + ); Some(assets) } - None => match Confirm::new() - .with_prompt(info("Do you have a public directory to serve assets from?")) + None => match Confirm::with_theme(&*THEME) + .with_prompt("Do you have a public directory to serve assets from?") + .default(false) .interact()? { true => { - let assets = Input::::new() + let assets = Input::::with_theme(&*THEME) .with_prompt(format!( - "{} {}", - info("Path to your Function's public directory?"), - debug( - format!("(relative to {:?})", root.canonicalize().unwrap()) - .as_str() - ), + "Path to your Function's public directory? {}", + style(format!("(relative to {:?})", root.canonicalize()?)) + .black() + .bright(), )) + .validate_with(|input: &String| -> std::result::Result<(), String> { + validate_assets_dir(&Some(root.join(input)), root) + .map_err(|err| err.to_string()) + }) .interact_text()?; - let assets = PathBuf::from(assets); - validate_assets_dir(&Some(root.join(&assets)), root)?; - - Some(assets) + Some(PathBuf::from(assets)) } false => None, }, @@ -114,20 +117,26 @@ impl FunctionConfig { }; config.write(root)?; + println!(); return Ok(config); } + println!("{}", style("Found configuration file...").black().bright()); + let content = fs::read_to_string(path)?; let mut config = serde_json::from_str::(&content)?; if let Some(client_override) = client_override { - println!("{}", debug("Using custom entrypoint...")); + println!("{}", style("Using custom client file...").black().bright()); config.client = Some(client_override); } if let Some(assets_override) = assets_override { - println!("{}", debug("Using custom public directory...")); + println!( + "{}", + style("Using custom public directory...").bright().black() + ); config.assets = Some(assets_override); } @@ -139,6 +148,8 @@ impl FunctionConfig { validate_assets_dir(&config.assets, root)?; + println!(); + Ok(config) } @@ -270,14 +281,14 @@ pub fn bundle_function( }; } - let end_progress = print_progress("Bundling Function handler..."); + let end_progress = print_progress("Bundling Function"); let index_output = esbuild(&function_config.index, root, prod)?; end_progress(); let mut final_assets = Assets::new(); if let Some(client) = &function_config.client { - let end_progress = print_progress("Bundling client file..."); + let end_progress = print_progress("Bundling client file"); let client_output = esbuild(client, root, prod)?; end_progress(); @@ -304,10 +315,7 @@ pub fn bundle_function( if let Some(assets) = &function_config.assets { let assets = root.join(assets); - let msg = format!( - "Found public directory ({:?}), bundling assets...", - assets.canonicalize().unwrap() - ); + let msg = format!("Processing assets ({:?})", assets.canonicalize().unwrap()); let end_progress = print_progress(&msg); let files = WalkDir::new(&assets) @@ -340,7 +348,7 @@ pub fn bundle_function( end_progress(); } else { - println!("{}", debug("No public directory found, skipping...")); + println!("{}", style("Skipping assets...").black().bright()); } Ok((index_output, final_assets)) @@ -390,7 +398,7 @@ pub async fn create_deployment( ) -> Result<()> { let (index, assets) = bundle_function(function_config, root, prod_bundle)?; - let end_progress = print_progress("Creating deployment..."); + let end_progress = print_progress("Creating Deployment"); let trpc_client = Arc::new(TrpcClient::new(config)); let response = trpc_client @@ -418,7 +426,7 @@ pub async fn create_deployment( assets_urls, } = response.result.data; - let end_progress = print_progress("Uploading files..."); + let end_progress = print_progress("Uploading files"); let request = Request::builder() .method(Method::PUT) @@ -454,17 +462,22 @@ pub async fn create_deployment( .await?; println!(); - println!("{}", success("Function deployed!")); + println!(" {} Function deployed!", style("◼").magenta()); if !is_production { - println!("{}", debug("Use --prod to deploy to production")); + println!( + " {} {} {}", + style("Append").black(), + style("--prod").black().bright(), + style("to deploy to production").black(), + ); } println!(); println!( - " {} {}", - "➤".bright_black(), - response.result.data.url.blue() + "{} {}", + style("›").black().bright(), + style(response.result.data.url).blue().underlined() ); Ok(()) diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index ee0f7d33d..ab84e9e3e 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -1,11 +1,11 @@ +use anyhow::{anyhow, Result}; +use std::path::{Path, PathBuf}; + mod config; mod console; mod deployments; mod trpc; -use std::path::{Path, PathBuf}; - -use anyhow::{anyhow, Result}; pub use config::*; pub use console::*; pub use deployments::*; diff --git a/crates/cli/src/utils/trpc.rs b/crates/cli/src/utils/trpc.rs index e50c0a5dd..7f27282c3 100644 --- a/crates/cli/src/utils/trpc.rs +++ b/crates/cli/src/utils/trpc.rs @@ -1,11 +1,10 @@ +use super::Config; use anyhow::{anyhow, Result}; use hyper::{body, client::HttpConnector, Body, Client, Method, Request}; use hyper_tls::HttpsConnector; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use urlencoding::encode; -use super::Config; - #[derive(Deserialize, Debug)] pub struct TrpcResponse { pub result: TrpcResult, @@ -28,7 +27,7 @@ pub struct TrpcErrorResult { pub struct TrpcClient { pub client: Client>, - config: Config, + config: Config, } impl TrpcClient { diff --git a/crates/runtime_http/src/lib.rs b/crates/runtime_http/src/lib.rs index 8d321f415..533e00887 100644 --- a/crates/runtime_http/src/lib.rs +++ b/crates/runtime_http/src/lib.rs @@ -1,6 +1,5 @@ -use std::time::Duration; - use anyhow::Result; +use std::time::Duration; mod headers; mod method; diff --git a/crates/runtime_http/src/request.rs b/crates/runtime_http/src/request.rs index 6c218e5b2..4f80a4d12 100644 --- a/crates/runtime_http/src/request.rs +++ b/crates/runtime_http/src/request.rs @@ -1,18 +1,13 @@ +use super::{FromV8, IntoV8, Method}; +use crate::{Headers, X_LAGON_ID}; use anyhow::{anyhow, Result}; use hyper::{ body::{self, Bytes}, - header::HeaderName, - http::{self, HeaderValue}, - Body, Request as HyperRequest, + http, Body, Request as HyperRequest, }; use lagon_runtime_v8_utils::{ extract_v8_headers_object, extract_v8_string, v8_headers_object, v8_string, }; -use std::str::FromStr; - -use crate::{Headers, X_LAGON_ID}; - -use super::{FromV8, IntoV8, Method}; #[derive(Debug)] pub struct Request { diff --git a/crates/runtime_http/src/response.rs b/crates/runtime_http/src/response.rs index 334aade6d..5fc6892ea 100644 --- a/crates/runtime_http/src/response.rs +++ b/crates/runtime_http/src/response.rs @@ -1,3 +1,4 @@ +use crate::{FromV8, Headers, IntoV8}; use anyhow::{anyhow, Result}; use hyper::{ body::{self, Bytes}, @@ -8,8 +9,6 @@ use lagon_runtime_v8_utils::{ v8_integer, v8_string, }; -use crate::{FromV8, Headers, IntoV8}; - static READABLE_STREAM_STR: &[u8] = b"[object ReadableStream]"; #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/crates/wpt-runner/Cargo.toml b/crates/wpt-runner/Cargo.toml index ab8453168..db7fc7205 100644 --- a/crates/wpt-runner/Cargo.toml +++ b/crates/wpt-runner/Cargo.toml @@ -9,5 +9,5 @@ lagon-runtime = { path = "../runtime" } lagon-runtime-http = { path = "../runtime_http" } lagon-runtime-isolate = { path = "../runtime_isolate" } flume = "0.10.14" -colored = "2.0.0" +console = "0.15.5" once_cell = "1.17.1" diff --git a/crates/wpt-runner/src/main.rs b/crates/wpt-runner/src/main.rs index 2b482eb0e..e9ab620f0 100644 --- a/crates/wpt-runner/src/main.rs +++ b/crates/wpt-runner/src/main.rs @@ -1,4 +1,4 @@ -use colored::*; +use console::style; use lagon_runtime::{options::RuntimeOptions, Runtime}; use lagon_runtime_http::{Request, RunResult}; use lagon_runtime_isolate::{options::IsolateOptions, Isolate, IsolateEvent, IsolateRequest}; @@ -79,11 +79,11 @@ async fn run_test(path: &Path) { } if SKIP_TESTS.iter().any(|&s| display.ends_with(s)) { - println!("{} {}", "Skipping".yellow(), display); + println!("{} {}", style("Skipping").yellow(), display); return; } - println!("{} {}", "Running".blue(), display); + println!("{} {}", style("Running").blue(), display); let code = fs::read_to_string(path).expect("Failed to read file"); @@ -128,10 +128,10 @@ export function handler() {{ if content.starts_with("TEST DONE 0") { RESULT.lock().unwrap().1 += 1; - println!("{}", content.green()); + println!("{}", style(content).green()); } else if content.starts_with("TEST DONE 1") { RESULT.lock().unwrap().2 += 1; - println!("{}", content.red()); + println!("{}", style(content).red()); } else if content.starts_with("TEST START") { RESULT.lock().unwrap().0 += 1; } @@ -207,8 +207,8 @@ async fn main() { println!( "{} tests, {} passed, {} failed", result.0, - result.1.to_string().green(), - result.2.to_string().red() + style(result.1.to_string()).green(), + style(result.2.to_string()).red() ); if result.2 == 0 { From c8c7e29422617920d5917946d3a751f3105d7c83 Mon Sep 17 00:00:00 2001 From: QuiiBz Date: Thu, 18 May 2023 12:15:18 +0200 Subject: [PATCH 10/18] fix: revert --- .changeset/funny-waves-confess.md | 5 ----- .changeset/great-cars-design.md | 5 ----- .changeset/tame-planets-wave.md | 5 ----- crates/cli/src/commands/build.rs | 4 +--- 4 files changed, 1 insertion(+), 18 deletions(-) delete mode 100644 .changeset/funny-waves-confess.md delete mode 100644 .changeset/great-cars-design.md delete mode 100644 .changeset/tame-planets-wave.md diff --git a/.changeset/funny-waves-confess.md b/.changeset/funny-waves-confess.md deleted file mode 100644 index c52988e1a..000000000 --- a/.changeset/funny-waves-confess.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@lagon/cli': minor ---- - -Introduce a brand new design diff --git a/.changeset/great-cars-design.md b/.changeset/great-cars-design.md deleted file mode 100644 index e59c2d9d6..000000000 --- a/.changeset/great-cars-design.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@lagon/cli': patch ---- - -Pre-select confirmation inputs diff --git a/.changeset/tame-planets-wave.md b/.changeset/tame-planets-wave.md deleted file mode 100644 index 8dc07b316..000000000 --- a/.changeset/tame-planets-wave.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@lagon/cli': patch ---- - -Improve UX by showing file errors instead of exiting immediately diff --git a/crates/cli/src/commands/build.rs b/crates/cli/src/commands/build.rs index 007fdc980..79e32afa7 100644 --- a/crates/cli/src/commands/build.rs +++ b/crates/cli/src/commands/build.rs @@ -33,9 +33,7 @@ pub fn build( println!(" {} Build successful!", style("◼").magenta()); println!( " {}", - style(format!("You can find it in {:?}", root)) - .black() - .bright() + style(format!("You can find it in {:?}", root)).black().bright() ); Ok(()) From a1ec8a15270bec17f717fa465d6cd01651136667 Mon Sep 17 00:00:00 2001 From: QuiiBz Date: Thu, 18 May 2023 12:18:43 +0200 Subject: [PATCH 11/18] fix: wpt results --- crates/wpt-runner/current-results.md | 705 +++++++++------------------ crates/wpt-runner/src/main.rs | 3 +- 2 files changed, 234 insertions(+), 474 deletions(-) diff --git a/crates/wpt-runner/current-results.md b/crates/wpt-runner/current-results.md index c19db91b4..f5857e985 100644 --- a/crates/wpt-runner/current-results.md +++ b/crates/wpt-runner/current-results.md @@ -20,69 +20,7 @@ TEST DONE 0 Headers.prototype.getSetCookie with two equal headers TEST DONE 0 Headers.prototype.getSetCookie ignores set-cookie2 headers TEST DONE 0 Headers.prototype.getSetCookie preserves header ordering TEST DONE 1 Set-Cookie is a forbidden response header -Running ../../tools/wpt/fetch/api/headers/header-values-normalize.any.js -TEST DONE 1 XMLHttpRequest with value %00 -TEST DONE 1 XMLHttpRequest with value %01 -TEST DONE 1 XMLHttpRequest with value %02 -TEST DONE 1 XMLHttpRequest with value %03 -TEST DONE 1 XMLHttpRequest with value %04 -TEST DONE 1 XMLHttpRequest with value %05 -TEST DONE 1 XMLHttpRequest with value %06 -TEST DONE 1 XMLHttpRequest with value %07 -TEST DONE 1 XMLHttpRequest with value %08 -TEST DONE 1 XMLHttpRequest with value %09 -TEST DONE 1 XMLHttpRequest with value %0A -TEST DONE 1 XMLHttpRequest with value %0D -TEST DONE 1 XMLHttpRequest with value %0E -TEST DONE 1 XMLHttpRequest with value %0F -TEST DONE 1 XMLHttpRequest with value %10 -TEST DONE 1 XMLHttpRequest with value %11 -TEST DONE 1 XMLHttpRequest with value %12 -TEST DONE 1 XMLHttpRequest with value %13 -TEST DONE 1 XMLHttpRequest with value %14 -TEST DONE 1 XMLHttpRequest with value %15 -TEST DONE 1 XMLHttpRequest with value %16 -TEST DONE 1 XMLHttpRequest with value %17 -TEST DONE 1 XMLHttpRequest with value %18 -TEST DONE 1 XMLHttpRequest with value %19 -TEST DONE 1 XMLHttpRequest with value %1A -TEST DONE 1 XMLHttpRequest with value %1B -TEST DONE 1 XMLHttpRequest with value %1C -TEST DONE 1 XMLHttpRequest with value %1D -TEST DONE 1 XMLHttpRequest with value %1E -TEST DONE 1 XMLHttpRequest with value %1F -TEST DONE 1 XMLHttpRequest with value %20 -TEST DONE 1 fetch() with value %00 -TEST DONE 1 fetch() with value %01 -TEST DONE 1 fetch() with value %02 -TEST DONE 1 fetch() with value %03 -TEST DONE 1 fetch() with value %04 -TEST DONE 1 fetch() with value %05 -TEST DONE 1 fetch() with value %06 -TEST DONE 1 fetch() with value %07 -TEST DONE 1 fetch() with value %08 -TEST DONE 1 fetch() with value %09 -TEST DONE 1 fetch() with value %0A -TEST DONE 1 fetch() with value %0D -TEST DONE 1 fetch() with value %0E -TEST DONE 1 fetch() with value %0F -TEST DONE 1 fetch() with value %10 -TEST DONE 1 fetch() with value %11 -TEST DONE 1 fetch() with value %12 -TEST DONE 1 fetch() with value %13 -TEST DONE 1 fetch() with value %14 -TEST DONE 1 fetch() with value %15 -TEST DONE 1 fetch() with value %16 -TEST DONE 1 fetch() with value %17 -TEST DONE 1 fetch() with value %18 -TEST DONE 1 fetch() with value %19 -TEST DONE 1 fetch() with value %1A -TEST DONE 1 fetch() with value %1B -TEST DONE 1 fetch() with value %1C -TEST DONE 1 fetch() with value %1D -TEST DONE 1 fetch() with value %1E -TEST DONE 1 fetch() with value %1F -TEST DONE 1 fetch() with value %20 +Skipping ../../tools/wpt/fetch/api/headers/header-values-normalize.any.js Running ../../tools/wpt/fetch/api/headers/header-values.any.js TEST DONE 1 XMLHttpRequest with value x%00x needs to throw TEST DONE 1 XMLHttpRequest with value x%0Ax needs to throw @@ -310,8 +248,60 @@ TEST DONE 1 RequestCache "reload" mode does store the response in the cache even TEST DONE 1 RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with Last-Modified and stale response TEST DONE 1 RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with Etag and fresh response TEST DONE 1 RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with Last-Modified and fresh response -Skipping ../../tools/wpt/fetch/api/request/request-consume-empty.any.js -Skipping ../../tools/wpt/fetch/api/request/request-consume.any.js +Running ../../tools/wpt/fetch/api/request/request-consume-empty.any.js +TEST DONE 1 Consume request's body as text +TEST DONE 1 Consume request's body as blob +TEST DONE 1 Consume request's body as arrayBuffer +TEST DONE 1 Consume request's body as json (error case) +TEST DONE 1 Consume request's body as formData with correct multipart type (error case) +TEST DONE 1 Consume request's body as formData with correct urlencoded type +TEST DONE 1 Consume request's body as formData without correct type (error case) +TEST DONE 0 Consume empty blob request body as arrayBuffer +TEST DONE 0 Consume empty text request body as arrayBuffer +TEST DONE 0 Consume empty blob request body as text +TEST DONE 0 Consume empty text request body as text +TEST DONE 0 Consume empty URLSearchParams request body as text +TEST DONE 1 Consume empty FormData request body as text +TEST DONE 0 Consume empty ArrayBuffer request body as text +Running ../../tools/wpt/fetch/api/request/request-consume.any.js +TEST DONE 0 Consume String request's body as text +TEST DONE 0 Consume String request's body as blob +TEST DONE 1 Consume String request's body as arrayBuffer +TEST DONE 0 Consume String request's body as JSON +TEST DONE 0 Consume ArrayBuffer request's body as text +TEST DONE 0 Consume ArrayBuffer request's body as blob +TEST DONE 1 Consume ArrayBuffer request's body as arrayBuffer +TEST DONE 0 Consume ArrayBuffer request's body as JSON +TEST DONE 0 Consume Uint8Array request's body as text +TEST DONE 0 Consume Uint8Array request's body as blob +TEST DONE 1 Consume Uint8Array request's body as arrayBuffer +TEST DONE 0 Consume Uint8Array request's body as JSON +TEST DONE 1 Consume Int8Array request's body as text +TEST DONE 1 Consume Int8Array request's body as blob +TEST DONE 1 Consume Int8Array request's body as arrayBuffer +TEST DONE 1 Consume Int8Array request's body as JSON +TEST DONE 1 Consume Float32Array request's body as text +TEST DONE 1 Consume Float32Array request's body as blob +TEST DONE 1 Consume Float32Array request's body as arrayBuffer +TEST DONE 1 Consume Float32Array request's body as JSON +TEST DONE 1 Consume DataView request's body as text +TEST DONE 1 Consume DataView request's body as blob +TEST DONE 1 Consume DataView request's body as arrayBuffer +TEST DONE 1 Consume DataView request's body as JSON +TEST DONE 1 Consume FormData request's body as FormData +TEST DONE 0 Consume blob response's body as blob +TEST DONE 0 Consume blob response's body as text +TEST DONE 0 Consume blob response's body as json +TEST DONE 1 Consume blob response's body as arrayBuffer +TEST DONE 0 Consume blob response's body as blob (empty blob as input) +TEST DONE 0 Consume JSON from text: '"null"' +TEST DONE 0 Consume JSON from text: '"1"' +TEST DONE 0 Consume JSON from text: '"true"' +TEST DONE 0 Consume JSON from text: '"\"string\""' +TEST DONE 0 Trying to consume bad JSON text as JSON: 'undefined' +TEST DONE 0 Trying to consume bad JSON text as JSON: '{' +TEST DONE 0 Trying to consume bad JSON text as JSON: 'a' +TEST DONE 0 Trying to consume bad JSON text as JSON: '[' Running ../../tools/wpt/fetch/api/request/request-disturbed.any.js TEST DONE 1 Request's body: initial state TEST DONE 1 Request without body cannot be disturbed @@ -322,7 +312,29 @@ TEST DONE 1 Check creating a new request with a new body from a disturbed reques TEST DONE 1 Input request used for creating new request became disturbed TEST DONE 1 Input request used for creating new request became disturbed even if body is not used TEST DONE 0 Check consuming a disturbed request -Skipping ../../tools/wpt/fetch/api/request/request-error.any.js +Running ../../tools/wpt/fetch/api/request/request-error.any.js +TEST DONE 1 RequestInit's window is not null +TEST DONE 1 Input URL is not valid +TEST DONE 1 Input URL has credentials +TEST DONE 1 RequestInit's mode is navigate +TEST DONE 1 RequestInit's referrer is invalid +TEST DONE 1 RequestInit's method is invalid +TEST DONE 1 RequestInit's method is forbidden +TEST DONE 1 RequestInit's mode is no-cors and method is not simple +TEST DONE 1 RequestInit's cache mode is only-if-cached and mode is not same-origin +TEST DONE 1 Request with cache mode: only-if-cached and fetch mode cors +TEST DONE 1 Request with cache mode: only-if-cached and fetch mode no-cors +TEST DONE 1 Bad referrerPolicy init parameter value +TEST DONE 1 Bad mode init parameter value +TEST DONE 1 Bad credentials init parameter value +TEST DONE 1 Bad cache init parameter value +TEST DONE 1 Bad redirect init parameter value +TEST DONE 0 Untitled +TEST DONE 1 Request should get its content-type from the init request +TEST DONE 0 Request should not get its content-type from the init request if init headers are provided +TEST DONE 1 Request should get its content-type from the body if none is provided +TEST DONE 1 Request should get its content-type from init headers if one is provided +TEST DONE 0 Request with cache mode: only-if-cached and fetch mode: same-origin Running ../../tools/wpt/fetch/api/request/request-headers.any.js TEST DONE 0 Adding valid request header "Content-Type: OK" TEST DONE 0 Adding valid request header "Potato: OK" @@ -413,8 +425,36 @@ TEST DONE 0 Can override Content-Type for Request with URLSearchParams body TEST DONE 0 Can override Content-Type for Request with string body TEST DONE 0 Can override Content-Type for Request with ReadableStream body TEST DONE 1 Default Content-Type for Request with FormData body -Skipping ../../tools/wpt/fetch/api/request/request-init-priority.any.js -Skipping ../../tools/wpt/fetch/api/request/request-init-stream.any.js +Running ../../tools/wpt/fetch/api/request/request-init-priority.any.js +TEST DONE 0 new Request() with a 'high' priority does not throw an error +TEST DONE 0 new Request() with a 'low' priority does not throw an error +TEST DONE 0 new Request() with a 'auto' priority does not throw an error +TEST DONE 1 new Request() throws a TypeError if any of RequestInit's members' values are invalid +TEST DONE 1 fetch() with a 'high' priority completes successfully +Running ../../tools/wpt/fetch/api/request/request-init-stream.any.js +TEST DONE 1 Constructing a Request with a stream holds the original object. +TEST DONE 1 Constructing a Request with a stream on which getReader() is called +TEST DONE 1 Constructing a Request with a stream on which read() is called +TEST DONE 1 Constructing a Request with a Request on which body.getReader() is called +TEST DONE 1 Constructing a Request with a Request on which body.getReader().read() is called +TEST DONE 0 It is OK to omit .duplex when the body is null. +TEST DONE 0 It is OK to omit .duplex when the body is a string. +TEST DONE 0 It is OK to omit .duplex when the body is a Uint8Array. +TEST DONE 0 It is OK to omit .duplex when the body is a Blob. +TEST DONE 1 It is error to omit .duplex when the body is a ReadableStream. +TEST DONE 0 It is OK to set .duplex = 'half' when the body is null. +TEST DONE 0 It is OK to set .duplex = 'half' when the body is a string. +TEST DONE 0 It is OK to set .duplex = 'half' when the body is a Uint8Array. +TEST DONE 0 It is OK to set .duplex = 'half' when the body is a Blob. +TEST DONE 0 It is OK to set .duplex = 'half' when the body is a ReadableStream. +TEST DONE 1 It is error to set .duplex = 'full' when the body is null. +TEST DONE 1 It is error to set .duplex = 'full' when the body is a string. +TEST DONE 1 It is error to set .duplex = 'full' when the body is a Uint8Array. +TEST DONE 1 It is error to set .duplex = 'full' when the body is a Blob. +TEST DONE 1 It is error to set .duplex = 'full' when the body is a ReadableStream. +TEST DONE 0 It is OK to omit duplex when init.body is not given and input.body is given. +TEST DONE 1 Constructing a Request with a stream on which read() and releaseLock() are called +TEST DONE 1 Constructing a Request with a Request on which read() and releaseLock() are called Running ../../tools/wpt/fetch/api/request/request-keepalive.any.js TEST DONE 1 keepalive flag TEST DONE 1 keepalive flag with stream body @@ -594,23 +634,23 @@ TEST DONE 1 Getting blob after getting the Response body - not disturbed, not lo TEST DONE 1 Getting text after getting the Response body - not disturbed, not locked (body source: fetch) TEST DONE 1 Getting json after getting the Response body - not disturbed, not locked (body source: fetch) TEST DONE 1 Getting arrayBuffer after getting the Response body - not disturbed, not locked (body source: fetch) -TEST DONE 1 Getting blob after getting the Response body - not disturbed, not locked (body source: stream) -TEST DONE 1 Getting text after getting the Response body - not disturbed, not locked (body source: stream) -TEST DONE 1 Getting json after getting the Response body - not disturbed, not locked (body source: stream) -TEST DONE 1 Getting arrayBuffer after getting the Response body - not disturbed, not locked (body source: stream) -TEST DONE 1 Getting blob after getting the Response body - not disturbed, not locked (body source: string) -TEST DONE 1 Getting text after getting the Response body - not disturbed, not locked (body source: string) -TEST DONE 1 Getting json after getting the Response body - not disturbed, not locked (body source: string) -TEST DONE 1 Getting arrayBuffer after getting the Response body - not disturbed, not locked (body source: string) +TEST DONE 0 Getting blob after getting the Response body - not disturbed, not locked (body source: stream) +TEST DONE 0 Getting text after getting the Response body - not disturbed, not locked (body source: stream) +TEST DONE 0 Getting json after getting the Response body - not disturbed, not locked (body source: stream) +TEST DONE 0 Getting arrayBuffer after getting the Response body - not disturbed, not locked (body source: stream) +TEST DONE 0 Getting blob after getting the Response body - not disturbed, not locked (body source: string) +TEST DONE 0 Getting text after getting the Response body - not disturbed, not locked (body source: string) +TEST DONE 0 Getting json after getting the Response body - not disturbed, not locked (body source: string) +TEST DONE 0 Getting arrayBuffer after getting the Response body - not disturbed, not locked (body source: string) Running ../../tools/wpt/fetch/api/response/response-stream-disturbed-2.any.js TEST DONE 1 Getting blob after getting a locked Response body (body source: fetch) TEST DONE 1 Getting text after getting a locked Response body (body source: fetch) TEST DONE 1 Getting json after getting a locked Response body (body source: fetch) TEST DONE 1 Getting arrayBuffer after getting a locked Response body (body source: fetch) -TEST DONE 1 Getting blob after getting a locked Response body (body source: stream) -TEST DONE 1 Getting text after getting a locked Response body (body source: stream) -TEST DONE 1 Getting json after getting a locked Response body (body source: stream) -TEST DONE 1 Getting arrayBuffer after getting a locked Response body (body source: stream) +TEST DONE 0 Getting blob after getting a locked Response body (body source: stream) +TEST DONE 0 Getting text after getting a locked Response body (body source: stream) +TEST DONE 0 Getting json after getting a locked Response body (body source: stream) +TEST DONE 0 Getting arrayBuffer after getting a locked Response body (body source: stream) TEST DONE 1 Getting blob after getting a locked Response body (body source: string) TEST DONE 1 Getting text after getting a locked Response body (body source: string) TEST DONE 1 Getting json after getting a locked Response body (body source: string) @@ -620,27 +660,15 @@ TEST DONE 1 Getting blob after reading the Response body (body source: fetch) TEST DONE 1 Getting text after reading the Response body (body source: fetch) TEST DONE 1 Getting json after reading the Response body (body source: fetch) TEST DONE 1 Getting arrayBuffer after reading the Response body (body source: fetch) -TEST DONE 1 Getting blob after reading the Response body (body source: stream) -TEST DONE 1 Getting text after reading the Response body (body source: stream) -TEST DONE 1 Getting json after reading the Response body (body source: stream) -TEST DONE 1 Getting arrayBuffer after reading the Response body (body source: stream) +TEST DONE 0 Getting blob after reading the Response body (body source: stream) +TEST DONE 0 Getting text after reading the Response body (body source: stream) +TEST DONE 0 Getting json after reading the Response body (body source: stream) +TEST DONE 0 Getting arrayBuffer after reading the Response body (body source: stream) TEST DONE 1 Getting blob after reading the Response body (body source: string) TEST DONE 1 Getting text after reading the Response body (body source: string) TEST DONE 1 Getting json after reading the Response body (body source: string) TEST DONE 1 Getting arrayBuffer after reading the Response body (body source: string) -Running ../../tools/wpt/fetch/api/response/response-stream-disturbed-4.any.js -TEST DONE 1 Getting blob after cancelling the Response body (body source: fetch) -TEST DONE 1 Getting text after cancelling the Response body (body source: fetch) -TEST DONE 1 Getting json after cancelling the Response body (body source: fetch) -TEST DONE 1 Getting arrayBuffer after cancelling the Response body (body source: fetch) -TEST DONE 1 Getting blob after cancelling the Response body (body source: stream) -TEST DONE 1 Getting text after cancelling the Response body (body source: stream) -TEST DONE 1 Getting json after cancelling the Response body (body source: stream) -TEST DONE 1 Getting arrayBuffer after cancelling the Response body (body source: stream) -TEST DONE 1 Getting blob after cancelling the Response body (body source: string) -TEST DONE 1 Getting text after cancelling the Response body (body source: string) -TEST DONE 1 Getting json after cancelling the Response body (body source: string) -TEST DONE 1 Getting arrayBuffer after cancelling the Response body (body source: string) +Skipping ../../tools/wpt/fetch/api/response/response-stream-disturbed-4.any.js Running ../../tools/wpt/fetch/api/response/response-stream-disturbed-5.any.js TEST DONE 1 Getting a body reader after consuming as blob (body source: fetch) TEST DONE 1 Getting a body reader after consuming as text (body source: fetch) @@ -681,317 +709,57 @@ TEST DONE 0 URL.searchParams getter TEST DONE 0 URL.searchParams updating, clearing TEST DONE 1 URL.searchParams setter, invalid values TEST DONE 1 URL.searchParams and URL.search setters, update propagation -Running ../../tools/wpt/url/url-setters-stripping.any.js -TEST DONE 1 Setting protocol with leading U+0000 (https:) -TEST DONE 1 Setting protocol with U+0000 before inserted colon (https:) -TEST DONE 1 Setting username with leading U+0000 (https:) -TEST DONE 1 Setting username with middle U+0000 (https:) -TEST DONE 1 Setting username with trailing U+0000 (https:) -TEST DONE 1 Setting password with leading U+0000 (https:) -TEST DONE 1 Setting password with middle U+0000 (https:) -TEST DONE 1 Setting password with trailing U+0000 (https:) -TEST DONE 1 Setting host with leading U+0000 (https:) -TEST DONE 1 Setting hostname with leading U+0000 (https:) -TEST DONE 1 Setting host with middle U+0000 (https:) -TEST DONE 1 Setting hostname with middle U+0000 (https:) -TEST DONE 1 Setting host with trailing U+0000 (https:) -TEST DONE 1 Setting hostname with trailing U+0000 (https:) -TEST DONE 1 Setting port with leading U+0000 (https:) -TEST DONE 1 Setting port with middle U+0000 (https:) -TEST DONE 1 Setting port with trailing U+0000 (https:) -TEST DONE 1 Setting pathname with leading U+0000 (https:) -TEST DONE 1 Setting pathname with middle U+0000 (https:) -TEST DONE 1 Setting pathname with trailing U+0000 (https:) -TEST DONE 1 Setting search with leading U+0000 (https:) -TEST DONE 1 Setting search with middle U+0000 (https:) -TEST DONE 1 Setting search with trailing U+0000 (https:) -TEST DONE 1 Setting hash with leading U+0000 (https:) -TEST DONE 1 Setting hash with middle U+0000 (https:) -TEST DONE 1 Setting hash with trailing U+0000 (https:) -TEST DONE 1 Setting protocol with leading U+0009 (https:) -TEST DONE 1 Setting protocol with U+0009 before inserted colon (https:) -TEST DONE 1 Setting username with leading U+0009 (https:) -TEST DONE 1 Setting username with middle U+0009 (https:) -TEST DONE 1 Setting username with trailing U+0009 (https:) -TEST DONE 1 Setting password with leading U+0009 (https:) -TEST DONE 1 Setting password with middle U+0009 (https:) -TEST DONE 1 Setting password with trailing U+0009 (https:) -TEST DONE 1 Setting host with leading U+0009 (https:) -TEST DONE 1 Setting hostname with leading U+0009 (https:) -TEST DONE 1 Setting host with middle U+0009 (https:) -TEST DONE 1 Setting hostname with middle U+0009 (https:) -TEST DONE 1 Setting host with trailing U+0009 (https:) -TEST DONE 1 Setting hostname with trailing U+0009 (https:) -TEST DONE 1 Setting port with leading U+0009 (https:) -TEST DONE 1 Setting port with middle U+0009 (https:) -TEST DONE 1 Setting port with trailing U+0009 (https:) -TEST DONE 1 Setting pathname with leading U+0009 (https:) -TEST DONE 1 Setting pathname with middle U+0009 (https:) -TEST DONE 1 Setting pathname with trailing U+0009 (https:) -TEST DONE 1 Setting search with leading U+0009 (https:) -TEST DONE 1 Setting search with middle U+0009 (https:) -TEST DONE 1 Setting search with trailing U+0009 (https:) -TEST DONE 1 Setting hash with leading U+0009 (https:) -TEST DONE 1 Setting hash with middle U+0009 (https:) -TEST DONE 1 Setting hash with trailing U+0009 (https:) -TEST DONE 1 Setting protocol with leading U+000A (https:) -TEST DONE 1 Setting protocol with U+000A before inserted colon (https:) -TEST DONE 1 Setting username with leading U+000A (https:) -TEST DONE 1 Setting username with middle U+000A (https:) -TEST DONE 1 Setting username with trailing U+000A (https:) -TEST DONE 1 Setting password with leading U+000A (https:) -TEST DONE 1 Setting password with middle U+000A (https:) -TEST DONE 1 Setting password with trailing U+000A (https:) -TEST DONE 1 Setting host with leading U+000A (https:) -TEST DONE 1 Setting hostname with leading U+000A (https:) -TEST DONE 1 Setting host with middle U+000A (https:) -TEST DONE 1 Setting hostname with middle U+000A (https:) -TEST DONE 1 Setting host with trailing U+000A (https:) -TEST DONE 1 Setting hostname with trailing U+000A (https:) -TEST DONE 1 Setting port with leading U+000A (https:) -TEST DONE 1 Setting port with middle U+000A (https:) -TEST DONE 1 Setting port with trailing U+000A (https:) -TEST DONE 1 Setting pathname with leading U+000A (https:) -TEST DONE 1 Setting pathname with middle U+000A (https:) -TEST DONE 1 Setting pathname with trailing U+000A (https:) -TEST DONE 1 Setting search with leading U+000A (https:) -TEST DONE 1 Setting search with middle U+000A (https:) -TEST DONE 1 Setting search with trailing U+000A (https:) -TEST DONE 1 Setting hash with leading U+000A (https:) -TEST DONE 1 Setting hash with middle U+000A (https:) -TEST DONE 1 Setting hash with trailing U+000A (https:) -TEST DONE 1 Setting protocol with leading U+000D (https:) -TEST DONE 1 Setting protocol with U+000D before inserted colon (https:) -TEST DONE 1 Setting username with leading U+000D (https:) -TEST DONE 1 Setting username with middle U+000D (https:) -TEST DONE 1 Setting username with trailing U+000D (https:) -TEST DONE 1 Setting password with leading U+000D (https:) -TEST DONE 1 Setting password with middle U+000D (https:) -TEST DONE 1 Setting password with trailing U+000D (https:) -TEST DONE 1 Setting host with leading U+000D (https:) -TEST DONE 1 Setting hostname with leading U+000D (https:) -TEST DONE 1 Setting host with middle U+000D (https:) -TEST DONE 1 Setting hostname with middle U+000D (https:) -TEST DONE 1 Setting host with trailing U+000D (https:) -TEST DONE 1 Setting hostname with trailing U+000D (https:) -TEST DONE 1 Setting port with leading U+000D (https:) -TEST DONE 1 Setting port with middle U+000D (https:) -TEST DONE 1 Setting port with trailing U+000D (https:) -TEST DONE 1 Setting pathname with leading U+000D (https:) -TEST DONE 1 Setting pathname with middle U+000D (https:) -TEST DONE 1 Setting pathname with trailing U+000D (https:) -TEST DONE 1 Setting search with leading U+000D (https:) -TEST DONE 1 Setting search with middle U+000D (https:) -TEST DONE 1 Setting search with trailing U+000D (https:) -TEST DONE 1 Setting hash with leading U+000D (https:) -TEST DONE 1 Setting hash with middle U+000D (https:) -TEST DONE 1 Setting hash with trailing U+000D (https:) -TEST DONE 1 Setting protocol with leading U+001F (https:) -TEST DONE 1 Setting protocol with U+001F before inserted colon (https:) -TEST DONE 1 Setting username with leading U+001F (https:) -TEST DONE 1 Setting username with middle U+001F (https:) -TEST DONE 1 Setting username with trailing U+001F (https:) -TEST DONE 1 Setting password with leading U+001F (https:) -TEST DONE 1 Setting password with middle U+001F (https:) -TEST DONE 1 Setting password with trailing U+001F (https:) -TEST DONE 1 Setting host with leading U+001F (https:) -TEST DONE 1 Setting hostname with leading U+001F (https:) -TEST DONE 1 Setting host with middle U+001F (https:) -TEST DONE 1 Setting hostname with middle U+001F (https:) -TEST DONE 1 Setting host with trailing U+001F (https:) -TEST DONE 1 Setting hostname with trailing U+001F (https:) -TEST DONE 1 Setting port with leading U+001F (https:) -TEST DONE 1 Setting port with middle U+001F (https:) -TEST DONE 1 Setting port with trailing U+001F (https:) -TEST DONE 1 Setting pathname with leading U+001F (https:) -TEST DONE 1 Setting pathname with middle U+001F (https:) -TEST DONE 1 Setting pathname with trailing U+001F (https:) -TEST DONE 1 Setting search with leading U+001F (https:) -TEST DONE 1 Setting search with middle U+001F (https:) -TEST DONE 1 Setting search with trailing U+001F (https:) -TEST DONE 1 Setting hash with leading U+001F (https:) -TEST DONE 1 Setting hash with middle U+001F (https:) -TEST DONE 1 Setting hash with trailing U+001F (https:) -TEST DONE 1 Setting protocol with leading U+0000 (wpt++:) -TEST DONE 1 Setting protocol with U+0000 before inserted colon (wpt++:) -TEST DONE 1 Setting username with leading U+0000 (wpt++:) -TEST DONE 1 Setting username with middle U+0000 (wpt++:) -TEST DONE 1 Setting username with trailing U+0000 (wpt++:) -TEST DONE 1 Setting password with leading U+0000 (wpt++:) -TEST DONE 1 Setting password with middle U+0000 (wpt++:) -TEST DONE 1 Setting password with trailing U+0000 (wpt++:) -TEST DONE 1 Setting host with leading U+0000 (wpt++:) -TEST DONE 1 Setting hostname with leading U+0000 (wpt++:) -TEST DONE 1 Setting host with middle U+0000 (wpt++:) -TEST DONE 1 Setting hostname with middle U+0000 (wpt++:) -TEST DONE 1 Setting host with trailing U+0000 (wpt++:) -TEST DONE 1 Setting hostname with trailing U+0000 (wpt++:) -TEST DONE 1 Setting port with leading U+0000 (wpt++:) -TEST DONE 1 Setting port with middle U+0000 (wpt++:) -TEST DONE 1 Setting port with trailing U+0000 (wpt++:) -TEST DONE 1 Setting pathname with leading U+0000 (wpt++:) -TEST DONE 1 Setting pathname with middle U+0000 (wpt++:) -TEST DONE 1 Setting pathname with trailing U+0000 (wpt++:) -TEST DONE 1 Setting search with leading U+0000 (wpt++:) -TEST DONE 1 Setting search with middle U+0000 (wpt++:) -TEST DONE 1 Setting search with trailing U+0000 (wpt++:) -TEST DONE 1 Setting hash with leading U+0000 (wpt++:) -TEST DONE 1 Setting hash with middle U+0000 (wpt++:) -TEST DONE 1 Setting hash with trailing U+0000 (wpt++:) -TEST DONE 1 Setting protocol with leading U+0009 (wpt++:) -TEST DONE 1 Setting protocol with U+0009 before inserted colon (wpt++:) -TEST DONE 1 Setting username with leading U+0009 (wpt++:) -TEST DONE 1 Setting username with middle U+0009 (wpt++:) -TEST DONE 1 Setting username with trailing U+0009 (wpt++:) -TEST DONE 1 Setting password with leading U+0009 (wpt++:) -TEST DONE 1 Setting password with middle U+0009 (wpt++:) -TEST DONE 1 Setting password with trailing U+0009 (wpt++:) -TEST DONE 1 Setting host with leading U+0009 (wpt++:) -TEST DONE 1 Setting hostname with leading U+0009 (wpt++:) -TEST DONE 1 Setting host with middle U+0009 (wpt++:) -TEST DONE 1 Setting hostname with middle U+0009 (wpt++:) -TEST DONE 1 Setting host with trailing U+0009 (wpt++:) -TEST DONE 1 Setting hostname with trailing U+0009 (wpt++:) -TEST DONE 1 Setting port with leading U+0009 (wpt++:) -TEST DONE 1 Setting port with middle U+0009 (wpt++:) -TEST DONE 1 Setting port with trailing U+0009 (wpt++:) -TEST DONE 1 Setting pathname with leading U+0009 (wpt++:) -TEST DONE 1 Setting pathname with middle U+0009 (wpt++:) -TEST DONE 1 Setting pathname with trailing U+0009 (wpt++:) -TEST DONE 1 Setting search with leading U+0009 (wpt++:) -TEST DONE 1 Setting search with middle U+0009 (wpt++:) -TEST DONE 1 Setting search with trailing U+0009 (wpt++:) -TEST DONE 1 Setting hash with leading U+0009 (wpt++:) -TEST DONE 1 Setting hash with middle U+0009 (wpt++:) -TEST DONE 1 Setting hash with trailing U+0009 (wpt++:) -TEST DONE 1 Setting protocol with leading U+000A (wpt++:) -TEST DONE 1 Setting protocol with U+000A before inserted colon (wpt++:) -TEST DONE 1 Setting username with leading U+000A (wpt++:) -TEST DONE 1 Setting username with middle U+000A (wpt++:) -TEST DONE 1 Setting username with trailing U+000A (wpt++:) -TEST DONE 1 Setting password with leading U+000A (wpt++:) -TEST DONE 1 Setting password with middle U+000A (wpt++:) -TEST DONE 1 Setting password with trailing U+000A (wpt++:) -TEST DONE 1 Setting host with leading U+000A (wpt++:) -TEST DONE 1 Setting hostname with leading U+000A (wpt++:) -TEST DONE 1 Setting host with middle U+000A (wpt++:) -TEST DONE 1 Setting hostname with middle U+000A (wpt++:) -TEST DONE 1 Setting host with trailing U+000A (wpt++:) -TEST DONE 1 Setting hostname with trailing U+000A (wpt++:) -TEST DONE 1 Setting port with leading U+000A (wpt++:) -TEST DONE 1 Setting port with middle U+000A (wpt++:) -TEST DONE 1 Setting port with trailing U+000A (wpt++:) -TEST DONE 1 Setting pathname with leading U+000A (wpt++:) -TEST DONE 1 Setting pathname with middle U+000A (wpt++:) -TEST DONE 1 Setting pathname with trailing U+000A (wpt++:) -TEST DONE 1 Setting search with leading U+000A (wpt++:) -TEST DONE 1 Setting search with middle U+000A (wpt++:) -TEST DONE 1 Setting search with trailing U+000A (wpt++:) -TEST DONE 1 Setting hash with leading U+000A (wpt++:) -TEST DONE 1 Setting hash with middle U+000A (wpt++:) -TEST DONE 1 Setting hash with trailing U+000A (wpt++:) -TEST DONE 1 Setting protocol with leading U+000D (wpt++:) -TEST DONE 1 Setting protocol with U+000D before inserted colon (wpt++:) -TEST DONE 1 Setting username with leading U+000D (wpt++:) -TEST DONE 1 Setting username with middle U+000D (wpt++:) -TEST DONE 1 Setting username with trailing U+000D (wpt++:) -TEST DONE 1 Setting password with leading U+000D (wpt++:) -TEST DONE 1 Setting password with middle U+000D (wpt++:) -TEST DONE 1 Setting password with trailing U+000D (wpt++:) -TEST DONE 1 Setting host with leading U+000D (wpt++:) -TEST DONE 1 Setting hostname with leading U+000D (wpt++:) -TEST DONE 1 Setting host with middle U+000D (wpt++:) -TEST DONE 1 Setting hostname with middle U+000D (wpt++:) -TEST DONE 1 Setting host with trailing U+000D (wpt++:) -TEST DONE 1 Setting hostname with trailing U+000D (wpt++:) -TEST DONE 1 Setting port with leading U+000D (wpt++:) -TEST DONE 1 Setting port with middle U+000D (wpt++:) -TEST DONE 1 Setting port with trailing U+000D (wpt++:) -TEST DONE 1 Setting pathname with leading U+000D (wpt++:) -TEST DONE 1 Setting pathname with middle U+000D (wpt++:) -TEST DONE 1 Setting pathname with trailing U+000D (wpt++:) -TEST DONE 1 Setting search with leading U+000D (wpt++:) -TEST DONE 1 Setting search with middle U+000D (wpt++:) -TEST DONE 1 Setting search with trailing U+000D (wpt++:) -TEST DONE 1 Setting hash with leading U+000D (wpt++:) -TEST DONE 1 Setting hash with middle U+000D (wpt++:) -TEST DONE 1 Setting hash with trailing U+000D (wpt++:) -TEST DONE 1 Setting protocol with leading U+001F (wpt++:) -TEST DONE 1 Setting protocol with U+001F before inserted colon (wpt++:) -TEST DONE 1 Setting username with leading U+001F (wpt++:) -TEST DONE 1 Setting username with middle U+001F (wpt++:) -TEST DONE 1 Setting username with trailing U+001F (wpt++:) -TEST DONE 1 Setting password with leading U+001F (wpt++:) -TEST DONE 1 Setting password with middle U+001F (wpt++:) -TEST DONE 1 Setting password with trailing U+001F (wpt++:) -TEST DONE 1 Setting host with leading U+001F (wpt++:) -TEST DONE 1 Setting hostname with leading U+001F (wpt++:) -TEST DONE 1 Setting host with middle U+001F (wpt++:) -TEST DONE 1 Setting hostname with middle U+001F (wpt++:) -TEST DONE 1 Setting host with trailing U+001F (wpt++:) -TEST DONE 1 Setting hostname with trailing U+001F (wpt++:) -TEST DONE 1 Setting port with leading U+001F (wpt++:) -TEST DONE 1 Setting port with middle U+001F (wpt++:) -TEST DONE 1 Setting port with trailing U+001F (wpt++:) -TEST DONE 1 Setting pathname with leading U+001F (wpt++:) -TEST DONE 1 Setting pathname with middle U+001F (wpt++:) -TEST DONE 1 Setting pathname with trailing U+001F (wpt++:) -TEST DONE 1 Setting search with leading U+001F (wpt++:) -TEST DONE 1 Setting search with middle U+001F (wpt++:) -TEST DONE 1 Setting search with trailing U+001F (wpt++:) -TEST DONE 1 Setting hash with leading U+001F (wpt++:) -TEST DONE 1 Setting hash with middle U+001F (wpt++:) -TEST DONE 1 Setting hash with trailing U+001F (wpt++:) +Skipping ../../tools/wpt/url/url-setters-stripping.any.js Skipping ../../tools/wpt/url/url-setters.any.js Running ../../tools/wpt/url/url-tojson.any.js TEST DONE 0 Untitled Running ../../tools/wpt/url/urlencoded-parser.any.js -TEST DONE 1 URLSearchParams constructed with: test +TEST DONE 0 URLSearchParams constructed with: test TEST DONE 0 URLSearchParams constructed with: test= -TEST DONE 1 URLSearchParams constructed with: %EF%BB%BFtest=%EF%BB%BF +TEST DONE 0 URLSearchParams constructed with: %EF%BB%BFtest=%EF%BB%BF TEST DONE 1 URLSearchParams constructed with: %FE%FF TEST DONE 1 URLSearchParams constructed with: %FF%FE -TEST DONE 1 URLSearchParams constructed with: †&†=x +TEST DONE 0 URLSearchParams constructed with: †&†=x TEST DONE 1 URLSearchParams constructed with: %C2 TEST DONE 1 URLSearchParams constructed with: %C2x TEST DONE 1 URLSearchParams constructed with: _charset_=windows-1252&test=%C2x TEST DONE 0 URLSearchParams constructed with: -TEST DONE 1 URLSearchParams constructed with: a +TEST DONE 0 URLSearchParams constructed with: a TEST DONE 0 URLSearchParams constructed with: a=b TEST DONE 0 URLSearchParams constructed with: a= TEST DONE 0 URLSearchParams constructed with: =b -TEST DONE 1 URLSearchParams constructed with: & -TEST DONE 1 URLSearchParams constructed with: &a -TEST DONE 1 URLSearchParams constructed with: a& -TEST DONE 1 URLSearchParams constructed with: a&a -TEST DONE 1 URLSearchParams constructed with: a&b&c +TEST DONE 0 URLSearchParams constructed with: & +TEST DONE 0 URLSearchParams constructed with: &a +TEST DONE 0 URLSearchParams constructed with: a& +TEST DONE 0 URLSearchParams constructed with: a&a +TEST DONE 0 URLSearchParams constructed with: a&b&c TEST DONE 0 URLSearchParams constructed with: a=b&c=d -TEST DONE 1 URLSearchParams constructed with: a=b&c=d& -TEST DONE 1 URLSearchParams constructed with: &&&a=b&&&&c=d& +TEST DONE 0 URLSearchParams constructed with: a=b&c=d& +TEST DONE 0 URLSearchParams constructed with: &&&a=b&&&&c=d& TEST DONE 0 URLSearchParams constructed with: a=a&a=b&a=c TEST DONE 1 URLSearchParams constructed with: a==a -TEST DONE 1 URLSearchParams constructed with: a=a+b+c+d -TEST DONE 0 URLSearchParams constructed with: %=a -TEST DONE 0 URLSearchParams constructed with: %a=a -TEST DONE 0 URLSearchParams constructed with: %a_=a -TEST DONE 1 URLSearchParams constructed with: %61=a -TEST DONE 1 URLSearchParams constructed with: %61+%4d%4D= +TEST DONE 0 URLSearchParams constructed with: a=a+b+c+d +TEST DONE 1 URLSearchParams constructed with: %=a +TEST DONE 1 URLSearchParams constructed with: %a=a +TEST DONE 1 URLSearchParams constructed with: %a_=a +TEST DONE 0 URLSearchParams constructed with: %61=a +TEST DONE 0 URLSearchParams constructed with: %61+%4d%4D= TEST DONE 1 URLSearchParams constructed with: id=0&value=% TEST DONE 1 URLSearchParams constructed with: b=%2sf%2a TEST DONE 1 URLSearchParams constructed with: b=%2%2af%2a TEST DONE 1 URLSearchParams constructed with: b=%%2a -TEST DONE 1 request.formData() with input: test -TEST DONE 1 response.formData() with input: test -TEST DONE 1 request.formData() with input: test= -TEST DONE 1 response.formData() with input: test= -TEST DONE 1 request.formData() with input: %EF%BB%BFtest=%EF%BB%BF -TEST DONE 1 response.formData() with input: %EF%BB%BFtest=%EF%BB%BF +TEST DONE 0 request.formData() with input: test +TEST DONE 0 response.formData() with input: test +TEST DONE 0 request.formData() with input: test= +TEST DONE 0 response.formData() with input: test= +TEST DONE 0 request.formData() with input: %EF%BB%BFtest=%EF%BB%BF +TEST DONE 0 response.formData() with input: %EF%BB%BFtest=%EF%BB%BF TEST DONE 1 request.formData() with input: %FE%FF TEST DONE 1 response.formData() with input: %FE%FF TEST DONE 1 request.formData() with input: %FF%FE TEST DONE 1 response.formData() with input: %FF%FE -TEST DONE 1 request.formData() with input: †&†=x -TEST DONE 1 response.formData() with input: †&†=x +TEST DONE 0 request.formData() with input: †&†=x +TEST DONE 0 response.formData() with input: †&†=x TEST DONE 1 request.formData() with input: %C2 TEST DONE 1 response.formData() with input: %C2 TEST DONE 1 request.formData() with input: %C2x @@ -1000,46 +768,46 @@ TEST DONE 1 request.formData() with input: _charset_=windows-1252&test=%C2x TEST DONE 1 response.formData() with input: _charset_=windows-1252&test=%C2x TEST DONE 0 request.formData() with input: TEST DONE 0 response.formData() with input: -TEST DONE 1 request.formData() with input: a -TEST DONE 1 response.formData() with input: a -TEST DONE 1 request.formData() with input: a=b -TEST DONE 1 response.formData() with input: a=b -TEST DONE 1 request.formData() with input: a= -TEST DONE 1 response.formData() with input: a= -TEST DONE 1 request.formData() with input: =b -TEST DONE 1 response.formData() with input: =b -TEST DONE 1 request.formData() with input: & -TEST DONE 1 response.formData() with input: & -TEST DONE 1 request.formData() with input: &a -TEST DONE 1 response.formData() with input: &a -TEST DONE 1 request.formData() with input: a& -TEST DONE 1 response.formData() with input: a& -TEST DONE 1 request.formData() with input: a&a -TEST DONE 1 response.formData() with input: a&a -TEST DONE 1 request.formData() with input: a&b&c -TEST DONE 1 response.formData() with input: a&b&c -TEST DONE 1 request.formData() with input: a=b&c=d -TEST DONE 1 response.formData() with input: a=b&c=d -TEST DONE 1 request.formData() with input: a=b&c=d& -TEST DONE 1 response.formData() with input: a=b&c=d& -TEST DONE 1 request.formData() with input: &&&a=b&&&&c=d& -TEST DONE 1 response.formData() with input: &&&a=b&&&&c=d& -TEST DONE 1 request.formData() with input: a=a&a=b&a=c -TEST DONE 1 response.formData() with input: a=a&a=b&a=c +TEST DONE 0 request.formData() with input: a +TEST DONE 0 response.formData() with input: a +TEST DONE 0 request.formData() with input: a=b +TEST DONE 0 response.formData() with input: a=b +TEST DONE 0 request.formData() with input: a= +TEST DONE 0 response.formData() with input: a= +TEST DONE 0 request.formData() with input: =b +TEST DONE 0 response.formData() with input: =b +TEST DONE 0 request.formData() with input: & +TEST DONE 0 response.formData() with input: & +TEST DONE 0 request.formData() with input: &a +TEST DONE 0 response.formData() with input: &a +TEST DONE 0 request.formData() with input: a& +TEST DONE 0 response.formData() with input: a& +TEST DONE 0 request.formData() with input: a&a +TEST DONE 0 response.formData() with input: a&a +TEST DONE 0 request.formData() with input: a&b&c +TEST DONE 0 response.formData() with input: a&b&c +TEST DONE 0 request.formData() with input: a=b&c=d +TEST DONE 0 response.formData() with input: a=b&c=d +TEST DONE 0 request.formData() with input: a=b&c=d& +TEST DONE 0 response.formData() with input: a=b&c=d& +TEST DONE 0 request.formData() with input: &&&a=b&&&&c=d& +TEST DONE 0 response.formData() with input: &&&a=b&&&&c=d& +TEST DONE 0 request.formData() with input: a=a&a=b&a=c +TEST DONE 0 response.formData() with input: a=a&a=b&a=c TEST DONE 1 request.formData() with input: a==a TEST DONE 1 response.formData() with input: a==a -TEST DONE 1 request.formData() with input: a=a+b+c+d -TEST DONE 1 response.formData() with input: a=a+b+c+d +TEST DONE 0 request.formData() with input: a=a+b+c+d +TEST DONE 0 response.formData() with input: a=a+b+c+d TEST DONE 1 request.formData() with input: %=a TEST DONE 1 response.formData() with input: %=a TEST DONE 1 request.formData() with input: %a=a TEST DONE 1 response.formData() with input: %a=a TEST DONE 1 request.formData() with input: %a_=a TEST DONE 1 response.formData() with input: %a_=a -TEST DONE 1 request.formData() with input: %61=a -TEST DONE 1 response.formData() with input: %61=a -TEST DONE 1 request.formData() with input: %61+%4d%4D= -TEST DONE 1 response.formData() with input: %61+%4d%4D= +TEST DONE 0 request.formData() with input: %61=a +TEST DONE 0 response.formData() with input: %61=a +TEST DONE 0 request.formData() with input: %61+%4d%4D= +TEST DONE 0 response.formData() with input: %61+%4d%4D= TEST DONE 1 request.formData() with input: id=0&value=% TEST DONE 1 response.formData() with input: id=0&value=% TEST DONE 1 request.formData() with input: b=%2sf%2a @@ -1049,10 +817,10 @@ TEST DONE 1 response.formData() with input: b=%2%2af%2a TEST DONE 1 request.formData() with input: b=%%2a TEST DONE 1 response.formData() with input: b=%%2a Running ../../tools/wpt/url/urlsearchparams-append.any.js -TEST DONE 1 Append same name -TEST DONE 1 Append empty strings -TEST DONE 1 Append null -TEST DONE 1 Append multiple +TEST DONE 0 Append same name +TEST DONE 0 Append empty strings +TEST DONE 0 Append null +TEST DONE 0 Append multiple Running ../../tools/wpt/url/urlsearchparams-constructor.any.js TEST DONE 1 Basic URLSearchParams construction TEST DONE 0 URLSearchParams constructor, no arguments @@ -1063,17 +831,17 @@ TEST DONE 0 URLSearchParams constructor, {} as argument TEST DONE 1 URLSearchParams constructor, string. TEST DONE 1 URLSearchParams constructor, object. TEST DONE 1 URLSearchParams constructor, FormData. -TEST DONE 1 Parse + -TEST DONE 1 Parse encoded + +TEST DONE 0 Parse + +TEST DONE 0 Parse encoded + TEST DONE 0 Parse space -TEST DONE 1 Parse %20 +TEST DONE 0 Parse %20 TEST DONE 0 Parse \0 -TEST DONE 1 Parse %00 +TEST DONE 0 Parse %00 TEST DONE 0 Parse ⎄ -TEST DONE 1 Parse %e2%8e%84 +TEST DONE 0 Parse %e2%8e%84 TEST DONE 0 Parse 💩 -TEST DONE 1 Parse %f0%9f%92%a9 -TEST DONE 1 Constructor with sequence of sequences of strings +TEST DONE 0 Parse %f0%9f%92%a9 +TEST DONE 0 Constructor with sequence of sequences of strings TEST DONE 0 Construct with object with + TEST DONE 0 Construct with object with two keys TEST DONE 0 Construct with array with two keys @@ -1082,59 +850,64 @@ TEST DONE 1 Construct with 3 unpaired surrogates (no leading) TEST DONE 1 Construct with object with NULL, non-ASCII, and surrogate keys TEST DONE 1 Custom [Symbol.iterator] Running ../../tools/wpt/url/urlsearchparams-delete.any.js -TEST DONE 1 Delete basics -TEST DONE 1 Deleting appended multiple +TEST DONE 0 Delete basics +TEST DONE 0 Deleting appended multiple TEST DONE 0 Deleting all params removes ? from URL -TEST DONE 1 Removing non-existent param removes ? from URL +TEST DONE 0 Removing non-existent param removes ? from URL TEST DONE 1 Changing the query of a URL with an opaque path can impact the path TEST DONE 1 Changing the query of a URL with an opaque path can impact the path if the URL has no fragment Running ../../tools/wpt/url/urlsearchparams-foreach.any.js TEST DONE 0 ForEach Check +TEST DONE 1 For-of Check +TEST DONE 0 empty +TEST DONE 1 delete next param during iteration +TEST DONE 1 delete current param during iteration +TEST DONE 1 delete every param seen during iteration Running ../../tools/wpt/url/urlsearchparams-get.any.js -TEST DONE 1 Get basics -TEST DONE 1 More get() basics +TEST DONE 0 Get basics +TEST DONE 0 More get() basics Running ../../tools/wpt/url/urlsearchparams-getall.any.js TEST DONE 0 getAll() basics -TEST DONE 1 getAll() multiples +TEST DONE 0 getAll() multiples Running ../../tools/wpt/url/urlsearchparams-has.any.js -TEST DONE 1 Has basics +TEST DONE 0 Has basics TEST DONE 0 has() following delete() Running ../../tools/wpt/url/urlsearchparams-set.any.js TEST DONE 0 Set basics -TEST DONE 1 URLSearchParams.set +TEST DONE 0 URLSearchParams.set Running ../../tools/wpt/url/urlsearchparams-sort.any.js TEST DONE 0 Parse and sort: z=b&a=b&z=a&a=a -TEST DONE 1 URL parse and sort: z=b&a=b&z=a&a=a -TEST DONE 1 Parse and sort: �=x&&�=a -TEST DONE 1 URL parse and sort: �=x&&�=a -TEST DONE 1 Parse and sort: ffi&🌈 -TEST DONE 1 URL parse and sort: ffi&🌈 +TEST DONE 0 URL parse and sort: z=b&a=b&z=a&a=a +TEST DONE 0 Parse and sort: �=x&&�=a +TEST DONE 0 URL parse and sort: �=x&&�=a +TEST DONE 0 Parse and sort: ffi&🌈 +TEST DONE 0 URL parse and sort: ffi&🌈 TEST DONE 1 Parse and sort: é&e�&é TEST DONE 1 URL parse and sort: é&e�&é TEST DONE 0 Parse and sort: z=z&a=a&z=y&a=b&z=x&a=c&z=w&a=d&z=v&a=e&z=u&a=f&z=t&a=g -TEST DONE 1 URL parse and sort: z=z&a=a&z=y&a=b&z=x&a=c&z=w&a=d&z=v&a=e&z=u&a=f&z=t&a=g -TEST DONE 1 Parse and sort: bbb&bb&aaa&aa=x&aa=y -TEST DONE 1 URL parse and sort: bbb&bb&aaa&aa=x&aa=y +TEST DONE 0 URL parse and sort: z=z&a=a&z=y&a=b&z=x&a=c&z=w&a=d&z=v&a=e&z=u&a=f&z=t&a=g +TEST DONE 0 Parse and sort: bbb&bb&aaa&aa=x&aa=y +TEST DONE 0 URL parse and sort: bbb&bb&aaa&aa=x&aa=y TEST DONE 0 Parse and sort: z=z&=f&=t&=x -TEST DONE 1 URL parse and sort: z=z&=f&=t&=x -TEST DONE 1 Parse and sort: a🌈&a💩 -TEST DONE 1 URL parse and sort: a🌈&a💩 -TEST DONE 1 Sorting non-existent params removes ? from URL +TEST DONE 0 URL parse and sort: z=z&=f&=t&=x +TEST DONE 0 Parse and sort: a🌈&a💩 +TEST DONE 0 URL parse and sort: a🌈&a💩 +TEST DONE 0 Sorting non-existent params removes ? from URL Running ../../tools/wpt/url/urlsearchparams-stringifier.any.js TEST DONE 1 Serialize space -TEST DONE 1 Serialize empty value -TEST DONE 1 Serialize empty name -TEST DONE 1 Serialize empty name and value -TEST DONE 1 Serialize + -TEST DONE 1 Serialize = -TEST DONE 1 Serialize & +TEST DONE 0 Serialize empty value +TEST DONE 0 Serialize empty name +TEST DONE 0 Serialize empty name and value +TEST DONE 0 Serialize + +TEST DONE 0 Serialize = +TEST DONE 0 Serialize & TEST DONE 0 Serialize *-._ TEST DONE 1 Serialize % -TEST DONE 1 Serialize \0 -TEST DONE 1 Serialize 💩 +TEST DONE 0 Serialize \0 +TEST DONE 0 Serialize 💩 TEST DONE 1 URLSearchParams.toString TEST DONE 1 URLSearchParams connected to URL -TEST DONE 1 URLSearchParams must not do newline normalization +TEST DONE 0 URLSearchParams must not do newline normalization Running ../../tools/wpt/encoding/api-basics.any.js TEST DONE 0 Default encodings TEST DONE 0 Default inputs @@ -1351,21 +1124,7 @@ Running ../../tools/wpt/encoding/textencoder-constructor-non-utf.any.js TEST DONE 0 Encoding argument supported for decode: UTF-8 TEST DONE 0 Encoding argument not considered for encode: UTF-8 Skipping ../../tools/wpt/encoding/textencoder-utf16-surrogates.any.js -Running ../../tools/wpt/encoding/unsupported-encodings.any.js -TEST DONE 1 UTF-7 should not be supported -TEST DONE 1 utf-7 should not be supported -TEST DONE 1 UTF-32 with BOM should decode as UTF-16LE -TEST DONE 1 UTF-32 with no BOM should decode as UTF-8 -TEST DONE 1 utf-32 with BOM should decode as UTF-16LE -TEST DONE 1 utf-32 with no BOM should decode as UTF-8 -TEST DONE 1 UTF-32LE with BOM should decode as UTF-16LE -TEST DONE 1 UTF-32LE with no BOM should decode as UTF-8 -TEST DONE 1 utf-32le with BOM should decode as UTF-16LE -TEST DONE 1 utf-32le with no BOM should decode as UTF-8 -TEST DONE 1 UTF-32be with no BOM should decode as UTF-8 -TEST DONE 1 UTF-32be with BOM should decode as UTF-8 -TEST DONE 1 utf-32be with no BOM should decode as UTF-8 -TEST DONE 1 utf-32be with BOM should decode as UTF-8 +Skipping ../../tools/wpt/encoding/unsupported-encodings.any.js Running ../../tools/wpt/FileAPI/blob/Blob-array-buffer.any.js TEST DONE 0 Blob.arrayBuffer() TEST DONE 0 Blob.arrayBuffer() empty Blob data @@ -1686,7 +1445,7 @@ Running ../../tools/wpt/FileAPI/reading-data-section/filereader_result.any.js TEST DONE 0 readAsText TEST DONE 0 readAsDataURL TEST DONE 0 readAsArrayBuffer -TEST DONE 1 readAsBinaryString +TEST DONE 0 readAsBinaryString TEST DONE 1 result is null during "loadstart" event for readAsText TEST DONE 1 result is null during "loadstart" event for readAsDataURL TEST DONE 1 result is null during "loadstart" event for readAsArrayBuffer @@ -1748,5 +1507,5 @@ Running ../../tools/wpt/urlpattern/urlpattern-compare.https.any.js Running ../../tools/wpt/urlpattern/urlpattern.any.js Running ../../tools/wpt/urlpattern/urlpattern.https.any.js -1620 tests, 464 passed, 1151 failed - -> 28% conformance +1379 tests, 616 passed, 758 failed (5 not completed) + -> 44% conformance diff --git a/crates/wpt-runner/src/main.rs b/crates/wpt-runner/src/main.rs index 01327ee61..399a9ef71 100644 --- a/crates/wpt-runner/src/main.rs +++ b/crates/wpt-runner/src/main.rs @@ -51,11 +51,12 @@ static TEST_HARNESS: Lazy = Lazy::new(|| { .replace("debug: false", "debug: true") }); -const SKIP_TESTS: [&str; 14] = [ +const SKIP_TESTS: [&str; 15] = [ // response "response-cancel-stream.any.js", // "undefined" "response-error-from-stream.any.js", // "Start error" "response-stream-with-broken-then.any.js", // "Cannot destructure property 'done' of 'undefined' as it is undefine" + "response-stream-disturbed-4.any.js", // url "idlharness.any.js", // load webidl stuff, not supported "url-setters.any.js", // fetch an json file, find a way to run it From 4d8c0f572b2e74cd7c487b02d729cccb0e04f8fa Mon Sep 17 00:00:00 2001 From: QuiiBz Date: Sat, 27 May 2023 15:13:49 +0200 Subject: [PATCH 12/18] fix: headers set/append normalize --- crates/wpt-runner/current-results.md | 10 +++++----- packages/js-runtime/src/runtime/http/Headers.ts | 6 ++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/crates/wpt-runner/current-results.md b/crates/wpt-runner/current-results.md index f5857e985..33ead9bba 100644 --- a/crates/wpt-runner/current-results.md +++ b/crates/wpt-runner/current-results.md @@ -95,9 +95,9 @@ TEST DONE 1 "no-cors" Headers object cannot have content-language set to , sssss TEST DONE 1 "no-cors" Headers object cannot have content-type set to text/plain;ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss, text/plain TEST DONE 1 Loading data… Running ../../tools/wpt/fetch/api/headers/headers-normalize.any.js -TEST DONE 1 Create headers with not normalized values -TEST DONE 1 Check append method with not normalized values -TEST DONE 1 Check set method with not normalized values +TEST DONE 0 Create headers with not normalized values +TEST DONE 0 Check append method with not normalized values +TEST DONE 0 Check set method with not normalized values Running ../../tools/wpt/fetch/api/headers/headers-record.any.js TEST DONE 0 Passing nothing to Headers constructor TEST DONE 0 Passing undefined to Headers constructor @@ -1507,5 +1507,5 @@ Running ../../tools/wpt/urlpattern/urlpattern-compare.https.any.js Running ../../tools/wpt/urlpattern/urlpattern.any.js Running ../../tools/wpt/urlpattern/urlpattern.https.any.js -1379 tests, 616 passed, 758 failed (5 not completed) - -> 44% conformance +1379 tests, 619 passed, 755 failed (5 not completed) + -> 45% conformance diff --git a/packages/js-runtime/src/runtime/http/Headers.ts b/packages/js-runtime/src/runtime/http/Headers.ts index e4b1f57de..f2528329f 100644 --- a/packages/js-runtime/src/runtime/http/Headers.ts +++ b/packages/js-runtime/src/runtime/http/Headers.ts @@ -1,5 +1,6 @@ (globalThis => { const SET_COOKIE = 'set-cookie'; + const NORMALIZE_VALUE_REGEX = new RegExp('^[\x0A\x0D\x09\x20]+|[\x0A\x0D\x09\x20]+$', 'g'); globalThis.Headers = class { private readonly h: Map = new Map(); @@ -41,7 +42,8 @@ private addValue(name: string, value: string) { name = name.toLowerCase(); - value = String(value); + value = String(value).replace(NORMALIZE_VALUE_REGEX, ''); + const values = this.h.get(name); if (values) { @@ -107,7 +109,7 @@ } name = name.toLowerCase(); - value = String(value); + value = String(value).replace(NORMALIZE_VALUE_REGEX, ''); this.h.set(name, [value]); } From 4c148d65c817984201136d93f9fe370cbe1f3696 Mon Sep 17 00:00:00 2001 From: QuiiBz Date: Sat, 27 May 2023 15:28:58 +0200 Subject: [PATCH 13/18] fix: skip test --- crates/wpt-runner/current-results.md | 120 ++---------------- crates/wpt-runner/src/main.rs | 10 +- .../js-runtime/src/runtime/http/Headers.ts | 1 + 3 files changed, 19 insertions(+), 112 deletions(-) diff --git a/crates/wpt-runner/current-results.md b/crates/wpt-runner/current-results.md index 33ead9bba..a2173510b 100644 --- a/crates/wpt-runner/current-results.md +++ b/crates/wpt-runner/current-results.md @@ -139,115 +139,13 @@ TEST DONE 1 Request() with a forbidden method connect must throw. TEST DONE 1 Request() with a forbidden method trace must throw. TEST DONE 1 Request() with a forbidden method track must throw. Running ../../tools/wpt/fetch/api/request/request-bad-port.any.js -Running ../../tools/wpt/fetch/api/request/request-cache-default-conditional.any.js -TEST DONE 1 RequestCache "default" mode with an If-Modified-Since header (following a request without additional headers) is treated similarly to "no-store" with Etag and stale response -TEST DONE 1 RequestCache "default" mode with an If-Modified-Since header (following a request without additional headers) is treated similarly to "no-store" with Last-Modified and stale response -TEST DONE 1 RequestCache "default" mode with an If-Modified-Since header (following a request without additional headers) is treated similarly to "no-store" with Etag and fresh response -TEST DONE 1 RequestCache "default" mode with an If-Modified-Since header (following a request without additional headers) is treated similarly to "no-store" with Last-Modified and fresh response -TEST DONE 1 RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with Etag and stale response -TEST DONE 1 RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with Last-Modified and stale response -TEST DONE 1 RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with Etag and fresh response -TEST DONE 1 RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with Last-Modified and fresh response -TEST DONE 1 RequestCache "default" mode with an If-None-Match header (following a request without additional headers) is treated similarly to "no-store" with Etag and stale response -TEST DONE 1 RequestCache "default" mode with an If-None-Match header (following a request without additional headers) is treated similarly to "no-store" with Last-Modified and stale response -TEST DONE 1 RequestCache "default" mode with an If-None-Match header (following a request without additional headers) is treated similarly to "no-store" with Etag and fresh response -TEST DONE 1 RequestCache "default" mode with an If-None-Match header (following a request without additional headers) is treated similarly to "no-store" with Last-Modified and fresh response -TEST DONE 1 RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with Etag and stale response -TEST DONE 1 RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with Last-Modified and stale response -TEST DONE 1 RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with Etag and fresh response -TEST DONE 1 RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with Last-Modified and fresh response -TEST DONE 1 RequestCache "default" mode with an If-Unmodified-Since header (following a request without additional headers) is treated similarly to "no-store" with Etag and stale response -TEST DONE 1 RequestCache "default" mode with an If-Unmodified-Since header (following a request without additional headers) is treated similarly to "no-store" with Last-Modified and stale response -TEST DONE 1 RequestCache "default" mode with an If-Unmodified-Since header (following a request without additional headers) is treated similarly to "no-store" with Etag and fresh response -TEST DONE 1 RequestCache "default" mode with an If-Unmodified-Since header (following a request without additional headers) is treated similarly to "no-store" with Last-Modified and fresh response -TEST DONE 1 RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with Etag and stale response -TEST DONE 1 RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with Last-Modified and stale response -TEST DONE 1 RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with Etag and fresh response -TEST DONE 1 RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with Last-Modified and fresh response -TEST DONE 1 RequestCache "default" mode with an If-Match header (following a request without additional headers) is treated similarly to "no-store" with Etag and stale response -TEST DONE 1 RequestCache "default" mode with an If-Match header (following a request without additional headers) is treated similarly to "no-store" with Last-Modified and stale response -TEST DONE 1 RequestCache "default" mode with an If-Match header (following a request without additional headers) is treated similarly to "no-store" with Etag and fresh response -TEST DONE 1 RequestCache "default" mode with an If-Match header (following a request without additional headers) is treated similarly to "no-store" with Last-Modified and fresh response -TEST DONE 1 RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with Etag and stale response -TEST DONE 1 RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with Last-Modified and stale response -TEST DONE 1 RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with Etag and fresh response -TEST DONE 1 RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with Last-Modified and fresh response -TEST DONE 1 RequestCache "default" mode with an If-Range header (following a request without additional headers) is treated similarly to "no-store" with Etag and stale response -TEST DONE 1 RequestCache "default" mode with an If-Range header (following a request without additional headers) is treated similarly to "no-store" with Last-Modified and stale response -TEST DONE 1 RequestCache "default" mode with an If-Range header (following a request without additional headers) is treated similarly to "no-store" with Etag and fresh response -TEST DONE 1 RequestCache "default" mode with an If-Range header (following a request without additional headers) is treated similarly to "no-store" with Last-Modified and fresh response -TEST DONE 1 RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with Etag and stale response -TEST DONE 1 RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with Last-Modified and stale response -TEST DONE 1 RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with Etag and fresh response -TEST DONE 1 RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with Last-Modified and fresh response -Running ../../tools/wpt/fetch/api/request/request-cache-default.any.js -TEST DONE 1 RequestCache "default" mode checks the cache for previously cached content and goes to the network for stale responses with Etag and stale response -TEST DONE 1 RequestCache "default" mode checks the cache for previously cached content and goes to the network for stale responses with Last-Modified and stale response -TEST DONE 1 RequestCache "default" mode checks the cache for previously cached content and avoids going to the network if a fresh response exists with Etag and fresh response -TEST DONE 1 RequestCache "default" mode checks the cache for previously cached content and avoids going to the network if a fresh response exists with Last-Modified and fresh response -TEST DONE 1 Responses with the "Cache-Control: no-store" header are not stored in the cache with Etag and stale response -TEST DONE 1 Responses with the "Cache-Control: no-store" header are not stored in the cache with Last-Modified and stale response -TEST DONE 1 Responses with the "Cache-Control: no-store" header are not stored in the cache with Etag and fresh response -TEST DONE 1 Responses with the "Cache-Control: no-store" header are not stored in the cache with Last-Modified and fresh response -Running ../../tools/wpt/fetch/api/request/request-cache-force-cache.any.js -TEST DONE 1 RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for stale responses with Etag and stale response -TEST DONE 1 RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for stale responses with Last-Modified and stale response -TEST DONE 1 RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for fresh responses with Etag and fresh response -TEST DONE 1 RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for fresh responses with Last-Modified and fresh response -TEST DONE 1 RequestCache "force-cache" mode checks the cache for previously cached content and goes to the network if a cached response is not found with Etag and stale response -TEST DONE 1 RequestCache "force-cache" mode checks the cache for previously cached content and goes to the network if a cached response is not found with Last-Modified and stale response -TEST DONE 1 RequestCache "force-cache" mode checks the cache for previously cached content and goes to the network if a cached response is not found with Etag and fresh response -TEST DONE 1 RequestCache "force-cache" mode checks the cache for previously cached content and goes to the network if a cached response is not found with Last-Modified and fresh response -TEST DONE 1 RequestCache "force-cache" mode checks the cache for previously cached content and goes to the network if a cached response would vary with Etag and stale response -TEST DONE 1 RequestCache "force-cache" mode checks the cache for previously cached content and goes to the network if a cached response would vary with Last-Modified and stale response -TEST DONE 1 RequestCache "force-cache" mode checks the cache for previously cached content and goes to the network if a cached response would vary with Etag and fresh response -TEST DONE 1 RequestCache "force-cache" mode checks the cache for previously cached content and goes to the network if a cached response would vary with Last-Modified and fresh response -TEST DONE 1 RequestCache "force-cache" stores the response in the cache if it goes to the network with Etag and stale response -TEST DONE 1 RequestCache "force-cache" stores the response in the cache if it goes to the network with Last-Modified and stale response -TEST DONE 1 RequestCache "force-cache" stores the response in the cache if it goes to the network with Etag and fresh response -TEST DONE 1 RequestCache "force-cache" stores the response in the cache if it goes to the network with Last-Modified and fresh response -Running ../../tools/wpt/fetch/api/request/request-cache-no-cache.any.js -TEST DONE 1 RequestCache "no-cache" mode revalidates stale responses found in the cache with Etag and stale response -TEST DONE 1 RequestCache "no-cache" mode revalidates stale responses found in the cache with Last-Modified and stale response -TEST DONE 1 RequestCache "no-cache" mode revalidates fresh responses found in the cache with Etag and fresh response -TEST DONE 1 RequestCache "no-cache" mode revalidates fresh responses found in the cache with Last-Modified and fresh response -Running ../../tools/wpt/fetch/api/request/request-cache-no-store.any.js -TEST DONE 1 RequestCache "no-store" mode does not check the cache for previously cached content and goes to the network regardless with Etag and stale response -TEST DONE 1 RequestCache "no-store" mode does not check the cache for previously cached content and goes to the network regardless with Last-Modified and stale response -TEST DONE 1 RequestCache "no-store" mode does not check the cache for previously cached content and goes to the network regardless with Etag and fresh response -TEST DONE 1 RequestCache "no-store" mode does not check the cache for previously cached content and goes to the network regardless with Last-Modified and fresh response -TEST DONE 1 RequestCache "no-store" mode does not store the response in the cache with Etag and stale response -TEST DONE 1 RequestCache "no-store" mode does not store the response in the cache with Last-Modified and stale response -TEST DONE 1 RequestCache "no-store" mode does not store the response in the cache with Etag and fresh response -TEST DONE 1 RequestCache "no-store" mode does not store the response in the cache with Last-Modified and fresh response -Running ../../tools/wpt/fetch/api/request/request-cache-only-if-cached.any.js -TEST DONE 1 RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for stale responses with Etag and stale response -TEST DONE 1 RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for stale responses with Last-Modified and stale response -TEST DONE 1 RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for fresh responses with Etag and fresh response -TEST DONE 1 RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for fresh responses with Last-Modified and fresh response -TEST DONE 1 RequestCache "only-if-cached" mode checks the cache for previously cached content and does not go to the network if a cached response is not found with Etag and fresh response -TEST DONE 1 RequestCache "only-if-cached" mode checks the cache for previously cached content and does not go to the network if a cached response is not found with Last-Modified and fresh response -TEST DONE 1 RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content with Etag and fresh response -TEST DONE 1 RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content with Last-Modified and fresh response -TEST DONE 1 RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content with Etag and stale response -TEST DONE 1 RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content with Last-Modified and stale response -TEST DONE 1 RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects with Etag and fresh response -TEST DONE 1 RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects with Last-Modified and fresh response -TEST DONE 1 RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects with Etag and stale response -TEST DONE 1 RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects with Last-Modified and stale response -Running ../../tools/wpt/fetch/api/request/request-cache-reload.any.js -TEST DONE 1 RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless with Etag and stale response -TEST DONE 1 RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless with Last-Modified and stale response -TEST DONE 1 RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless with Etag and fresh response -TEST DONE 1 RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless with Last-Modified and fresh response -TEST DONE 1 RequestCache "reload" mode does store the response in the cache with Etag and stale response -TEST DONE 1 RequestCache "reload" mode does store the response in the cache with Last-Modified and stale response -TEST DONE 1 RequestCache "reload" mode does store the response in the cache with Etag and fresh response -TEST DONE 1 RequestCache "reload" mode does store the response in the cache with Last-Modified and fresh response -TEST DONE 1 RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with Etag and stale response -TEST DONE 1 RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with Last-Modified and stale response -TEST DONE 1 RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with Etag and fresh response -TEST DONE 1 RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with Last-Modified and fresh response +Skipping ../../tools/wpt/fetch/api/request/request-cache-default-conditional.any.js +Skipping ../../tools/wpt/fetch/api/request/request-cache-default.any.js +Skipping ../../tools/wpt/fetch/api/request/request-cache-force-cache.any.js +Skipping ../../tools/wpt/fetch/api/request/request-cache-no-cache.any.js +Skipping ../../tools/wpt/fetch/api/request/request-cache-no-store.any.js +Skipping ../../tools/wpt/fetch/api/request/request-cache-only-if-cached.any.js +Skipping ../../tools/wpt/fetch/api/request/request-cache-reload.any.js Running ../../tools/wpt/fetch/api/request/request-consume-empty.any.js TEST DONE 1 Consume request's body as text TEST DONE 1 Consume request's body as blob @@ -1507,5 +1405,5 @@ Running ../../tools/wpt/urlpattern/urlpattern-compare.https.any.js Running ../../tools/wpt/urlpattern/urlpattern.any.js Running ../../tools/wpt/urlpattern/urlpattern.https.any.js -1379 tests, 619 passed, 755 failed (5 not completed) - -> 45% conformance +1277 tests, 619 passed, 653 failed (5 not completed) + -> 48% conformance diff --git a/crates/wpt-runner/src/main.rs b/crates/wpt-runner/src/main.rs index 399a9ef71..642c690a4 100644 --- a/crates/wpt-runner/src/main.rs +++ b/crates/wpt-runner/src/main.rs @@ -51,12 +51,20 @@ static TEST_HARNESS: Lazy = Lazy::new(|| { .replace("debug: false", "debug: true") }); -const SKIP_TESTS: [&str; 15] = [ +const SKIP_TESTS: [&str; 22] = [ // response "response-cancel-stream.any.js", // "undefined" "response-error-from-stream.any.js", // "Start error" "response-stream-with-broken-then.any.js", // "Cannot destructure property 'done' of 'undefined' as it is undefine" "response-stream-disturbed-4.any.js", + // request + "request-cache-default-conditional.any.js", // fetch a python server + "request-cache-default.any.js", // fetch a python server + "request-cache-force-cache.any.js", // fetch a python server + "request-cache-no-cache.any.js", // fetch a python server + "request-cache-no-store.any.js", // fetch a python server + "request-cache-only-if-cached.any.js", // fetch a python server + "request-cache-reload.any.js", // fetch a python server // url "idlharness.any.js", // load webidl stuff, not supported "url-setters.any.js", // fetch an json file, find a way to run it diff --git a/packages/js-runtime/src/runtime/http/Headers.ts b/packages/js-runtime/src/runtime/http/Headers.ts index f2528329f..463b93b99 100644 --- a/packages/js-runtime/src/runtime/http/Headers.ts +++ b/packages/js-runtime/src/runtime/http/Headers.ts @@ -1,5 +1,6 @@ (globalThis => { const SET_COOKIE = 'set-cookie'; + // eslint-disable-next-line no-control-regex const NORMALIZE_VALUE_REGEX = new RegExp('^[\x0A\x0D\x09\x20]+|[\x0A\x0D\x09\x20]+$', 'g'); globalThis.Headers = class { From 3638551b3bef5ba16ee54c32e5bbc8434389e398 Mon Sep 17 00:00:00 2001 From: QuiiBz Date: Sat, 27 May 2023 15:58:19 +0200 Subject: [PATCH 14/18] fix: consume body --- crates/wpt-runner/current-results.md | 26 ++++++++++---------- packages/js-runtime/src/runtime/http/body.ts | 6 ++--- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/crates/wpt-runner/current-results.md b/crates/wpt-runner/current-results.md index a2173510b..8c5b445df 100644 --- a/crates/wpt-runner/current-results.md +++ b/crates/wpt-runner/current-results.md @@ -147,12 +147,12 @@ Skipping ../../tools/wpt/fetch/api/request/request-cache-no-store.any.js Skipping ../../tools/wpt/fetch/api/request/request-cache-only-if-cached.any.js Skipping ../../tools/wpt/fetch/api/request/request-cache-reload.any.js Running ../../tools/wpt/fetch/api/request/request-consume-empty.any.js -TEST DONE 1 Consume request's body as text -TEST DONE 1 Consume request's body as blob -TEST DONE 1 Consume request's body as arrayBuffer -TEST DONE 1 Consume request's body as json (error case) +TEST DONE 0 Consume request's body as text +TEST DONE 0 Consume request's body as blob +TEST DONE 0 Consume request's body as arrayBuffer +TEST DONE 0 Consume request's body as json (error case) TEST DONE 1 Consume request's body as formData with correct multipart type (error case) -TEST DONE 1 Consume request's body as formData with correct urlencoded type +TEST DONE 0 Consume request's body as formData with correct urlencoded type TEST DONE 1 Consume request's body as formData without correct type (error case) TEST DONE 0 Consume empty blob request body as arrayBuffer TEST DONE 0 Consume empty text request body as arrayBuffer @@ -202,7 +202,7 @@ TEST DONE 0 Trying to consume bad JSON text as JSON: 'a' TEST DONE 0 Trying to consume bad JSON text as JSON: '[' Running ../../tools/wpt/fetch/api/request/request-disturbed.any.js TEST DONE 1 Request's body: initial state -TEST DONE 1 Request without body cannot be disturbed +TEST DONE 0 Request without body cannot be disturbed TEST DONE 1 Check cloning a disturbed request TEST DONE 0 Check creating a new request from a disturbed request TEST DONE 1 Request construction failure should not set "bodyUsed" @@ -407,12 +407,12 @@ TEST DONE 1 Check response clone use structureClone for teed ReadableStreams (Fl TEST DONE 1 Check response clone use structureClone for teed ReadableStreams (Float64Arraychunk) TEST DONE 1 Check response clone use structureClone for teed ReadableStreams (DataViewchunk) Running ../../tools/wpt/fetch/api/response/response-consume-empty.any.js -TEST DONE 1 Consume response's body as text -TEST DONE 1 Consume response's body as blob -TEST DONE 1 Consume response's body as arrayBuffer -TEST DONE 1 Consume response's body as json (error case) +TEST DONE 0 Consume response's body as text +TEST DONE 0 Consume response's body as blob +TEST DONE 0 Consume response's body as arrayBuffer +TEST DONE 0 Consume response's body as json (error case) TEST DONE 1 Consume response's body as formData with correct multipart type (error case) -TEST DONE 1 Consume response's body as formData with correct urlencoded type +TEST DONE 0 Consume response's body as formData with correct urlencoded type TEST DONE 1 Consume response's body as formData without correct type (error case) TEST DONE 0 Consume empty blob response body as arrayBuffer TEST DONE 0 Consume empty text response body as arrayBuffer @@ -1405,5 +1405,5 @@ Running ../../tools/wpt/urlpattern/urlpattern-compare.https.any.js Running ../../tools/wpt/urlpattern/urlpattern.any.js Running ../../tools/wpt/urlpattern/urlpattern.https.any.js -1277 tests, 619 passed, 653 failed (5 not completed) - -> 48% conformance +1277 tests, 630 passed, 642 failed (5 not completed) + -> 49% conformance diff --git a/packages/js-runtime/src/runtime/http/body.ts b/packages/js-runtime/src/runtime/http/body.ts index 796978a1d..bc6e34a2c 100644 --- a/packages/js-runtime/src/runtime/http/body.ts +++ b/packages/js-runtime/src/runtime/http/body.ts @@ -90,8 +90,7 @@ export class RequestResponseBody { throw new TypeError('Body is already used'); } - if (!this.theBody) { - this.bodyUsed = true; + if (this.theBody === null) { return new Uint8Array(); } @@ -166,8 +165,7 @@ export class RequestResponseBody { throw new TypeError('Body is already used'); } - if (!this.theBody) { - this.bodyUsed = true; + if (this.theBody === null) { return ''; } From a1cff539c34e79b5abc3a7d0f3368d8f2ca8df02 Mon Sep 17 00:00:00 2001 From: QuiiBz Date: Sat, 27 May 2023 16:06:13 +0200 Subject: [PATCH 15/18] fix: consome body arrayBuffer --- crates/wpt-runner/current-results.md | 28 ++++++++++---------- crates/wpt-runner/src/main.rs | 2 ++ packages/js-runtime/src/runtime/http/body.ts | 5 ++++ 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/crates/wpt-runner/current-results.md b/crates/wpt-runner/current-results.md index 8c5b445df..e1c64785a 100644 --- a/crates/wpt-runner/current-results.md +++ b/crates/wpt-runner/current-results.md @@ -164,15 +164,15 @@ TEST DONE 0 Consume empty ArrayBuffer request body as text Running ../../tools/wpt/fetch/api/request/request-consume.any.js TEST DONE 0 Consume String request's body as text TEST DONE 0 Consume String request's body as blob -TEST DONE 1 Consume String request's body as arrayBuffer +TEST DONE 0 Consume String request's body as arrayBuffer TEST DONE 0 Consume String request's body as JSON TEST DONE 0 Consume ArrayBuffer request's body as text TEST DONE 0 Consume ArrayBuffer request's body as blob -TEST DONE 1 Consume ArrayBuffer request's body as arrayBuffer +TEST DONE 0 Consume ArrayBuffer request's body as arrayBuffer TEST DONE 0 Consume ArrayBuffer request's body as JSON TEST DONE 0 Consume Uint8Array request's body as text TEST DONE 0 Consume Uint8Array request's body as blob -TEST DONE 1 Consume Uint8Array request's body as arrayBuffer +TEST DONE 0 Consume Uint8Array request's body as arrayBuffer TEST DONE 0 Consume Uint8Array request's body as JSON TEST DONE 1 Consume Int8Array request's body as text TEST DONE 1 Consume Int8Array request's body as blob @@ -186,11 +186,11 @@ TEST DONE 1 Consume DataView request's body as text TEST DONE 1 Consume DataView request's body as blob TEST DONE 1 Consume DataView request's body as arrayBuffer TEST DONE 1 Consume DataView request's body as JSON -TEST DONE 1 Consume FormData request's body as FormData +TEST DONE 0 Consume FormData request's body as FormData TEST DONE 0 Consume blob response's body as blob TEST DONE 0 Consume blob response's body as text TEST DONE 0 Consume blob response's body as json -TEST DONE 1 Consume blob response's body as arrayBuffer +TEST DONE 0 Consume blob response's body as arrayBuffer TEST DONE 0 Consume blob response's body as blob (empty blob as input) TEST DONE 0 Consume JSON from text: '"null"' TEST DONE 0 Consume JSON from text: '"1"' @@ -388,8 +388,8 @@ Skipping ../../tools/wpt/fetch/api/response/response-cancel-stream.any.js Running ../../tools/wpt/fetch/api/response/response-clone.any.js TEST DONE 0 Check Response's clone with default values, without body TEST DONE 0 Check Response's clone has the expected attribute values -TEST DONE 1 Check orginal response's body after cloning -TEST DONE 1 Check cloned response's body +TEST DONE 0 Check orginal response's body after cloning +TEST DONE 0 Check cloned response's body TEST DONE 1 Cannot clone a disturbed response TEST DONE 1 Cloned responses should provide the same data TEST DONE 1 Cancelling stream should not affect cloned one @@ -425,10 +425,10 @@ Running ../../tools/wpt/fetch/api/response/response-consume-stream.any.js TEST DONE 0 Getting an error Response stream TEST DONE 0 Getting a redirect Response stream TEST DONE 1 Read empty text response's body as readableStream -TEST DONE 1 Read empty blob response's body as readableStream -TEST DONE 1 Read blob response's body as readableStream with mode=undefined -TEST DONE 1 Read text response's body as readableStream with mode=undefined -TEST DONE 1 Read URLSearchParams response's body as readableStream with mode=undefined +TEST DONE 0 Read empty blob response's body as readableStream +TEST DONE 0 Read blob response's body as readableStream with mode=undefined +TEST DONE 0 Read text response's body as readableStream with mode=undefined +TEST DONE 0 Read URLSearchParams response's body as readableStream with mode=undefined TEST DONE 1 Read array buffer response's body as readableStream with mode=undefined TEST DONE 1 Read form data response's body as readableStream with mode=undefined TEST DONE 1 Read blob response's body as readableStream with mode=byob @@ -470,7 +470,7 @@ TEST DONE 0 Initialize Response's body with application/octet-binary TEST DONE 1 Initialize Response's body with multipart/form-data TEST DONE 0 Initialize Response's body with application/x-www-form-urlencoded;charset=UTF-8 TEST DONE 0 Initialize Response's body with text/plain;charset=UTF-8 -TEST DONE 1 Read Response's body as readableStream +TEST DONE 0 Read Response's body as readableStream TEST DONE 1 Testing empty Response Content-Type header Running ../../tools/wpt/fetch/api/response/response-init-contenttype.any.js TEST DONE 0 Default Content-Type for Response with empty body @@ -1405,5 +1405,5 @@ Running ../../tools/wpt/urlpattern/urlpattern-compare.https.any.js Running ../../tools/wpt/urlpattern/urlpattern.any.js Running ../../tools/wpt/urlpattern/urlpattern.https.any.js -1277 tests, 630 passed, 642 failed (5 not completed) - -> 49% conformance +1277 tests, 642 passed, 630 failed (5 not completed) + -> 50% conformance diff --git a/crates/wpt-runner/src/main.rs b/crates/wpt-runner/src/main.rs index 642c690a4..c81cfc946 100644 --- a/crates/wpt-runner/src/main.rs +++ b/crates/wpt-runner/src/main.rs @@ -34,6 +34,7 @@ const ENCODING_TABLE: &str = r#"const encodings_table = ]"#; const REQUEST_CACHE: &str = include_str!("../../../tools/wpt/fetch/api/request/request-cache.js"); const REQUEST_ERROR: &str = include_str!("../../../tools/wpt/fetch/api/request/request-error.js"); +const REQUEST_UTILS: &str = include_str!("../../../tools/wpt/fetch/api/resources/utils.js"); const SUBSET_TESTS: &str = include_str!("../../../tools/wpt/common/subset-tests.js"); const DECODING_HELPERS: &str = include_str!("../../../tools/wpt/encoding/resources/decoding-helpers.js"); @@ -112,6 +113,7 @@ export function handler() {{ {ENCODING_TABLE} {REQUEST_CACHE} {REQUEST_ERROR} + {REQUEST_UTILS} {SUBSET_TESTS} {DECODING_HELPERS} {SUPPORT_BLOB} diff --git a/packages/js-runtime/src/runtime/http/body.ts b/packages/js-runtime/src/runtime/http/body.ts index bc6e34a2c..ec4ef265c 100644 --- a/packages/js-runtime/src/runtime/http/body.ts +++ b/packages/js-runtime/src/runtime/http/body.ts @@ -147,7 +147,12 @@ export class RequestResponseBody { } async formData(): Promise { + if (this.bodyUsed) { + throw new TypeError('Body is already used'); + } + if (this.theBody instanceof FormData) { + this.bodyUsed = true; return this.theBody; } From 093a63af842a119ed12cad9f3b2a048458974950 Mon Sep 17 00:00:00 2001 From: QuiiBz Date: Tue, 30 May 2023 20:20:30 +0200 Subject: [PATCH 16/18] fix: response status code --- crates/wpt-runner/current-results.md | 10 +++++----- packages/js-runtime/src/runtime/http/Response.ts | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/wpt-runner/current-results.md b/crates/wpt-runner/current-results.md index e1c64785a..eb82ac2e1 100644 --- a/crates/wpt-runner/current-results.md +++ b/crates/wpt-runner/current-results.md @@ -439,10 +439,10 @@ TEST DONE 1 Read form data response's body as readableStream with mode=byob Skipping ../../tools/wpt/fetch/api/response/response-error-from-stream.any.js Running ../../tools/wpt/fetch/api/response/response-error.any.js TEST DONE 1 Throws RangeError when responseInit's status is 0 -TEST DONE 1 Throws RangeError when responseInit's status is 100 -TEST DONE 1 Throws RangeError when responseInit's status is 199 -TEST DONE 1 Throws RangeError when responseInit's status is 600 -TEST DONE 1 Throws RangeError when responseInit's status is 1000 +TEST DONE 0 Throws RangeError when responseInit's status is 100 +TEST DONE 0 Throws RangeError when responseInit's status is 199 +TEST DONE 0 Throws RangeError when responseInit's status is 600 +TEST DONE 0 Throws RangeError when responseInit's status is 1000 TEST DONE 1 Throws TypeError when responseInit's statusText is TEST DONE 1 Throws TypeError when responseInit's statusText is Ā @@ -1405,5 +1405,5 @@ Running ../../tools/wpt/urlpattern/urlpattern-compare.https.any.js Running ../../tools/wpt/urlpattern/urlpattern.any.js Running ../../tools/wpt/urlpattern/urlpattern.https.any.js -1277 tests, 642 passed, 630 failed (5 not completed) +1277 tests, 646 passed, 626 failed (5 not completed) -> 50% conformance diff --git a/packages/js-runtime/src/runtime/http/Response.ts b/packages/js-runtime/src/runtime/http/Response.ts index cc58711da..b0f8bdd2b 100644 --- a/packages/js-runtime/src/runtime/http/Response.ts +++ b/packages/js-runtime/src/runtime/http/Response.ts @@ -22,6 +22,10 @@ import { RequestResponseBody } from './body'; } if (init?.status) { + if (init.status < 200 || init.status > 599) { + throw new RangeError('Invalid status code'); + } + this.ok = init.status >= 200 && init.status < 300; } else { this.ok = true; From e14cc780acdee20f84d0152b6c0a2a02935e3067 Mon Sep 17 00:00:00 2001 From: QuiiBz Date: Tue, 30 May 2023 20:36:46 +0200 Subject: [PATCH 17/18] fix: body formData --- crates/wpt-runner/current-results.md | 6 +++--- packages/js-runtime/src/runtime/http/body.ts | 11 ++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/crates/wpt-runner/current-results.md b/crates/wpt-runner/current-results.md index eb82ac2e1..882b4aa17 100644 --- a/crates/wpt-runner/current-results.md +++ b/crates/wpt-runner/current-results.md @@ -159,7 +159,7 @@ TEST DONE 0 Consume empty text request body as arrayBuffer TEST DONE 0 Consume empty blob request body as text TEST DONE 0 Consume empty text request body as text TEST DONE 0 Consume empty URLSearchParams request body as text -TEST DONE 1 Consume empty FormData request body as text +TEST DONE 0 Consume empty FormData request body as text TEST DONE 0 Consume empty ArrayBuffer request body as text Running ../../tools/wpt/fetch/api/request/request-consume.any.js TEST DONE 0 Consume String request's body as text @@ -419,7 +419,7 @@ TEST DONE 0 Consume empty text response body as arrayBuffer TEST DONE 0 Consume empty blob response body as text TEST DONE 0 Consume empty text response body as text TEST DONE 0 Consume empty URLSearchParams response body as text -TEST DONE 1 Consume empty FormData response body as text +TEST DONE 0 Consume empty FormData response body as text TEST DONE 0 Consume empty ArrayBuffer response body as text Running ../../tools/wpt/fetch/api/response/response-consume-stream.any.js TEST DONE 0 Getting an error Response stream @@ -1405,5 +1405,5 @@ Running ../../tools/wpt/urlpattern/urlpattern-compare.https.any.js Running ../../tools/wpt/urlpattern/urlpattern.any.js Running ../../tools/wpt/urlpattern/urlpattern.https.any.js -1277 tests, 646 passed, 626 failed (5 not completed) +1277 tests, 648 passed, 624 failed (5 not completed) -> 50% conformance diff --git a/packages/js-runtime/src/runtime/http/body.ts b/packages/js-runtime/src/runtime/http/body.ts index ec4ef265c..0db078ea7 100644 --- a/packages/js-runtime/src/runtime/http/body.ts +++ b/packages/js-runtime/src/runtime/http/body.ts @@ -184,8 +184,17 @@ export class RequestResponseBody { return globalThis.__lagon__.TEXT_DECODER.decode(this.theBody); } - if (this.theBody instanceof FormData || this.theBody instanceof URLSearchParams) { + const isFormData = this.theBody instanceof FormData; + + if (isFormData || this.theBody instanceof URLSearchParams) { this.bodyUsed = true; + + if (isFormData) { + return Array.from((this.theBody as FormData).entries()) + .map(([key, value]) => `${key}=${value}`) + .join('&'); + } + return this.theBody.toString(); } From 0d2c3b08295d6b4286da438de6e8a92b80bca410 Mon Sep 17 00:00:00 2001 From: QuiiBz Date: Wed, 31 May 2023 07:52:32 +0200 Subject: [PATCH 18/18] chore: add changeset --- .changeset/mean-cherries-marry.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changeset/mean-cherries-marry.md diff --git a/.changeset/mean-cherries-marry.md b/.changeset/mean-cherries-marry.md new file mode 100644 index 000000000..ad38cbc58 --- /dev/null +++ b/.changeset/mean-cherries-marry.md @@ -0,0 +1,7 @@ +--- +'@lagon/cli': patch +'@lagon/serverless': patch +'@lagon/js-runtime': patch +--- + +Improve implementation of Headers, Request, Response and URLSearchParams