Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Unified Diff: third_party/WebKit/Source/core/paint/FirstMeaningfulPaintDetectorTest.cpp

Issue 2711893002: Loosen FirstMeaningfulPaint UMA network-idle heuristics (Closed)
Patch Set: add tests, rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/paint/FirstMeaningfulPaintDetectorTest.cpp
diff --git a/third_party/WebKit/Source/core/paint/FirstMeaningfulPaintDetectorTest.cpp b/third_party/WebKit/Source/core/paint/FirstMeaningfulPaintDetectorTest.cpp
index 842d2731b0604d96e2da5a3b072ac73c9e1196ee..1beeb38678b1b6dac1e16515a3e22702eac001f7 100644
--- a/third_party/WebKit/Source/core/paint/FirstMeaningfulPaintDetectorTest.cpp
+++ b/third_party/WebKit/Source/core/paint/FirstMeaningfulPaintDetectorTest.cpp
@@ -37,7 +37,21 @@ class FirstMeaningfulPaintDetectorTest : public testing::Test {
detector().notifyPaint();
}
- void simulateNetworkStable() { detector().networkStableTimerFired(nullptr); }
+ void simulateNetworkStable() {
+ document().setParsingState(Document::FinishedParsing);
+ detector().network0QuietTimerFired(nullptr);
+ detector().network2QuietTimerFired(nullptr);
+ }
+
+ void simulateNetwork0Quiet() {
+ document().setParsingState(Document::FinishedParsing);
+ detector().network0QuietTimerFired(nullptr);
+ }
+
+ void simulateNetwork2Quiet() {
+ document().setParsingState(Document::FinishedParsing);
+ detector().network2QuietTimerFired(nullptr);
+ }
private:
static double returnMockTime() {
@@ -126,4 +140,35 @@ TEST_F(FirstMeaningfulPaintDetectorTest,
paintTiming().firstContentfulPaint());
}
+TEST_F(FirstMeaningfulPaintDetectorTest, Network2QuietThen0Quiet) {
+ paintTiming().markFirstContentfulPaint();
+
+ simulateLayoutAndPaint(1);
+ double afterFirstPaint = monotonicallyIncreasingTime();
+ simulateNetwork2Quiet();
+
+ simulateLayoutAndPaint(10);
+ simulateNetwork0Quiet();
+
+ // The first paint is FirstMeaningfulPaint.
+ EXPECT_GT(paintTiming().firstMeaningfulPaint(), 0.0);
+ EXPECT_LT(paintTiming().firstMeaningfulPaint(), afterFirstPaint);
+}
+
+TEST_F(FirstMeaningfulPaintDetectorTest, Network0QuietThen2Quiet) {
+ paintTiming().markFirstContentfulPaint();
+
+ simulateLayoutAndPaint(1);
+ double afterFirstPaint = monotonicallyIncreasingTime();
+ simulateNetwork0Quiet();
+
+ simulateLayoutAndPaint(10);
+ double afterSecondPaint = monotonicallyIncreasingTime();
+ simulateNetwork2Quiet();
+
+ // The second paint is FirstMeaningfulPaint.
+ EXPECT_GT(paintTiming().firstMeaningfulPaint(), afterFirstPaint);
+ EXPECT_LT(paintTiming().firstMeaningfulPaint(), afterSecondPaint);
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698