Fix session history navigations and reloads which change SiteInstance.

Reloading an URL usually does not change its SiteInstance, however there
are a couple of exceptions - hosted apps and recently isolation of error
pages. In both of these cases, a commit for a specific URL can happen
in SiteInstance A and a subsequent reload results in a change to
SiteInstance B. With error page isolation, this can happen easily due
to timeout or some other transient network error on the initial navigation
to the URL, which ends up in an error page process. A later successful
reload then results in a different SiteInstance for the same URL.

Session history navigations are similar in behavior. When navigating
back/forward, the navigation can be redirected cross-site, resulting
in a SiteInstance change.

This CL changes ClassifyNavigation to account for these and classifies
them as NEW_PAGE with replacement. It ensures that when an entry's
SiteInstance changes, which means the security context has changed,
we don't reuse and update the existing entry, but rather we replace it
with a newly constructed one.

The CL adds a specific test for session history navigations that are
redirected and adds session history length checks to the existing test
of reloading a hosted app, which changes SiteInstances.

Bug: 840485, 848446
Change-Id: Iabacc60ce5726d5d919877b6e65e5d2f51dff3e2
Reviewed-on: https://chromium-review.googlesource.com/1086876
Commit-Queue: Nasko Oskov <[email protected]>
Reviewed-by: Charlie Reis <[email protected]>
Reviewed-by: Devlin <[email protected]>
Cr-Commit-Position: refs/heads/master@{#567492}
6 files changed