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:
@@ -148,7 +148,7 @@ void CefRenderFrameObserver::DidCreateScriptContext(
|
||||
}
|
||||
|
||||
// Do this last, in case the client callback modified the window object.
|
||||
framePtr->OnContextCreated();
|
||||
framePtr->OnContextCreated(context);
|
||||
}
|
||||
|
||||
void CefRenderFrameObserver::WillReleaseScriptContext(
|
||||
@@ -157,31 +157,32 @@ void CefRenderFrameObserver::WillReleaseScriptContext(
|
||||
blink::WebLocalFrame* frame = render_frame()->GetWebFrame();
|
||||
CefRefPtr<CefBrowserImpl> browserPtr =
|
||||
CefBrowserImpl::GetBrowserForMainFrame(frame->Top());
|
||||
if (browserPtr) {
|
||||
CefRefPtr<CefApp> application = CefAppManager::Get()->GetApplication();
|
||||
if (application) {
|
||||
CefRefPtr<CefRenderProcessHandler> handler =
|
||||
application->GetRenderProcessHandler();
|
||||
if (handler) {
|
||||
CefRefPtr<CefFrameImpl> framePtr = browserPtr->GetWebFrameImpl(frame);
|
||||
if (!browserPtr)
|
||||
return;
|
||||
|
||||
v8::Isolate* isolate = blink::MainThreadIsolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
CefRefPtr<CefRenderProcessHandler> handler;
|
||||
CefRefPtr<CefApp> application = CefAppManager::Get()->GetApplication();
|
||||
if (application)
|
||||
handler = application->GetRenderProcessHandler();
|
||||
|
||||
// The released context should not be used for script execution.
|
||||
// Depending on how the context is released this may or may not already
|
||||
// be set.
|
||||
blink_glue::CefScriptForbiddenScope forbidScript;
|
||||
CefRefPtr<CefFrameImpl> framePtr = browserPtr->GetWebFrameImpl(frame);
|
||||
|
||||
CefRefPtr<CefV8Context> contextPtr(
|
||||
new CefV8ContextImpl(isolate, context));
|
||||
if (handler) {
|
||||
v8::Isolate* isolate = blink::MainThreadIsolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
|
||||
handler->OnContextReleased(browserPtr.get(), framePtr.get(),
|
||||
contextPtr);
|
||||
}
|
||||
}
|
||||
// The released context should not be used for script execution.
|
||||
// Depending on how the context is released this may or may not already
|
||||
// be set.
|
||||
blink_glue::CefScriptForbiddenScope forbidScript;
|
||||
|
||||
CefRefPtr<CefV8Context> contextPtr(new CefV8ContextImpl(isolate, context));
|
||||
|
||||
handler->OnContextReleased(browserPtr.get(), framePtr.get(), contextPtr);
|
||||
}
|
||||
|
||||
framePtr->OnContextReleased();
|
||||
|
||||
CefV8ReleaseContext(context);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user