<!DOCTYPE html>
<meta charset="utf-8"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/websockets/cookies/support/websocket-cookies-helper.sub.js"></script>
<script>
if (window.testRunner) {
// Block third-party cookies.
testRunner.setBlockThirdPartyCookies(true);
}
promise_test(() => {
var value = '' + Math.random();
var origin = WSS_ORIGIN;
return setSameSiteCookies(origin, value).then(
() => connectAndGetRequestCookiesFrom(origin)
).then(
cookies => {
assert_not_equals(cookies, '(none)', 'request should contain cookies.');
assertCookie(cookies, 'samesite-unspecified', value, true /* present */);
assertCookie(cookies, 'samesite-lax', value, true /* present */);
assertCookie(cookies, 'samesite-strict', value, true /* present */);
assertCookie(cookies, 'samesite-none', value, true /* present */);
return clearSameSiteCookies(origin);
}
);
}, 'Test that first-party cookies are not blocked for WebSockets.');
</script>