diff --git a/lib/templates/test-body-footer.html b/lib/templates/test-body-footer.html
index ba5c8c4e..68885762 100644
--- a/lib/templates/test-body-footer.html
+++ b/lib/templates/test-body-footer.html
@@ -25,9 +25,11 @@
if (REQUEST_ASYNC) {
request.responseType = 'json';
- request.onload = function() {
- handleCoverageResponse(this, callback);
- }
+ request.onreadystatechange = function() {
+ if (request.readyState === 4) {
+ handleCoverageResponse(this, callback);
+ }
+ };
} else {
// The request is already done at this point, since it is synchronous
if (request.status === 200) {
@@ -47,7 +49,7 @@
}
function handleCoverageResponse(xhr, callback) {
- var data = xhr.response;
+ var data = xhr.response || xhr.responseText;
// PhantomJS doesn't honor `responseType = 'json'`
if (typeof data === 'string') {