This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 12837 - Define unloading document cleanup steps
Summary: Define unloading document cleanup steps
Status: RESOLVED WORKSFORME
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: XHR (show other bugs)
Version: unspecified
Hardware: PC Windows 3.1
: P2 normal
Target Milestone: ---
Assignee: Anne
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-31 23:11 UTC by Simon Pieters
Modified: 2016-08-12 08:53 UTC (History)
5 users (show)

See Also:


Attachments
Demo unloading document, no XHR (448 bytes, text/html)
2014-10-16 10:22 UTC, Simon Pieters
Details
Demo unloading document, with XHR (576 bytes, text/html)
2014-10-16 10:23 UTC, Simon Pieters
Details

Description Simon Pieters 2011-05-31 23:11:52 UTC
XHR should define unloading document cleanup steps ( http://www.whatwg.org/specs/web-apps/current-work/complete/history.html#unloading-document-cleanup-steps )

if there are open XHRs, close them and make the document unsalvageable
Comment 1 Simon Pieters 2011-08-17 12:21:00 UTC
This specification defines the following unloading document cleanup steps.

Make disappear any XMLHttpRequest objects that were created by the XMLHttpRequest() constructor  or AnonXMLHttpRequest() constructor whose global object is the Document's Window object. 

If this affected any XMLHttpRequest objects, the set Document's salvageable state to false.

If a user agent is to make disappear an XMLHttpRequest object (this happens when a Document object goes away), the user agent must follow the first appropriate set of steps from the following list:

↪If the XMLHttpRequest object is in the OPENED state with the send() flag being true, or the HEADERS_RECEIVED state, or the LOADING state

Act as if the user aborted the cancels the request.

↪Otherwise

Do nothing.
Comment 2 Simon Pieters 2011-08-17 12:25:33 UTC
possibly you need to have a way to kill an XHR without firing events, to use when navigating away
Comment 3 Anne 2011-08-17 15:58:28 UTC
So why exactly is this not needed for EventSource?
Comment 4 Anne 2011-08-17 22:51:09 UTC
This is only needed for WebSocket apparently. For HTTP you can just kill the connection.
Comment 5 Hallvord R. M. Steen 2013-11-07 13:44:48 UTC
Per Anne's comment above no spec change is required.
Comment 6 Anne 2013-11-07 13:49:41 UTC
Are you sure? I'm not a 100% sure. We have a way to terminate without events now so we might want to mention that it should be used here...
Comment 7 Hallvord R. M. Steen 2013-11-07 14:15:00 UTC
I'm not 100% sure either, but the referenced document unloading stuff was pretty specific to WebSocket in the details. We probably want to consult some developers and ask if there's anything we need to say here.
Comment 8 Anne 2013-11-07 14:32:20 UTC
Let's leave this open until what needs to happen is decided on.
Comment 9 Anne 2014-05-21 14:31:49 UTC
Looks similar to bug 23878 which I just assigned to Ian. Going to try that with this too.
Comment 10 Ian 'Hixie' Hickson 2014-09-29 21:21:27 UTC
I'm confused as to what you want me to do here. Can you elaborate?
Comment 11 Anne 2014-10-15 08:13:52 UTC
Sorry, I meant to ask you to look at comment 0 and comment 1 to see if there's anything we need to define here.
Comment 12 Ian 'Hixie' Hickson 2014-10-15 19:05:38 UTC
Isn't this an XHR problem? I don't understand what you're asking me.
Comment 13 Anne 2014-10-16 08:01:44 UTC
The main problem is that I'm not sure what to do. Whether this is applicable to XMLHttpRequest or not. If this is just about closing the connection, then I think we have that other bug for that about terminating all fetches associated with an environment.
Comment 14 Simon Pieters 2014-10-16 09:01:35 UTC
You also need to make the document unsalvageable if it closed the connection. IIRC some browsers did this when I filed the bug, but maybe we should check what browsers do today...
Comment 15 Anne 2014-10-16 09:49:43 UTC
"unsalvageable" is only mentioned in informative text in HTML. And does not include other elements that do fetching. I take it XMLHttpRequest is special in that regard when you tested it?
Comment 16 Simon Pieters 2014-10-16 10:22:53 UTC
Created attachment 1524 [details]
Demo unloading document, no XHR
Comment 17 Simon Pieters 2014-10-16 10:23:27 UTC
Created attachment 1525 [details]
Demo unloading document, with XHR
Comment 19 Anne 2014-10-16 11:31:30 UTC
https://simon.html5.org/dump/unload-baseline.html
https://simon.html5.org/dump/unload-xhr.html

Given these, it seems there is no difference when using XMLHttpRequest.
Comment 20 Ian 'Hixie' Hickson 2014-11-26 20:05:39 UTC
I'm sending this back to XHR for now since I don't really understand what I'm supposed to do here, but please don't hesitate to send it back to me if there's something I should be doing. Thanks!
Comment 22 Anne 2016-08-12 08:53:35 UTC
Demos still work for me.