Commit b69c519b authored by Deepanjan Roy's avatar Deepanjan Roy Committed by Commit Bot

Clamp invalidating input time at nav start

In some edge cases (e.g. inaccurate input timestamp provided through
remote debugging protocol) we might receive an input timestamp that is
earlier than navigation start. Since invalidating input timestamp before
navigation start in non-sensical, we clamp it at navigation start.

R=tdresser@chromium.org,japhet@chromium.org

Bug: 797334
Change-Id: Ib12921e5d372b0f676a6182fd3cd643b7e12a5f8
Reviewed-on: https://chromium-review.googlesource.com/895410Reviewed-by: default avatarNate Chapin <japhet@chromium.org>
Reviewed-by: default avatarTimothy Dresser <tdresser@chromium.org>
Commit-Queue: Deepanjan Roy <dproy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534126}
parent 63e34688
......@@ -215,7 +215,13 @@ void InteractiveDetector::OnInvalidatingInputEvent(
if (!page_event_times_.first_invalidating_input.is_null())
return;
page_event_times_.first_invalidating_input = invalidation_time;
// In some edge cases (e.g. inaccurate input timestamp provided through remote
// debugging protocol) we might receive an input timestamp that is earlier
// than navigation start. Since invalidating input timestamp before navigation
// start in non-sensical, we clamp it at navigation start.
page_event_times_.first_invalidating_input =
std::max(invalidation_time, page_event_times_.nav_start);
if (GetSupplementable()->Loader())
GetSupplementable()->Loader()->DidChangePerformanceTiming();
}
......
......@@ -399,6 +399,23 @@ TEST_F(InteractiveDetectorTest, InvalidatingUserInput) {
t0 + 5.0);
}
TEST_F(InteractiveDetectorTest, InvalidatingUserInputClampedAtNavStart) {
double t0 = CurrentTimeTicksInSeconds();
SimulateNavigationStart(t0);
// Network is forever quiet for this test.
SetActiveConnections(1);
SimulateDOMContentLoadedEnd(t0 + 2.0);
SimulateFMPDetected(/* fmp_time */ t0 + 3.0, /* detection_time */ t0 + 4.0);
// Invalidating input timestamp is earlier than navigation start.
SimulateInteractiveInvalidatingInput(t0 - 10.0);
// Run till 5 seconds after long task 2 end.
RunTillTimestamp((t0 + 7.1) + 5.0 + 0.1);
EXPECT_EQ(GetInteractiveTime(), t0 + 3.0); // TTI at FMP.
// Invalidating input timestamp is clamped at navigation start.
EXPECT_EQ(TimeTicksInSeconds(GetDetector()->GetFirstInvalidatingInputTime()),
t0);
}
class InteractiveDetectorTestWithDummyPage : public PageTestBase {
public:
// Public because it's executed on a task queue.
......
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