the exact HTML page posted below will invoke the unhandledrejection handler when running on Firefox (observed on 78.12.0esr (64-bit)
), but not on Chrome (observed on 92.0.4515.131 (Official Build) (64-bit)
), why? both browsers are up-to-date today, 2021-08-06
https://jsfiddle.net/vt6z9n5g/1/
<!DOCTYPE HTML>
<html><head><meta charset="utf-8"> </head><body>
<script>
window.addEventListener("error",function(ex){
let msg="error handler invoked! addEventListener";
console.log(msg);
alert(msg);
});
window.addEventListener("unhandledrejection", function (ex) {
let msg="unhandledrejection handler invoked! addEventListener";
console.log(msg);
alert(msg);
});
(async function(){
let foo= ((await ( await fetch("/no_json_plz_i_want_an_error")).json()));
})()//.catch(function(error){ throw error; });
</script>
</body></html>