Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
WebSocket requests should include Sec-Fetch-Mode=websocket for FetchM…
…etadata https://bugs.webkit.org/show_bug.cgi?id=237550 rdar://problem/90106854 Reviewed by Alex Christensen. Add Sec Fetch headers to the WebSocket Handshake request. We specila case this since we do not have a good use of websocket destination and mode enumeration values. And the URL needs to be translated from ws to http scheme. Add win and bigsur expectations since they do not support custom HTTP headers. * LayoutTests/platform/win/http/wpt/fetch/fetch-metadata-websocket-expected.txt: * LayoutTests/platform/mac-bigsur/http/wpt/fetch: * LayoutTests/http/wpt/fetch/fetch-metadata-websocket-expected.txt: Added. * LayoutTests/http/wpt/fetch/fetch-metadata-websocket.html: Added. * Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp: (WebCore::ThreadableWebSocketChannel::webSocketConnectRequest): Canonical link: https://commits.webkit.org/256527@main
- Loading branch information
Showing
5 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
PASS Websocket Handshake fetch metadata | ||
PASS WebSocket Handshake: sec-fetch-dest | ||
PASS WebSocket Handshake: sec-fetch-mode | ||
PASS WebSocket Handshake: sec-fetch-site | ||
PASS WebSocket Handshake: sec-fetch-user | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!DOCTYPE html><!-- webkit-test-runner [ dumpJSConsoleLogInStdErr=true ] --> | ||
|
||
<link rel="author" href="mtrzos@google.com" title="Maciek Trzos"> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script src=/fetch/metadata/resources/helper.js></script> | ||
<script src=/common/utils.js></script> | ||
<body></body> | ||
<script> | ||
let nonce = token(); | ||
|
||
console.log(window.location.href); | ||
|
||
promise_test(t => { | ||
return new Promise((resolve, reject) => { | ||
let key = "websocket-" + nonce; | ||
|
||
let ws = new WebSocket("ws://localhost:8800/fetch/metadata/resources/record-header.py?file=" + key); | ||
let expected = {"site": "same-origin", "user": "", "mode": "websocket", "dest": "websocket"}; | ||
|
||
// This is expected to fail but will still record the headers from the handshake. | ||
ws.addEventListener("error", e => { | ||
validate_expectations(key, expected, "WebSocket Handshake") | ||
.then(_ => resolve()) | ||
.catch(e => reject(e)); | ||
}); | ||
}) | ||
}, "Websocket Handshake fetch metadata"); | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
PASS Websocket Handshake fetch metadata | ||
FAIL WebSocket Handshake: sec-fetch-dest assert_equals: expected "websocket" but got "" | ||
FAIL WebSocket Handshake: sec-fetch-mode assert_equals: expected "websocket" but got "" | ||
FAIL WebSocket Handshake: sec-fetch-site assert_equals: expected "same-origin" but got "" | ||
PASS WebSocket Handshake: sec-fetch-user | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
PASS Websocket Handshake fetch metadata | ||
FAIL WebSocket Handshake: sec-fetch-dest assert_equals: expected "websocket" but got "" | ||
FAIL WebSocket Handshake: sec-fetch-mode assert_equals: expected "websocket" but got "" | ||
FAIL WebSocket Handshake: sec-fetch-site assert_equals: expected "same-origin" but got "" | ||
PASS WebSocket Handshake: sec-fetch-user | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters