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

fix: set window option properly #2048

Merged
merged 4 commits into from
Apr 5, 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/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class Request {
}

// 11. If init["window"] exists, then set window to "no-window".
if (init.window !== undefined) {
if ('window' in init) {
window = 'no-window'
}

Expand Down
20 changes: 20 additions & 0 deletions test/fetch/407-statuscode-window-null.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict'

const { fetch } = require('../..')
const { createServer } = require('http')
const { once } = require('events')
const { test } = require('tap')

test('Receiving a 407 status code w/ a window option present should reject', async (t) => {
const server = createServer((req, res) => {
res.statusCode = 407
res.end()
}).listen(0)

t.teardown(server.close.bind(server))
await once(server, 'listening')

// if init.window exists, the spec tells us to set request.window to 'no-window',
// which later causes the request to be rejected if the status code is 407
await t.rejects(fetch(`http://localhost:${server.address().port}`, { window: null }))
})