mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
chrome: Update expectations with same-site BFCache enabled (fixes issue #3301)
With same-site BFCache enabled every navigation can now potentially be served via the BFCache. To support this internally a new top-level RenderFrame object may be created for each new navigation. As a result, OnBrowserCreated may now be called multiple times with the same browser ID in a given renderer process (a behavior previously only seen with cross-site navigations and different renderer processes). BFCache navigations do not trigger the same Chromium notifications as a normal load. To avoid breaking CEF API usage expectations we now synthetically generate the load-related callbacks that would otherwise be missing (OnLoadingStateChange with isLoading=true, OnLoadStart, OnLoadEnd). The |httpStatusCode| argument to OnLoadEnd will be 0 in this case. To test: - Run `FrameHandlerTest.*:MessageRouterTest.*:NavigationTest.*` - Run `NavigationTest.LoadSameOriginLoadURL` for OnBrowserCreated behavior. - Run `NavigationTest.History` for load-related callback behavior.
This commit is contained in:
@@ -294,6 +294,28 @@ bool IsChromeRuntimeEnabled() {
|
||||
return state ? true : false;
|
||||
}
|
||||
|
||||
bool IsBFCacheEnabled() {
|
||||
// Supported by the Chrome runtime only, see issue #3237.
|
||||
if (!IsChromeRuntimeEnabled())
|
||||
return false;
|
||||
|
||||
// Enabled by default starting in M96.
|
||||
static int state = -1;
|
||||
if (state == -1) {
|
||||
CefRefPtr<CefCommandLine> command_line =
|
||||
CefCommandLine::GetGlobalCommandLine();
|
||||
const std::string& value = command_line->GetSwitchValue("disable-features");
|
||||
state = value.find("BackForwardCache") == std::string::npos ? 1 : 0;
|
||||
}
|
||||
return state ? true : false;
|
||||
}
|
||||
|
||||
bool IsSameSiteBFCacheEnabled() {
|
||||
// Same-site BFCache is enabled by default starting in M101 and does not have
|
||||
// a separate configuration flag.
|
||||
return IsBFCacheEnabled();
|
||||
}
|
||||
|
||||
bool IgnoreURL(const std::string& url) {
|
||||
return IsChromeRuntimeEnabled() &&
|
||||
url.find("/favicon.ico") != std::string::npos;
|
||||
|
Reference in New Issue
Block a user