Commit 5b5bc453 authored by Nicolás Peña Moreno's avatar Nicolás Peña Moreno Committed by Commit Bot

[LargestContentfulPaint] Ignore keyup input events

This CL prevents the detectors from stopping the LCP computations when
a keyup is detected. This prevents refreshing via Ctrl+R from stopping
the computations prematurely, as the reloaded page receives a keup.

Bug: 1034080
Change-Id: Ic22193fd29e9cd939e57e7210b22918d5f203683
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1969051Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726006}
parent 5de85f93
......@@ -237,6 +237,10 @@ class ImagePaintTimingDetectorTest : public testing::Test {
void SimulateScroll() { GetPaintTimingDetector().NotifyScroll(kUserScroll); }
void SimulateKeyUp() {
GetPaintTimingDetector().NotifyInputEvent(WebInputEvent::kKeyUp);
}
scoped_refptr<base::TestMockTimeTaskRunner> test_task_runner_;
frame_test_helpers::WebViewHelper web_view_helper_;
......@@ -984,6 +988,18 @@ TEST_F(ImagePaintTimingDetectorTest, DeactivateAfterUserInput) {
EXPECT_FALSE(GetPaintTimingDetector().GetImagePaintTimingDetector());
}
TEST_F(ImagePaintTimingDetectorTest, ContinueAfterKeyUp) {
SetBodyInnerHTML(R"HTML(
<div id="parent">
<img id="target"></img>
</div>
)HTML");
SimulateKeyUp();
SetImageAndPaint("target", 5, 5);
UpdateAllLifecyclePhasesAndInvokeCallbackIfAny();
EXPECT_TRUE(GetPaintTimingDetector().GetImagePaintTimingDetector());
}
TEST_F(ImagePaintTimingDetectorTest, NullTimeNoCrash) {
SetBodyInnerHTML(R"HTML(
<img id="target"></img>
......
......@@ -176,8 +176,10 @@ void PaintTimingDetector::StopRecordingLargestContentfulPaint() {
}
void PaintTimingDetector::NotifyInputEvent(WebInputEvent::Type type) {
// A single keyup event should be ignored. It could be caused by user actions
// such as refreshing via Ctrl+R.
if (type == WebInputEvent::kMouseMove || type == WebInputEvent::kMouseEnter ||
type == WebInputEvent::kMouseLeave ||
type == WebInputEvent::kMouseLeave || type == WebInputEvent::kKeyUp ||
WebInputEvent::IsPinchGestureEventType(type)) {
return;
}
......
......@@ -111,6 +111,10 @@ class TextPaintTimingDetectorTest : public testing::Test {
GetPaintTimingDetector().NotifyScroll(ScrollType::kUserScroll);
}
void SimulateKeyUp() {
GetPaintTimingDetector().NotifyInputEvent(WebInputEvent::kKeyUp);
}
void InvokeCallback() {
DCHECK_GT(mock_callback_manager_->CountCallbacks(), 0u);
InvokeSwapTimeCallback(mock_callback_manager_);
......@@ -544,6 +548,17 @@ TEST_F(TextPaintTimingDetectorTest,
EXPECT_FALSE(GetLargestTextPaintManager());
}
TEST_F(TextPaintTimingDetectorTest, KeepLargestTextPaintMangerAfterUserInput) {
SetBodyInnerHTML(R"HTML(
)HTML");
AppendDivElementToBody("text");
UpdateAllLifecyclePhasesAndSimulateSwapTime();
EXPECT_TRUE(GetLargestTextPaintManager());
SimulateKeyUp();
EXPECT_TRUE(GetLargestTextPaintManager());
}
TEST_F(TextPaintTimingDetectorTest, LargestTextPaint_ReportLastNullCandidate) {
SetBodyInnerHTML(R"HTML(
)HTML");
......
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