Commit a29bbe70 authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Commit Bot

Convert BlinkTestHostMsg_ResetDone to Mojo in blink test IPC message

This CL migrate the legacy ResetDone IPC message to the new Mojo
in BlinkTestClient interface.

This CL adds a |is_secondary_window_| flag to WebTestRenderFrameObserver
to avoid calling ResetDone twice when a secondary window exists. Then,
it's passed to BlinkTestRunner::DidCommitNavigationInMainFrame to avoid
calling ResetDone twice. Because twice calls of ResetDone can cause a
crash during the web test.

Bug: 1039247
Change-Id: Ia992616449ec54d1e28d2a6804f907cfac404cf7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2009595Reviewed-by: default avatarMike West <mkwst@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Cr-Commit-Position: refs/heads/master@{#738004}
parent 044a8cd3
...@@ -25,6 +25,10 @@ void BlinkTestClientImpl::InitiateLayoutDump() { ...@@ -25,6 +25,10 @@ void BlinkTestClientImpl::InitiateLayoutDump() {
BlinkTestController::Get()->OnInitiateLayoutDump(); BlinkTestController::Get()->OnInitiateLayoutDump();
} }
void BlinkTestClientImpl::ResetDone() {
BlinkTestController::Get()->OnResetDone();
}
void BlinkTestClientImpl::PrintMessageToStderr(const std::string& message) { void BlinkTestClientImpl::PrintMessageToStderr(const std::string& message) {
BlinkTestController::Get()->OnPrintMessageToStderr(message); BlinkTestController::Get()->OnPrintMessageToStderr(message);
} }
......
...@@ -23,6 +23,7 @@ class BlinkTestClientImpl : public mojom::BlinkTestClient { ...@@ -23,6 +23,7 @@ class BlinkTestClientImpl : public mojom::BlinkTestClient {
private: private:
// BlinkTestClient implementation. // BlinkTestClient implementation.
void InitiateLayoutDump() override; void InitiateLayoutDump() override;
void ResetDone() override;
void PrintMessageToStderr(const std::string& message) override; void PrintMessageToStderr(const std::string& message) override;
void Reload() override; void Reload() override;
void OverridePreferences( void OverridePreferences(
......
...@@ -804,7 +804,6 @@ bool BlinkTestController::OnMessageReceived(const IPC::Message& message) { ...@@ -804,7 +804,6 @@ bool BlinkTestController::OnMessageReceived(const IPC::Message& message) {
bool handled = true; bool handled = true;
IPC_BEGIN_MESSAGE_MAP(BlinkTestController, message) IPC_BEGIN_MESSAGE_MAP(BlinkTestController, message)
IPC_MESSAGE_HANDLER(BlinkTestHostMsg_PrintMessage, OnPrintMessage) IPC_MESSAGE_HANDLER(BlinkTestHostMsg_PrintMessage, OnPrintMessage)
IPC_MESSAGE_HANDLER(BlinkTestHostMsg_ResetDone, OnResetDone)
IPC_MESSAGE_HANDLER(WebTestHostMsg_BlockThirdPartyCookies, IPC_MESSAGE_HANDLER(WebTestHostMsg_BlockThirdPartyCookies,
OnBlockThirdPartyCookies) OnBlockThirdPartyCookies)
IPC_MESSAGE_UNHANDLED(handled = false) IPC_MESSAGE_UNHANDLED(handled = false)
...@@ -1019,18 +1018,18 @@ void BlinkTestController::OnTestFinished() { ...@@ -1019,18 +1018,18 @@ void BlinkTestController::OnTestFinished() {
} }
void BlinkTestController::OnCleanupFinished() { void BlinkTestController::OnCleanupFinished() {
if (main_window_) {
main_window_->web_contents()->Stop();
GetBlinkTestControlRemote(
main_window_->web_contents()->GetRenderViewHost()->GetMainFrame())
->Reset();
}
if (secondary_window_) { if (secondary_window_) {
secondary_window_->web_contents()->Stop(); secondary_window_->web_contents()->Stop();
GetBlinkTestControlRemote( GetBlinkTestControlRemote(
secondary_window_->web_contents()->GetRenderViewHost()->GetMainFrame()) secondary_window_->web_contents()->GetRenderViewHost()->GetMainFrame())
->Reset(); ->Reset();
} }
if (main_window_) {
main_window_->web_contents()->Stop();
GetBlinkTestControlRemote(
main_window_->web_contents()->GetRenderViewHost()->GetMainFrame())
->Reset();
}
} }
void BlinkTestController::OnCaptureDumpCompleted(mojom::BlinkTestDumpPtr dump) { void BlinkTestController::OnCaptureDumpCompleted(mojom::BlinkTestDumpPtr dump) {
......
...@@ -96,6 +96,9 @@ interface BlinkTestClient { ...@@ -96,6 +96,9 @@ interface BlinkTestClient {
// BlinkTestMsg_LayoutDumpCompleted. // BlinkTestMsg_LayoutDumpCompleted.
InitiateLayoutDump(); InitiateLayoutDump();
// Notify the browser process the reset was done.
ResetDone();
// Add a message to stderr (not saved to expected output files, for debugging // Add a message to stderr (not saved to expected output files, for debugging
// only). // only).
PrintMessageToStderr(string message); PrintMessageToStderr(string message);
......
...@@ -15,8 +15,6 @@ ...@@ -15,8 +15,6 @@
#define IPC_MESSAGE_START BlinkTestMsgStart #define IPC_MESSAGE_START BlinkTestMsgStart
IPC_MESSAGE_ROUTED0(BlinkTestHostMsg_ResetDone)
// WebTestDelegate related. // WebTestDelegate related.
IPC_MESSAGE_ROUTED1(BlinkTestHostMsg_PrintMessage, std::string /* message */) IPC_MESSAGE_ROUTED1(BlinkTestHostMsg_PrintMessage, std::string /* message */)
......
...@@ -716,15 +716,22 @@ void BlinkTestRunner::CaptureDump( ...@@ -716,15 +716,22 @@ void BlinkTestRunner::CaptureDump(
CaptureDumpComplete(); CaptureDumpComplete();
} }
void BlinkTestRunner::DidCommitNavigationInMainFrame() { void BlinkTestRunner::DidCommitNavigationInMainFrame(bool is_secondary_window) {
WebFrame* main_frame = render_view()->GetWebView()->MainFrame(); WebFrame* main_frame = render_view()->GetWebView()->MainFrame();
if (!waiting_for_reset_ || !main_frame->IsWebLocalFrame()) if (!waiting_for_reset_ || !main_frame->IsWebLocalFrame())
return; return;
GURL url = main_frame->ToWebLocalFrame()->GetDocumentLoader()->GetUrl(); GURL url = main_frame->ToWebLocalFrame()->GetDocumentLoader()->GetUrl();
if (!url.IsAboutBlank()) if (!url.IsAboutBlank())
return; return;
// Avoid a situation where ResetDone is called twice, because
// ResetDone should be called once if a secondary renderer exists.
if (is_secondary_window)
return;
waiting_for_reset_ = false; waiting_for_reset_ = false;
Send(new BlinkTestHostMsg_ResetDone(routing_id()));
GetBlinkTestClientRemote().ResetDone();
} }
// Private methods ----------------------------------------------------------- // Private methods -----------------------------------------------------------
......
...@@ -152,7 +152,7 @@ class BlinkTestRunner : public RenderViewObserver, ...@@ -152,7 +152,7 @@ class BlinkTestRunner : public RenderViewObserver,
void OnReplicateTestConfiguration(mojom::ShellTestConfigurationPtr params); void OnReplicateTestConfiguration(mojom::ShellTestConfigurationPtr params);
void OnSetupSecondaryRenderer(); void OnSetupSecondaryRenderer();
void CaptureDump(mojom::BlinkTestControl::CaptureDumpCallback callback); void CaptureDump(mojom::BlinkTestControl::CaptureDumpCallback callback);
void DidCommitNavigationInMainFrame(); void DidCommitNavigationInMainFrame(bool is_secondary_window);
void OnReset(); void OnReset();
void OnTestFinishedInSecondaryRenderer(); void OnTestFinishedInSecondaryRenderer();
void OnLayoutDumpCompleted(std::string completed_layout_dump); void OnLayoutDumpCompleted(std::string completed_layout_dump);
......
...@@ -64,7 +64,7 @@ void WebTestRenderFrameObserver::DidCommitProvisionalLoad( ...@@ -64,7 +64,7 @@ void WebTestRenderFrameObserver::DidCommitProvisionalLoad(
render_frame()->GetWebFrame()); render_frame()->GetWebFrame());
} }
BlinkTestRunner::Get(render_frame()->GetRenderView()) BlinkTestRunner::Get(render_frame()->GetRenderView())
->DidCommitNavigationInMainFrame(); ->DidCommitNavigationInMainFrame(is_secondary_window_);
} }
void WebTestRenderFrameObserver::DidFailProvisionalLoad() { void WebTestRenderFrameObserver::DidFailProvisionalLoad() {
...@@ -114,6 +114,7 @@ void WebTestRenderFrameObserver::SetTestConfiguration( ...@@ -114,6 +114,7 @@ void WebTestRenderFrameObserver::SetTestConfiguration(
void WebTestRenderFrameObserver::SetupSecondaryRenderer() { void WebTestRenderFrameObserver::SetupSecondaryRenderer() {
BlinkTestRunner::Get(render_frame()->GetRenderView()) BlinkTestRunner::Get(render_frame()->GetRenderView())
->OnSetupSecondaryRenderer(); ->OnSetupSecondaryRenderer();
is_secondary_window_ = true;
} }
void WebTestRenderFrameObserver::Reset() { void WebTestRenderFrameObserver::Reset() {
......
...@@ -47,6 +47,7 @@ class WebTestRenderFrameObserver : public RenderFrameObserver, ...@@ -47,6 +47,7 @@ class WebTestRenderFrameObserver : public RenderFrameObserver,
mojo::AssociatedReceiver<mojom::BlinkTestControl> receiver_{this}; mojo::AssociatedReceiver<mojom::BlinkTestControl> receiver_{this};
bool focus_on_next_commit_ = false; bool focus_on_next_commit_ = false;
bool is_secondary_window_ = false;
DISALLOW_COPY_AND_ASSIGN(WebTestRenderFrameObserver); DISALLOW_COPY_AND_ASSIGN(WebTestRenderFrameObserver);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment