The following is a stripped down version of a local file that I'm loading into Microsoft Edge:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script>
var url = "http://example.com"
// Document is ready
ready(function () {
var xhr = new XMLHttpRequest();
xhr.open('POST', url, true)
xhr.withCredentials = true
xhr.setRequestHeader("Content-Type", "application/json; charset=UTF-8")
xhr.onload = function() {
console.log('onload')
console.log('Status: ' + xhr.status + ". " + xhr.statusText)
}
xhr.onerror = function(error) {
console.log('onerror')
}
xhr.send()
})
// Hook for when the DOM has finished loading
function ready(fn) {
if (document.readyState !== 'loading') {
fn()
} else {
document.addEventListener('DOMContentLoaded', fn)
}
}
</script>
</head>
<body>
</body>
</html>
Loading it into the browser works great using file:///path/to/file.html
and the request returns successfully. The problem that I'm running into is that the response is supposed to set a cookie in the browser. It works perfectly on Chrome, IE11, Firefox and Safari, but not on Edge.
Is there some sort of security measure in place preventing Edge from creating cookies from JavaScript that is run from a local file? If so, why?