Fetch with Credentials

JavaScripts in this page will set document.cookie to ..., which will be reflected by the server and all request headers are printed as following:

Click following buttons to fetch...

ServiceWorkerGlobalScope.fetch()

ServiceWorkerGlobalScope.fetch() attach cookies by default.

window.fetch()

window.fetch(url, options) will not attach cookies by default. Setting the credentials options will do this trick.

AJAX

XMLHttpRequest.send() will attach cookies by default, withCredentials is needed only in CORS requests.