1
0
Fork 0
firefox/testing/web-platform/tests/xhr/abort-during-readystatechange.any.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

19 lines
662 B
JavaScript

"use strict";
setup({ single_test: true });
const xhr = new XMLHttpRequest();
// In jsdom's implementation, this would cause a crash, as after firing readystatechange for HEADERS_RECEIVED, it would
// try to manipulate internal state. But that internal state got cleared during abort(). So jsdom needed to be modified
// to check if that internal state had gone away as a result of firing readystatechange, and if so, bail out.
xhr.addEventListener("readystatechange", () => {
if (xhr.readyState === xhr.HEADERS_RECEIVED) {
xhr.abort();
} else if (xhr.readyState === xhr.DONE) {
done();
}
});
xhr.open("GET", "/common/blank.html");
xhr.send();