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:
Marshall Greenblatt
2022-04-05 13:22:32 -04:00
parent a3b1dc01ea
commit 21cf732e7f
14 changed files with 479 additions and 183 deletions

View File

@ -22,6 +22,8 @@
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/dom/node.h"
#include "third_party/blink/renderer/core/editing/serializers/serialization.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/execution_context/execution_context_lifecycle_state_observer.h"
#include "third_party/blink/renderer/core/exported/web_view_impl.h"
#include "third_party/blink/renderer/core/frame/frame_owner.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
@ -220,6 +222,43 @@ bool IsScriptForbidden() {
return blink::ScriptForbiddenScope::IsScriptForbidden();
}
std::unique_ptr<CefObserverRegistration>
RegisterExecutionContextLifecycleStateObserver(
v8::Local<v8::Context> context,
CefExecutionContextLifecycleStateObserver* observer) {
class Observer : public blink::GarbageCollected<Observer>,
public blink::ExecutionContextLifecycleStateObserver {
public:
Observer(blink::ExecutionContext* execution_context,
CefExecutionContextLifecycleStateObserver* observer)
: blink::ExecutionContextLifecycleStateObserver(execution_context),
observer_(observer) {
UpdateStateIfNeeded();
}
void ContextLifecycleStateChanged(
blink::mojom::blink::FrameLifecycleState state) override {
observer_->ContextLifecycleStateChanged(state);
}
void ContextDestroyed() override {}
private:
CefExecutionContextLifecycleStateObserver* observer_;
};
class Registration : public CefObserverRegistration {
public:
Registration(blink::Persistent<Observer> observer) : observer_(observer) {}
private:
blink::Persistent<Observer> observer_;
};
return std::make_unique<Registration>(blink::MakeGarbageCollected<Observer>(
blink::ExecutionContext::From(context), observer));
}
void RegisterURLSchemeAsSupportingFetchAPI(const blink::WebString& scheme) {
blink::SchemeRegistry::RegisterURLSchemeAsSupportingFetchAPI(scheme);
}