Problem/Motivation
There was a similar thread for D7 - #2808789: Fix "An AJAX HTTP request terminated abnormally" alert after user has navigated away from the page.
The problem we are experiencing is mostly in JS functional tests having the autosave_form module enabled where ajax request are triggered at a specific interval but the form is submitted before an ajax request has finished, in which case the ajax request is terminated and drupal is throwing a JS error, at which point phantomjs will interrupt the test and exit with an error.
Proposed resolution
Do not throw the error if the response has the status code 0 and the unbeforeunload event has been triggered.