-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can fetches start during 7.8.12 Aborting a document load ? #1334
Comments
It seems the document is no longer an active document once it's being aborted? That might be enough reason not to be able to use Fetch from such a document. |
I'm a little hazy on the spec definition of an "active" Document, but based on https://html.spec.whatwg.org/multipage/browsers.html#active-document ("At any time, one Document in each browsing context is designated the active document.") , I would have assumed that an aborted Document remains the active Document unless another Document explicitly becomes active. Have I misunderstood? |
Probably not. E.g., looks like the document remains the same in the Can you share a testcase? Since it's not clear to me how you can run JavaScript while abort a document is running. |
Hmm, perhaps through the |
I was using the snippet below. Chrome shows an "In stop: true" in the console, while Firefox doesn't. <script>
var requests = [];
var inStop = false;
function startRequest() {
var x = new XMLHttpRequest();
x.open("GET", location, true);
x.onabort = startRequest;
x.send(null);
requests.push(x);
console.log("In stop: " + inStop);
}
startRequest();
inStop = true;
window.stop();
inStop = false;
</script> |
I'm not sure what is best here. @bzbarsky, care to chime in? Happy to define whatever... |
I'm pretty sure the Gecko behavior is that we only dispatch the "abort" event when On the other hand, "readystatechange" events totally fire for all this stuff in Gecko, albeit async: the network load is canceled and it asynchronously propagates that information back to whatever is waiting for it. So if you change this testcase to use onreadystatechange, you do see multiple On the general topic here, in an ideal world aborting a document would not run any script synchronously at all... At worst it would queue some tasks to do stuff that might try to run script and do fetches, but at that point we're not dealing with this weird reentry kind of situation or documents in some half-inconsistent state. |
A full discussion of the issue, involving a work-around for Mozilla Firefox from @bzbarsky including his suggestion that it be posted in #1382, can be reviewed at https://bugzilla.mozilla.org/show_bug.cgi?id=1315741. |
https://html.spec.whatwg.org/multipage/browsers.html#abort-a-document
What should happen if a fetch starts during the invocation of this algorithm? Suppose an XHR's onabort fires as a result of its cancellation and starts a new XHR. Should that XHR be allowed to start, or should it be blocked/cancelled? Currently there's at least some divergence: Firefox appears to block the fetch, but Chrome starts the fetch.
The text was updated successfully, but these errors were encountered: