Commit 97c90c7a authored by Bryan McQuade's avatar Bryan McQuade Committed by Commit Bot

Make FID main frame only in page_load_metrics

Change-Id: I0ccee8c3e4caccefa4df75fef87ad3335d17fa63
Bug: 924765
Reviewed-on: https://chromium-review.googlesource.com/c/1432394
Commit-Queue: Bryan McQuade <bmcquade@chromium.org>
Reviewed-by: default avatarTimothy Dresser <tdresser@chromium.org>
Cr-Commit-Position: refs/heads/master@{#625736}
parent f972a92d
...@@ -1190,7 +1190,8 @@ TEST_F(MetricsWebContentsObserverTest, ...@@ -1190,7 +1190,8 @@ TEST_F(MetricsWebContentsObserverTest,
// Main frame delivers an input notification. Subsequently, a subframe delivers // Main frame delivers an input notification. Subsequently, a subframe delivers
// an input notification, where the input occurred first. Verify that // an input notification, where the input occurred first. Verify that
// FirstInputDelay and FirstInputTimestamp come from the subframe. // FirstInputDelay and FirstInputTimestamp come from the main frame, as FID is
// currently main-frame-only.
TEST_F(MetricsWebContentsObserverTest, TEST_F(MetricsWebContentsObserverTest,
FirstInputDelayAndTimingSubframeFirstDeliveredSecond) { FirstInputDelayAndTimingSubframeFirstDeliveredSecond) {
mojom::PageLoadTiming timing; mojom::PageLoadTiming timing;
...@@ -1231,12 +1232,11 @@ TEST_F(MetricsWebContentsObserverTest, ...@@ -1231,12 +1232,11 @@ TEST_F(MetricsWebContentsObserverTest,
const mojom::InteractiveTiming& interactive_timing = const mojom::InteractiveTiming& interactive_timing =
*complete_timings().back()->interactive_timing; *complete_timings().back()->interactive_timing;
EXPECT_EQ(base::TimeDelta::FromMilliseconds(15), EXPECT_EQ(base::TimeDelta::FromMilliseconds(10),
interactive_timing.first_input_delay); interactive_timing.first_input_delay);
// Ensure the timestamp is from the subframe. The main frame timestamp was 100 // Ensure the timestamp is from the main frame.
// minutes. EXPECT_EQ(interactive_timing.first_input_timestamp,
EXPECT_LT(interactive_timing.first_input_timestamp, base::TimeDelta::FromMinutes(100));
base::TimeDelta::FromMinutes(10));
CheckNoErrorEvents(); CheckNoErrorEvents();
} }
...@@ -1280,7 +1280,6 @@ TEST_F(MetricsWebContentsObserverTest, ...@@ -1280,7 +1280,6 @@ TEST_F(MetricsWebContentsObserverTest,
timing.interactive_timing->first_input_timestamp = timing.interactive_timing->first_input_timestamp =
base::TimeDelta::FromMilliseconds(90); base::TimeDelta::FromMilliseconds(90);
web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl));
SimulateTimingUpdate(timing); SimulateTimingUpdate(timing);
// Navigate again to confirm the timing updated for the mainframe message. // Navigate again to confirm the timing updated for the mainframe message.
...@@ -1330,7 +1329,6 @@ TEST_F(MetricsWebContentsObserverTest, LongestInputInMainFrame) { ...@@ -1330,7 +1329,6 @@ TEST_F(MetricsWebContentsObserverTest, LongestInputInMainFrame) {
base::TimeDelta::FromMilliseconds(100); base::TimeDelta::FromMilliseconds(100);
main_frame_timing.interactive_timing->longest_input_timestamp = main_frame_timing.interactive_timing->longest_input_timestamp =
base::TimeDelta::FromMilliseconds(2000); base::TimeDelta::FromMilliseconds(2000);
web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl));
SimulateTimingUpdate(main_frame_timing); SimulateTimingUpdate(main_frame_timing);
// Second subframe. // Second subframe.
...@@ -1366,6 +1364,9 @@ TEST_F(MetricsWebContentsObserverTest, LongestInputInMainFrame) { ...@@ -1366,6 +1364,9 @@ TEST_F(MetricsWebContentsObserverTest, LongestInputInMainFrame) {
// LID (15ms) LID (100ms) LID (200ms) // LID (15ms) LID (100ms) LID (200ms)
// //
// Delivery order: Main Frame -> Subframe1 -> Subframe2. // Delivery order: Main Frame -> Subframe1 -> Subframe2.
//
// Since LID is only recorded in the main frame, we expect the subframe LID to
// be ignored.
TEST_F(MetricsWebContentsObserverTest, LongestInputInSubframe) { TEST_F(MetricsWebContentsObserverTest, LongestInputInSubframe) {
content::WebContentsTester* web_contents_tester = content::WebContentsTester* web_contents_tester =
content::WebContentsTester::For(web_contents()); content::WebContentsTester::For(web_contents());
...@@ -1413,15 +1414,11 @@ TEST_F(MetricsWebContentsObserverTest, LongestInputInSubframe) { ...@@ -1413,15 +1414,11 @@ TEST_F(MetricsWebContentsObserverTest, LongestInputInSubframe) {
const mojom::InteractiveTiming& interactive_timing = const mojom::InteractiveTiming& interactive_timing =
*complete_timings().back()->interactive_timing; *complete_timings().back()->interactive_timing;
EXPECT_EQ(base::TimeDelta::FromMilliseconds(200), EXPECT_EQ(base::TimeDelta::FromMilliseconds(100),
interactive_timing.longest_input_delay); interactive_timing.longest_input_delay);
// Actual LID timestamp includes the delta between navigation start in EXPECT_EQ(interactive_timing.longest_input_timestamp.value(),
// subframe2 and navigation time in the main frame. That delta varies with base::TimeDelta::FromMilliseconds(2000));
// different runs, so we only check here that the timestamp is greater than
// 3s.
EXPECT_GT(interactive_timing.longest_input_timestamp.value(),
base::TimeDelta::FromMilliseconds(3000));
CheckNoErrorEvents(); CheckNoErrorEvents();
} }
......
...@@ -369,29 +369,16 @@ class PageLoadTimingMerger { ...@@ -369,29 +369,16 @@ class PageLoadTimingMerger {
new_interactive_timing.first_invalidating_input; new_interactive_timing.first_invalidating_input;
target_interactive_timing->interactive_detection = target_interactive_timing->interactive_detection =
new_interactive_timing.interactive_detection; new_interactive_timing.interactive_detection;
}
if (MaybeUpdateTimeDelta(&target_interactive_timing->first_input_timestamp, // first/longest input delay are currently only tracked in the main frame.
navigation_start_offset,
new_interactive_timing.first_input_timestamp)) {
// If we updated the first input timestamp, also update the
// associated first input delay.
target_interactive_timing->first_input_delay = target_interactive_timing->first_input_delay =
new_interactive_timing.first_input_delay; new_interactive_timing.first_input_delay;
} target_interactive_timing->first_input_timestamp =
new_interactive_timing.first_input_timestamp;
if (new_interactive_timing.longest_input_delay.has_value()) { target_interactive_timing->longest_input_delay =
base::TimeDelta new_longest_input_timestamp = new_interactive_timing.longest_input_delay;
navigation_start_offset + target_interactive_timing->longest_input_timestamp =
new_interactive_timing.longest_input_timestamp.value(); new_interactive_timing.longest_input_timestamp;
if (!target_interactive_timing->longest_input_delay.has_value() ||
new_interactive_timing.longest_input_delay.value() >
target_interactive_timing->longest_input_delay.value()) {
target_interactive_timing->longest_input_delay =
new_interactive_timing.longest_input_delay;
target_interactive_timing->longest_input_timestamp =
new_longest_input_timestamp;
}
} }
} }
......
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