Commit 3dd7a610 authored by danakj's avatar danakj Committed by Chromium LUCI CQ

Improve mac webtest size injection timing

This changes the hook-up of mac web tests to resize the top level
RenderWidgetHostView as soon as the renderer-side objects are created
so that the correct screen rects can be sent to the renderer. Previously
it was hooked up to the asynchronous RenderViewReady() which made it
race with the renderer running the test, a race it happened to win. Now
we do it when
a) The main RenderFrame is created (along with its renderer-side widget)
b) A new window/webcontents is created, and it already has a renderer-
   side main frame when it is wrapped in a Shell.

This will allow us to change the browser-side code notifying about
renderer objects being created without breaking these tests in
https://chromium-review.googlesource.com/c/chromium/src/+/2597851 .

R=dcheng@chromium.org

Bug: 1158869
Change-Id: I645d67c705a9390853c052804edbd07eaea91c95
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2606520
Auto-Submit: danakj <danakj@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#839784}
parent bd3a8a3b
......@@ -144,6 +144,12 @@ Shell* Shell::CreateShell(std::unique_ptr<WebContents> web_contents,
g_platform->SetContents(shell);
g_platform->DidCreateOrAttachWebContents(shell, raw_web_contents);
// If the RenderFrame was created during WebContents construction (as happens
// for windows opened from the renderer) then the Shell won't hear about the
// main frame being created as a WebContentsObservers. This gives the delegate
// a chance to act on the main frame accordingly.
if (raw_web_contents->GetMainFrame()->IsRenderFrameCreated())
g_platform->MainFrameCreated(shell);
return shell;
}
......@@ -222,8 +228,9 @@ Shell* Shell::CreateNewWindow(BrowserContext* browser_context,
return shell;
}
void Shell::RenderViewReady() {
g_platform->RenderViewReady(this);
void Shell::RenderFrameCreated(RenderFrameHost* frame_host) {
if (frame_host == web_contents_->GetMainFrame())
g_platform->MainFrameCreated(this);
}
void Shell::LoadURL(const GURL& url) {
......
......@@ -209,7 +209,7 @@ class Shell : public WebContentsDelegate,
void LoadProgressChanged(double progress) override;
#endif
void TitleWasSet(NavigationEntry* entry) override;
void RenderViewReady() override;
void RenderFrameCreated(RenderFrameHost* frame_host) override;
void OnDevToolsWebContentsDestroyed();
......
......@@ -68,9 +68,10 @@ class ShellPlatformDelegate {
// Set the title of shell window
virtual void SetTitle(Shell* shell, const base::string16& title);
// Called when a RenderView is created for a renderer process; forwarded from
// WebContentsObserver.
virtual void RenderViewReady(Shell* shell);
// Called when the main frame is created in the renderer process; forwarded
// from WebContentsObserver. If navigation creates a new main frame, this may
// occur more than once.
virtual void MainFrameCreated(Shell* shell);
// Allows platforms to override the JavascriptDialogManager. By default
// returns null, which signals that the Shell should use its own instance.
......
......@@ -109,7 +109,7 @@ void ShellPlatformDelegate::SetIsLoading(Shell* shell, bool loading) {
void ShellPlatformDelegate::SetTitle(Shell* shell,
const base::string16& title) {}
void ShellPlatformDelegate::RenderViewReady(Shell* shell) {}
void ShellPlatformDelegate::MainFrameCreated(Shell* shell) {}
bool ShellPlatformDelegate::DestroyShell(Shell* shell) {
return false; // Shell destroys itself.
......
......@@ -82,7 +82,7 @@ void ShellPlatformDelegate::SetIsLoading(Shell* shell, bool loading) {}
void ShellPlatformDelegate::SetTitle(Shell* shell,
const base::string16& title) {}
void ShellPlatformDelegate::RenderViewReady(Shell* shell) {}
void ShellPlatformDelegate::MainFrameCreated(Shell* shell) {}
bool ShellPlatformDelegate::DestroyShell(Shell* shell) {
return false; // Shell destroys itself.
......
......@@ -304,8 +304,7 @@ void ShellPlatformDelegate::SetTitle(Shell* shell,
[shell_data.window.GetNativeNSWindow() setTitle:title_string];
}
void ShellPlatformDelegate::RenderViewReady(Shell* shell) {
}
void ShellPlatformDelegate::MainFrameCreated(Shell* shell) {}
bool ShellPlatformDelegate::DestroyShell(Shell* shell) {
DCHECK(base::Contains(shell_data_map_, shell));
......
......@@ -432,7 +432,7 @@ void ShellPlatformDelegate::SetTitle(Shell* shell,
shell_data.window_widget->widget_delegate()->SetTitle(title);
}
void ShellPlatformDelegate::RenderViewReady(Shell* shell) {}
void ShellPlatformDelegate::MainFrameCreated(Shell* shell) {}
bool ShellPlatformDelegate::DestroyShell(Shell* shell) {
DCHECK(base::Contains(shell_data_map_, shell));
......
......@@ -29,7 +29,7 @@ class WebTestShellPlatformDelegate : public ShellPlatformDelegate {
bool is_enabled) override;
void SetAddressBarURL(Shell* shell, const GURL& url) override;
void SetTitle(Shell* shell, const base::string16& title) override;
void RenderViewReady(Shell* shell) override;
void MainFrameCreated(Shell* shell) override;
std::unique_ptr<JavaScriptDialogManager> CreateJavaScriptDialogManager(
Shell* shell) override;
bool HandleRequestToLockMouse(Shell* shell,
......
......@@ -57,8 +57,8 @@ void WebTestShellPlatformDelegate::SetTitle(Shell* shell,
ShellPlatformDelegate::SetTitle(shell, title);
}
void WebTestShellPlatformDelegate::RenderViewReady(Shell* shell) {
ShellPlatformDelegate::RenderViewReady(shell);
void WebTestShellPlatformDelegate::MainFrameCreated(Shell* shell) {
ShellPlatformDelegate::MainFrameCreated(shell);
}
bool WebTestShellPlatformDelegate::DestroyShell(Shell* shell) {
......
......@@ -96,9 +96,9 @@ void WebTestShellPlatformDelegate::SetTitle(Shell* shell,
}
}
void WebTestShellPlatformDelegate::RenderViewReady(Shell* shell) {
void WebTestShellPlatformDelegate::MainFrameCreated(Shell* shell) {
if (!IsHeadless()) {
ShellPlatformDelegate::RenderViewReady(shell);
ShellPlatformDelegate::MainFrameCreated(shell);
return;
}
......
......@@ -116,9 +116,9 @@ void WebTestShellPlatformDelegate::SetTitle(Shell* shell,
// Nothing in headless mode.
}
void WebTestShellPlatformDelegate::RenderViewReady(Shell* shell) {
void WebTestShellPlatformDelegate::MainFrameCreated(Shell* shell) {
// No difference in headless mode.
ShellPlatformDelegate::RenderViewReady(shell);
ShellPlatformDelegate::MainFrameCreated(shell);
}
bool WebTestShellPlatformDelegate::DestroyShell(Shell* shell) {
......
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