blob: ddeb84be88b12bea7771e23e3cc7366fb1df15da [file] [log] [blame]
<!DOCTYPE html>
<script src="/js-test-resources/gc.js"></script>
<script src="/js-test-resources/js-test.js"></script>
<script>
jsTestIsAsync = true;
var numberOfDocumentsBefore, numberOfDocumentsAfter;
function checkDocumentLeakAndFinishTest() {
numberOfDocumentsAfter = internals.numberOfLiveDocuments();
shouldBe("numberOfDocumentsAfter", "numberOfDocumentsBefore");
finishJSTest();
}
function runTest() {
numberOfDocumentsBefore = internals.numberOfLiveDocuments();
var xhr = new XMLHttpRequest();
xhr.responseType = 'document';
xhr.overrideMimeType("text/html");
xhr.onreadystatechange = function () {
if (this.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
testPassed("this reached HEADERS_RECEIVED state.");
this.abort();
asyncGC(checkDocumentLeakAndFinishTest);
} else if (this.readyState == XMLHttpRequest.LOADING) {
testFailed("this reached LOADING state, but it should not reach here after abort().");
} else if (this.readyState == XMLHttpRequest.DONE) {
testPassed("this reached DONE state.");
}
}
xhr.open("GET", "resources/get.txt", true);
xhr.send(null);
xhr = null;
}
// run GC before test to avoid document count being flaky.
asyncGC(runTest);
</script>