From 8d2ecaab7f1dc5d17f8b18a15a469d9095a942ef Mon Sep 17 00:00:00 2001 From: Ming Liu Date: Fri, 6 Jan 2017 16:55:50 -0800 Subject: [PATCH 1/2] Refactor onload to onreadystatechange onreadystatechange is more reliable, chromium doesnt trigger onload --- lib/templates/test-body-footer.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/templates/test-body-footer.html b/lib/templates/test-body-footer.html index ba5c8c4e..48d90920 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) { From eda9a2c93d1243941c0bf3f71731b7e62feccfb6 Mon Sep 17 00:00:00 2001 From: Ming Liu Date: Fri, 6 Jan 2017 16:56:41 -0800 Subject: [PATCH 2/2] Fix PhantomJS honoring responseType issue --- lib/templates/test-body-footer.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/templates/test-body-footer.html b/lib/templates/test-body-footer.html index 48d90920..68885762 100644 --- a/lib/templates/test-body-footer.html +++ b/lib/templates/test-body-footer.html @@ -49,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') {