1
0
Fork 0
firefox/testing/web-platform/tests/websockets/cookies/cross-origin-cookie-set.html
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

40 lines
1.5 KiB
HTML

<!DOCTYPE html>
<title>Include credentials in cross-origin websocket requests</title>
<meta name=author title="Domenico Rizzo" href="mailto:domenico.rizzo@gmail.com">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="/websockets/constants.sub.js"></script>
<h1>WebSocket - Set Cross-origin cookie</h1>
<div id=log></div>
<script>
var resp_test = async_test('Cookie should be set')
resp_test.step(function() {
var ws = new WebSocket(SCHEME_CROSSDOMAIN_PORT + "/set-cookie?cookie_test");
ws.onerror = resp_test.step_func_done(function () {
assert_unreached("ws no error");
});
ws.onclose = resp_test.step_func_done(function () {
assert_unreached("'close' should not fire before 'open'.");
});
ws.onopen = resp_test.step_func(function (e) {
ws.onclose = null;
ws.close();
var ws2 = new WebSocket(SCHEME_CROSSDOMAIN_PORT + "/echo-cookie");
ws2.onerror = resp_test.step_func_done(function () {
assert_unreached("ws2 no error");
});
ws2.onclose = resp_test.step_func_done(function () {
assert_unreached("'close' should not fire before 'open'.");
});
ws2.onmessage = resp_test.step_func_done(function (e) {
ws2.onclose = null;
ws2.close();
assert_true(/ws_test_cookie_test=test/.test(e.data));
});
});
})
</script>