[whatwg] Navigation events generated during unload

On Mon, 5 Oct 2009, Boris Zbarsky wrote:
> On 10/5/09 9:01 PM, Ian Hickson wrote:
> > Any suggestions? What do browsers actually do, white-box wise?
> 
> Gecko forbids most navigation between firing unload and the newly 
> loading page becoming the current page.  "most" means all history 
> navigation (including reload()) and attempts to navigate via the APIs 
> exposed to the browser UI.  It allows navigation via setting 
> location.href or calling location.replace _if_ the new URI is 
> same-origin with the URI being loaded (the one whose loading triggered 
> the unload event).  That is, you can't keep people on your site if 
> they're trying to go somewhere else.
> 
> See https://bugzilla.mozilla.org/show_bug.cgi?id=409888 for the reason 
> we added the same-origin exception and 
> https://bugzilla.mozilla.org/show_bug.cgi?id=371360 for the reason 
> there's a restriction to start with.
> 
> There is no special handling of beforeunload in this regard in Gecko.

On Mon, 5 Oct 2009, Boris Zbarsky wrote:
> 
> Oh, right.  The Gecko implementation of form submission and link clicks 
> performs the "are we after unload firing started, and if so, is the new 
> URI same-origin with the URI that was loading?" check at the moment of 
> the click or submit call, which is before target name resolution has 
> happened.  That could probably be changed, with enough effort (and 
> likely would be as part of making link clicks work however it is HTML5 
> defines them, instead of however it is they work in Gecko right now).

I specced something almost but not quite the same as what Gecko does. I'm 
aware of two differents. The first difference I could find is shown on 
this test case:

   http://www.hixie.ch/tests/adhoc/html/navigation/unload/cross-origin/004.html

I couldn't work out what Gecko is doing with it.

The second is that I also covered onunload. It seems everything that 
applies to one applies to the other; they run back to back as specced in 
HTML5.

Other than that, I think what I specced matches Gecko. The new text is 
step 3 of the navigation algorithm:

   http://www.whatwg.org/specs/web-apps/current-work/complete.html#navigate

Test suite (onunload only):

   http://www.hixie.ch/tests/adhoc/html/navigation/unload/

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Sunday, 11 October 2009 18:04:08 UTC