Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make Blink compatible with url::Origin::Resolve(...'about:blank'...).
Main change: blink::SecurityOrigin::CreateWithReferenceOrigin ============================================================= The main change in this CL is changing how blink::SecurityOrigin's CreateWithReferenceOrigin handles "about:blank" URLs. Before this CL, an opaque origin would be returned; after this CL, the reference origin is returned. This change is desirable, because: 1. It makes blink::SecurityOrigin::CreateWithReferenceOrigin compatible with url::Origin::Resolve. This lets us copy additional test assertions from OriginTest.ConstructFromGURL testcase in //url/origin_unittest.cc (url::Origin-specific tests) to AbstractOriginTest::VerifyOriginInvariants in //url/origin_abstract_tests.h (tests shared across blink::SecurityOrigin and url::Origin) 2. It causes "about:blank" to commit with the correct origin (based on the origin of the initiator of the navigation) when the `owner_document` is missing (e.g. when the parent is a remote frame, see also a follow-up CL: https://crrev.com/c/2639656). This lets us have mostly correct test expectations in the new NavigationBrowserTest*ToAboutBlank* tests added in this CL, as well as fix test expectations in some already existing tests: - ChromeNavigationBrowserTest. NavigationInitiatedByCrossSiteSubframeRedirectedToAboutBlank - ExtensionApiTest.TabsUpdate_WebToAboutBlank - MultiOriginSessionRestoreTest.BackToAboutBlank1 - MultiOriginSessionRestoreTest.BackToAboutBlank2 - TabRestoreTest.BackToAboutBlank - SitePerProcessBrowserTest.SandboxFlagsNotInheritedBeforeNavigation - SitePerProcessBrowserTest.SubframeBlankUrlsAfterRestore Supplementary changes ===================== To make sure that the new origin of "about:blank" remains compatible with the process lock, some additional changes need to be made: - ExtensionApiTabTest.Tabs2 navigates to about:blank in noopener mode. We are preserving the initiator_origin (if url were http then the initiator would control SameSite cookies, etc). But if we preserve the initiator origin then "about:blank" needs to commit with the same origin as the initiator. And if the initiator origin requires process locks, then we can’t commit in an unlocked process. Therefore we need to call NavigationRequest::SetSourceSiteInstanceToInitiatorIfNeeded for non-history navigations in no-opener mode. - ExtensionApiTabTest.HostPermission hits a browsing-instance-swap case in DetermineSiteInstanceForURL (swap forced because of going from WebUI to non-WebUI: current_effective_url = chrome://new-tab-page/; destination_effective_url = about:blank). This forces the CL to modify `force_browsing_instance_swap` case in DetermineSiteInstanceForURL to use `source_instance` if the `source_instance` already comes from a different browsing instance. Without this tweak, about:blank would commit in an unlocked site instance and fail with CANNOT_COMMIT_ORIGIN url 'about:blank' origin 'chrome-extension://...'. Summary of new tests added in this CL ===================================== - NavigationBrowserTest.GrandchildToAboutBlank_ABA_SameSite (no process swaps, parent of the navigated frame is a local frame) - NavigationBrowserTest.GrandchildToAboutBlank_ABA_CrossSite (no process swaps, parent of the navigated frame is a remote frame) - NavigationBrowserTest.GrandchildToAboutBlank_ABB_CrossSite (process swap required, initially parent of the navigated frame is a local frame, when committing parent of the navigated frame is a remote frame) - NavigationBrowserTest.TopToAboutBlank_CrossSite (the initiator of the navigation is destroyed as the result of the navigation) - SameSiteSiblingToAboutBlank_CrossSiteTop (initiator of the navigation is not an ancestor nor a child of the navigated frame; the initiator has to be same-origin as the target frame - a cross-origin initiator would be blocked from navigating the target frame) Bug: 585649 Change-Id: Ibc4a25a3af96e65b4d7759a09c3cc47d6fb51356 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2637187 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Avi Drissman <avi@chromium.org> Reviewed-by: Nasko Oskov <nasko@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org> Cr-Commit-Position: refs/heads/master@{#847405}
- Loading branch information