Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update wpts #2226

Merged
merged 3 commits into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/fetch/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Response {
}

// https://fetch.spec.whatwg.org/#dom-response-json
static json (data = undefined, init = {}) {
static json (data, init = {}) {
webidl.argumentLengthCheck(arguments, 1, { header: 'Response.json' })

if (init !== null) {
Expand Down
25 changes: 23 additions & 2 deletions lib/fetch/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -556,16 +556,37 @@ function bytesMatch (bytes, metadataList) {
const algorithm = item.algo

// 2. Let expectedValue be the val component of item.
const expectedValue = item.hash
let expectedValue = item.hash

// See https://github.com/web-platform-tests/wpt/commit/e4c5cc7a5e48093220528dfdd1c4012dc3837a0e
// "be liberal with padding". This is annoying, and it's not even in the spec.

if (expectedValue.endsWith('==')) {
expectedValue = expectedValue.slice(0, -2)
}

// 3. Let actualValue be the result of applying algorithm to bytes.
const actualValue = crypto.createHash(algorithm).update(bytes).digest('base64')
let actualValue = crypto.createHash(algorithm).update(bytes).digest('base64')

if (actualValue.endsWith('==')) {
actualValue = actualValue.slice(0, -2)
}

// 4. If actualValue is a case-sensitive match for expectedValue,
// return true.
if (actualValue === expectedValue) {
return true
}

let actualBase64URL = crypto.createHash(algorithm).update(bytes).digest('base64url')

if (actualBase64URL.endsWith('==')) {
actualBase64URL = actualBase64URL.slice(0, -2)
}
Comment on lines +583 to +585
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KhafraDev This will always eval as false


if (actualBase64URL === expectedValue) {
return true
}
}

// 6. Return false.
Expand Down
2 changes: 2 additions & 0 deletions test/wpt/runner/runner.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ export class WPTRunner extends EventEmitter {
`unexpected failures: ${failed - expectedFailures}, ` +
`skipped: ${skipped}`
)

process.exit(0)
}

addInitScript (code) {
Expand Down
8 changes: 7 additions & 1 deletion test/wpt/status/fetch.status.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
"api": {
"abort": {
"general.any.js": {
"note": "TODO(@KhafraDev): Clone aborts with original controller can probably be fixed",
"fail": [
"Already aborted signal rejects immediately",
"Underlying connection is closed when aborting after receiving response - no-cors",
"Stream errors once aborted. Underlying connection closed.",
"Readable stream synchronously cancels with AbortError if aborted before reading"
"Readable stream synchronously cancels with AbortError if aborted before reading",
"Clone aborts with original controller"
]
},
"cache.https.any.js": {
Expand Down Expand Up @@ -128,6 +130,10 @@
]
}
},
"fetch-later": {
"note": "this is not part of the spec, only a proposal",
"skip": true
},
"headers": {
"header-setcookie.any.js": {
"note": "undici doesn't filter headers",
Expand Down