[LCPP] Read-path test: ElementLocator matching <img>s priority bumed to VeryHigh
This CL adds a test case for the read path added in https://crrev.com/c/4672510 The test html is third_party/blink/web_tests/http/tests/lcp_critical_path_predictor/prioritize_lcp_image.php , but it requires the following test infra changes to run: - NonAssociatedWebTestControlHost mojom binding so it can be accessed from mojo JS binding. Context: discussion at https://chromium.slack.com/archives/CGGGVPSQ4/p1688601297545099 - WebTestContentBrowserClient injects LCPP hint at `DidStartNavigation` if it was supplied via NonAssociatedWebTestControlHost. - BUILD.gn files are modified so that they will generate wire format protos used for testing from text protos. - `lcpp` VirtualTestSuite is added, since the test require the LCPCriticalPathPredictor feature flag to be enabled until the feature is unflagged. Bug: 1419756 Change-Id: Ib7447341808d2df4e5ca374c42362e872c11b1f0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4673124 Auto-Submit: Kouhei Ueno <kouhei@chromium.org> Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org> Reviewed-by: Rakina Zata Amni <rakina@chromium.org> Commit-Queue: Takashi Toyoshima <toyoshim@chromium.org> Cr-Commit-Position: refs/heads/main@{#1174559}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
38c4f7db70
commit
17e52a99ef
content/web_test
browser
web_test_content_browser_client.ccweb_test_content_browser_client.hweb_test_control_host.ccweb_test_control_host.h
common
third_party/blink/web_tests
@@ -366,6 +366,12 @@ void WebTestContentBrowserClient::ExposeInterfacesToRenderer(
|
||||
base::BindRepeating(&WebTestContentBrowserClient::BindWebTestControlHost,
|
||||
base::Unretained(this),
|
||||
render_process_host->GetID()));
|
||||
|
||||
registry->AddInterface(
|
||||
base::BindRepeating(
|
||||
&WebTestContentBrowserClient::BindNonAssociatedWebTestControlHost,
|
||||
base::Unretained(this)),
|
||||
ui_task_runner);
|
||||
}
|
||||
|
||||
void WebTestContentBrowserClient::BindPermissionAutomation(
|
||||
@@ -657,6 +663,14 @@ void WebTestContentBrowserClient::BindWebTestControlHost(
|
||||
render_process_id, std::move(receiver));
|
||||
}
|
||||
|
||||
void WebTestContentBrowserClient::BindNonAssociatedWebTestControlHost(
|
||||
mojo::PendingReceiver<mojom::NonAssociatedWebTestControlHost> receiver) {
|
||||
if (WebTestControlHost::Get()) {
|
||||
WebTestControlHost::Get()->BindNonAssociatedWebTestControlHost(
|
||||
std::move(receiver));
|
||||
}
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
bool WebTestContentBrowserClient::PreSpawnChild(
|
||||
sandbox::TargetConfig* config,
|
||||
|
@@ -160,6 +160,9 @@ class WebTestContentBrowserClient : public ShellContentBrowserClient {
|
||||
int render_process_id,
|
||||
mojo::PendingAssociatedReceiver<mojom::WebTestControlHost> receiver);
|
||||
|
||||
void BindNonAssociatedWebTestControlHost(
|
||||
mojo::PendingReceiver<mojom::NonAssociatedWebTestControlHost> receiver);
|
||||
|
||||
bool block_popups_ = true;
|
||||
bool screen_orientation_changed_ = false;
|
||||
|
||||
|
@@ -685,6 +685,7 @@ bool WebTestControlHost::ResetBrowserAfterWebTest() {
|
||||
expected_pixel_hash_.clear();
|
||||
test_url_ = GURL();
|
||||
prefs_ = blink::web_pref::WebPreferences();
|
||||
lcpp_hint_ = absl::nullopt;
|
||||
should_override_prefs_ = false;
|
||||
WebTestContentBrowserClient::Get()->SetPopupBlockingEnabled(true);
|
||||
WebTestContentBrowserClient::Get()->ResetMockClipboardHosts();
|
||||
@@ -1065,6 +1066,13 @@ void WebTestControlHost::RenderViewDeleted(RenderViewHost* render_view_host) {
|
||||
main_window_render_view_hosts_.erase(render_view_host);
|
||||
}
|
||||
|
||||
void WebTestControlHost::DidStartNavigation(
|
||||
NavigationHandle* navigation_handle) {
|
||||
if (lcpp_hint_) {
|
||||
navigation_handle->SetLCPPNavigationHint(lcpp_hint_.value());
|
||||
}
|
||||
}
|
||||
|
||||
void WebTestControlHost::ReadyToCommitNavigation(
|
||||
NavigationHandle* navigation_handle) {
|
||||
NavigationRequest* request = NavigationRequest::From(navigation_handle);
|
||||
@@ -1783,6 +1791,11 @@ void WebTestControlHost::DisableAutoResize(const gfx::Size& new_size) {
|
||||
main_window_->ResizeWebContentForTests(new_size);
|
||||
}
|
||||
|
||||
void WebTestControlHost::SetLCPPNavigationHint(
|
||||
blink::mojom::LCPCriticalPathPredictorNavigationTimeHintPtr hint) {
|
||||
lcpp_hint_ = *hint.get();
|
||||
}
|
||||
|
||||
void WebTestControlHost::GoToOffset(int offset) {
|
||||
main_window_->GoBackOrForward(offset);
|
||||
}
|
||||
@@ -1844,6 +1857,10 @@ void WebTestControlHost::PrepareRendererForNextWebTest() {
|
||||
//
|
||||
// Note: this navigation might happen in a new process, depending on the
|
||||
// COOP policy of the previous document.
|
||||
|
||||
// Avoid sending LCPP hint on the about:blank navigation.
|
||||
lcpp_hint_ = absl::nullopt;
|
||||
|
||||
NavigationController::LoadURLParams params((GURL(kAboutBlankResetWebTest)));
|
||||
params.transition_type = ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED);
|
||||
params.should_clear_history_list = true;
|
||||
@@ -2001,6 +2018,11 @@ void WebTestControlHost::BindWebTestControlHostForRenderer(
|
||||
receiver_bindings_.Add(this, std::move(receiver), render_process_id);
|
||||
}
|
||||
|
||||
void WebTestControlHost::BindNonAssociatedWebTestControlHost(
|
||||
mojo::PendingReceiver<mojom::NonAssociatedWebTestControlHost> receiver) {
|
||||
non_associated_receiver_bindings_.Add(this, std::move(receiver));
|
||||
}
|
||||
|
||||
mojo::AssociatedRemote<mojom::WebTestRenderFrame>&
|
||||
WebTestControlHost::GetWebTestRenderFrameRemote(RenderFrameHost* frame) {
|
||||
GlobalRenderFrameHostId key(frame->GetProcess()->GetID(),
|
||||
|
@@ -38,6 +38,7 @@
|
||||
#include "mojo/public/cpp/bindings/associated_receiver_set.h"
|
||||
#include "mojo/public/cpp/bindings/associated_remote.h"
|
||||
#include "third_party/blink/public/common/web_preferences/web_preferences.h"
|
||||
#include "third_party/blink/public/mojom/lcp_critical_path_predictor/lcp_critical_path_predictor.mojom.h"
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
|
||||
class SkBitmap;
|
||||
@@ -114,7 +115,8 @@ class WebTestResultPrinter {
|
||||
class WebTestControlHost : public WebContentsObserver,
|
||||
public RenderProcessHostObserver,
|
||||
public GpuDataManagerObserver,
|
||||
public mojom::WebTestControlHost {
|
||||
public mojom::WebTestControlHost,
|
||||
public mojom::NonAssociatedWebTestControlHost {
|
||||
public:
|
||||
static WebTestControlHost* Get();
|
||||
|
||||
@@ -153,6 +155,9 @@ class WebTestControlHost : public WebContentsObserver,
|
||||
int render_process_id,
|
||||
mojo::PendingAssociatedReceiver<mojom::WebTestControlHost> receiver);
|
||||
|
||||
void BindNonAssociatedWebTestControlHost(
|
||||
mojo::PendingReceiver<mojom::NonAssociatedWebTestControlHost> receiver);
|
||||
|
||||
const WebTestRuntimeFlags& web_test_runtime_flags() const {
|
||||
return web_test_runtime_flags_;
|
||||
}
|
||||
@@ -190,6 +195,7 @@ class WebTestControlHost : public WebContentsObserver,
|
||||
void RenderFrameHostChanged(RenderFrameHost* old_host,
|
||||
RenderFrameHost* new_host) override;
|
||||
void RenderViewDeleted(RenderViewHost* render_view_host) override;
|
||||
void DidStartNavigation(NavigationHandle* navigation_handle) override;
|
||||
void ReadyToCommitNavigation(NavigationHandle* navigation_handle) override;
|
||||
void DidFinishNavigation(NavigationHandle* navigation) override;
|
||||
|
||||
@@ -261,6 +267,9 @@ class WebTestControlHost : public WebContentsObserver,
|
||||
void EnableAutoResize(const gfx::Size& min_size,
|
||||
const gfx::Size& max_size) override;
|
||||
void DisableAutoResize(const gfx::Size& new_size) override;
|
||||
void SetLCPPNavigationHint(
|
||||
blink::mojom::LCPCriticalPathPredictorNavigationTimeHintPtr hint)
|
||||
override;
|
||||
|
||||
void DiscardMainWindow();
|
||||
// Closes all windows opened by the test. This is every window but the main
|
||||
@@ -358,6 +367,14 @@ class WebTestControlHost : public WebContentsObserver,
|
||||
bool should_override_prefs_ = false;
|
||||
blink::web_pref::WebPreferences prefs_;
|
||||
|
||||
// When populated, simulate a LCPP backend by sending this hint data along
|
||||
// navigations (typically reload of the same page).
|
||||
// This is set by the LCPP web_tests via
|
||||
// NonAssociatedWebTestControlHost::SetLCPPNavigationHint mojom interface.
|
||||
// This is reset before switching to the next test page.
|
||||
absl::optional<blink::mojom::LCPCriticalPathPredictorNavigationTimeHint>
|
||||
lcpp_hint_;
|
||||
|
||||
bool crash_when_leak_found_ = false;
|
||||
std::unique_ptr<LeakDetector> leak_detector_;
|
||||
|
||||
@@ -426,6 +443,9 @@ class WebTestControlHost : public WebContentsObserver,
|
||||
int /*render_process_id*/>
|
||||
receiver_bindings_;
|
||||
|
||||
mojo::ReceiverSet<mojom::NonAssociatedWebTestControlHost>
|
||||
non_associated_receiver_bindings_;
|
||||
|
||||
base::ScopedTempDir writable_directory_for_tests_;
|
||||
|
||||
enum class NextPointerLockAction {
|
||||
|
@@ -8,6 +8,7 @@ import "mojo/public/mojom/base/file_path.mojom";
|
||||
import "mojo/public/mojom/base/string16.mojom";
|
||||
import "mojo/public/mojom/base/values.mojom";
|
||||
import "skia/public/mojom/bitmap.mojom";
|
||||
import "third_party/blink/public/mojom/lcp_critical_path_predictor/lcp_critical_path_predictor.mojom"; // presubmit: ignore-long-line
|
||||
import "third_party/blink/public/mojom/permissions/permission_status.mojom";
|
||||
import "third_party/blink/public/mojom/webpreferences/web_preferences.mojom";
|
||||
import "ui/gfx/geometry/mojom/geometry.mojom";
|
||||
@@ -338,3 +339,15 @@ interface WebTestControlHost {
|
||||
// Disable Auto Resize mode, resizing the contents to `new_size`.
|
||||
DisableAutoResize(gfx.mojom.Size new_size);
|
||||
};
|
||||
|
||||
// Web test messages sent from the renderer process to the browser.
|
||||
// This provides a message pipe from each renderer to the global
|
||||
// WebTestControlHost in the browser.
|
||||
// This is very similar to WebTestControlHost, but the interface is not
|
||||
// associated to the legacy IPC channel, so can be used from mojo JS binding
|
||||
// directly.
|
||||
interface NonAssociatedWebTestControlHost {
|
||||
// Provide the specified LCPP navigation time hint to next navigation.
|
||||
SetLCPPNavigationHint(
|
||||
blink.mojom.LCPCriticalPathPredictorNavigationTimeHint hint);
|
||||
};
|
||||
|
Reference in New Issue
Block a user