Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /webtransport/response-headers.https.any.html - WPT Dashboard Interop Dashboard
- /webtransport/response-headers.https.any.serviceworker.html - WPT Dashboard Interop Dashboard
- /webtransport/response-headers.https.any.sharedworker.html - WPT Dashboard Interop Dashboard
- /webtransport/response-headers.https.any.worker.html - WPT Dashboard Interop Dashboard
// META: global=window,worker
// META: script=resources/webtransport-test-helpers.sub.js
promise_test(async t => {
// Step 6: "wt-protocol" is a negotiation-only header and must be deleted
// from responseHeaders before it is exposed to script (the negotiated
// protocol itself is exposed via WebTransport.protocol instead).
const options = { protocols: ['a', 'b', 'c'] };
const wt = new WebTransport(
webtransport_url('custom-response.py?wt-protocol="b"'), options);
t.add_cleanup(() => wt.close());
await wt.ready;
assert_equals(wt.protocol, 'b');
assert_not_equals(wt.responseHeaders, null);
assert_equals(wt.responseHeaders.get('wt-protocol'), null,
'wt-protocol must not be exposed via responseHeaders');
}, 'wt-protocol is stripped from responseHeaders');
promise_test(async t => {
// Step 7: transport.[[ResponseHeaders]] is an immutable Headers object.
const wt = new WebTransport(webtransport_url('echo.py'));
t.add_cleanup(() => wt.close());
await wt.ready;
assert_not_equals(wt.responseHeaders, null);
assert_throws_js(TypeError, () => wt.responseHeaders.set('x-custom', 'evil'));
assert_throws_js(TypeError, () => wt.responseHeaders.append('x-custom', 'evil'));
assert_throws_js(TypeError, () => wt.responseHeaders.delete('x-custom'));
}, 'responseHeaders is immutable');