Skip to content

Commit af9aaea

Browse files
authored
update spec & wpts (#2482)
* update spec & wpts restore fetch error debug time * fix some test failures for others!! * fix some test failures for others!! * fix most remaining failures * fix remaining WPT fail * fix fetching blob * mark websocket WPTs as failing
1 parent 1943852 commit af9aaea

File tree

218 files changed

+4367
-1489
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

218 files changed

+4367
-1489
lines changed

lib/core/util.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ async function * convertIterableToBuffer (iterable) {
365365
}
366366
}
367367

368+
/** @type {globalThis['ReadableStream']} */
368369
let ReadableStream
369370
function ReadableStreamFrom (iterable) {
370371
if (!ReadableStream) {
@@ -395,9 +396,9 @@ function ReadableStreamFrom (iterable) {
395396
},
396397
async cancel (reason) {
397398
await iterator.return()
398-
}
399-
},
400-
0
399+
},
400+
type: 'bytes'
401+
}
401402
)
402403
}
403404

lib/fetch/body.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,19 @@ function extractBody (object, keepalive = false) {
4747
stream = object.stream()
4848
} else {
4949
// 4. Otherwise, set stream to a new ReadableStream object, and set
50-
// up stream.
50+
// up stream with byte reading support.
5151
stream = new ReadableStream({
5252
async pull (controller) {
53-
controller.enqueue(
54-
typeof source === 'string' ? textEncoder.encode(source) : source
55-
)
53+
const buffer = typeof source === 'string' ? textEncoder.encode(source) : source
54+
55+
if (buffer.byteLength) {
56+
controller.enqueue(buffer)
57+
}
58+
5659
queueMicrotask(() => readableStreamClose(controller))
5760
},
5861
start () {},
59-
type: undefined
62+
type: 'bytes'
6063
})
6164
}
6265

@@ -223,21 +226,25 @@ function extractBody (object, keepalive = false) {
223226
// When running action is done, close stream.
224227
queueMicrotask(() => {
225228
controller.close()
229+
controller.byobRequest?.respond(0)
226230
})
227231
} else {
228232
// Whenever one or more bytes are available and stream is not errored,
229233
// enqueue a Uint8Array wrapping an ArrayBuffer containing the available
230234
// bytes into stream.
231235
if (!isErrored(stream)) {
232-
controller.enqueue(new Uint8Array(value))
236+
const buffer = new Uint8Array(value)
237+
if (buffer.byteLength) {
238+
controller.enqueue(buffer)
239+
}
233240
}
234241
}
235242
return controller.desiredSize > 0
236243
},
237244
async cancel (reason) {
238245
await iterator.return()
239246
},
240-
type: undefined
247+
type: 'bytes'
241248
})
242249
}
243250

lib/fetch/dataURL.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,13 @@ function URLSerializer (url, excludeFragment = false) {
126126
const href = url.href
127127
const hashLength = url.hash.length
128128

129-
return hashLength === 0 ? href : href.substring(0, href.length - hashLength)
129+
const serialized = hashLength === 0 ? href : href.substring(0, href.length - hashLength)
130+
131+
if (!hashLength && href.endsWith('#')) {
132+
return serialized.slice(0, -1)
133+
}
134+
135+
return serialized
130136
}
131137

132138
// https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points

0 commit comments

Comments
 (0)