WICG / portals

A proposal for enabling seamless navigations between sites or pages
https://wicg.github.io/portals/
Other
946 stars 66 forks source link

Document cases where earlier navigations take priority #218

Open jakearchibald opened 4 years ago

jakearchibald commented 4 years ago

Right now it looks like the HTML spec say "last wins" in terms of navigation, but I think there are cases where we give priority to user-initiated navigations over js-initiated navigations.

We should document this and figure out where portal activation sits.

@jyasskin @kjmcnee do either of you have this in your heads already?

kjmcnee commented 4 years ago

In chrome, we ignore renderer initiated navigations when there is an ongoing browser initiated request and the new navigation lacks a user gesture.

Portal activation without a user gesture also cannot cancel a browser initiated request.

jakearchibald commented 4 years ago

What does "browser initiated" mean compared to "renderer initiated" with or without a user gesture?

kjmcnee commented 4 years ago

Browser initiated refers to things like entering something in the address bar, using the browsers back/forward buttons, bookmarks, etc. Essentially, methods of navigation that the user agent offers the user that aren't driven by the web content.

jakearchibald commented 4 years ago

Cheers. In terms of navigations driven by web content, is it always "last wins", regardless of whether there was a user gesture or not?

bokand commented 4 years ago

Something I learned in a past life - there's some nuance in "browser initiated" that probably doesn't line up with intuition. For example, in Chrome, a history navigation is considered "browser initiated" even if it's initiated from script (e.g. history.back()) without a user gesture. We'd probably want to spell this out more explicitly.

I do recall seeing code in Chrome's navigation bits that gave allowed browser-initiated navigations to clobber non-browser-initiated ones but I'm not sure how much of this is standardized - @jakearchibald you mentioned the HTML spec saying this, can you link to it? I'm curious what the specs have to say here.

Is there any reason to treat portal activation differently from a regular navigation in these cases?

kjmcnee commented 4 years ago

Even though session history navigations initiated by script are considered browser initiated, the requests are still subject to being ignored in chromium: https://source.chromium.org/chromium/chromium/src/+/master:content/browser/web_contents/web_contents_impl.cc;drc=3abb32da2944ffe178dd66f404e7e1bb88a58ed0;l=4951

But that's good to point out, since I would imagine this means that a page couldn't cancel its own call to |history.back()| with another navigation without a user gesture, though I haven't tested this.