Commit 58051e42 authored by Nicolás Peña Moreno's avatar Nicolás Peña Moreno Committed by Commit Bot

[LargestContentfulPaint] Set startTime

Currently startTime is 0, which is a problem because getEntries()
methods all sort by startTime. To help with this problem, we set the
startTime to renderTime, if available, or to loadTime, if renderTime is
nt available.

Bug: 965505
Change-Id: Ie70b69269f7ce4be0fdc94f33a44a84e062d3ba5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1719379Reviewed-by: default avatarYoav Weiss <yoavweiss@chromium.org>
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681147}
parent 758185a9
...@@ -10,13 +10,14 @@ ...@@ -10,13 +10,14 @@
namespace blink { namespace blink {
LargestContentfulPaint::LargestContentfulPaint(double render_time, LargestContentfulPaint::LargestContentfulPaint(double start_time,
double render_time,
uint64_t size, uint64_t size,
double load_time, double load_time,
const AtomicString& id, const AtomicString& id,
const String& url, const String& url,
Element* element) Element* element)
: PerformanceEntry(g_empty_atom, 0, 0), : PerformanceEntry(g_empty_atom, start_time, start_time),
size_(size), size_(size),
render_time_(render_time), render_time_(render_time),
load_time_(load_time), load_time_(load_time),
......
...@@ -17,7 +17,8 @@ class CORE_EXPORT LargestContentfulPaint final : public PerformanceEntry { ...@@ -17,7 +17,8 @@ class CORE_EXPORT LargestContentfulPaint final : public PerformanceEntry {
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
public: public:
LargestContentfulPaint(double render_time, LargestContentfulPaint(double start_time,
double render_time,
uint64_t size, uint64_t size,
double load_time, double load_time,
const AtomicString& id, const AtomicString& id,
......
...@@ -446,9 +446,13 @@ void WindowPerformance::OnLargestContentfulPaintUpdated( ...@@ -446,9 +446,13 @@ void WindowPerformance::OnLargestContentfulPaintUpdated(
const AtomicString& id, const AtomicString& id,
const String& url, const String& url,
Element* element) { Element* element) {
double render_timestamp = MonotonicTimeToDOMHighResTimeStamp(paint_time);
double load_timestamp = MonotonicTimeToDOMHighResTimeStamp(load_time);
double start_timestamp =
render_timestamp != 0.0 ? render_timestamp : load_timestamp;
auto* entry = MakeGarbageCollected<LargestContentfulPaint>( auto* entry = MakeGarbageCollected<LargestContentfulPaint>(
MonotonicTimeToDOMHighResTimeStamp(paint_time), paint_size, start_timestamp, render_timestamp, paint_size, load_timestamp, id, url,
MonotonicTimeToDOMHighResTimeStamp(load_time), id, url, element); element);
if (HasObserverFor(PerformanceEntry::kLargestContentfulPaint)) if (HasObserverFor(PerformanceEntry::kLargestContentfulPaint))
NotifyObserversOfEntry(*entry); NotifyObserversOfEntry(*entry);
AddLargestContentfulPaint(entry); AddLargestContentfulPaint(entry);
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
'The rendering timestamp should occur after script starts running.'); 'The rendering timestamp should occur after script starts running.');
assert_greater_than_equal(performance.now(), entry.renderTime, assert_greater_than_equal(performance.now(), entry.renderTime,
'The rendering timestamp should occur before the entry is dispatched to the observer.'); 'The rendering timestamp should occur before the entry is dispatched to the observer.');
assert_equals(entry.startTime, 0); assert_equals(entry.startTime, entry.renderTime, 'startTime should equal renderTime');
assert_equals(entry.duration, 0); assert_equals(entry.duration, 0);
// black-rectangle.png is 100 x 50. It occupies 50 x 50 so size will be bounded by the displayed size. // black-rectangle.png is 100 x 50. It occupies 50 x 50 so size will be bounded by the displayed size.
assert_equals(entry.size, 2500); assert_equals(entry.size, 2500);
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
const entry = entryList.getEntries()[0]; const entry = entryList.getEntries()[0];
assert_equals(entry.entryType, 'largest-contentful-paint'); assert_equals(entry.entryType, 'largest-contentful-paint');
assert_equals(entry.renderTime, 0, 'The renderTime value should be 0 for a cross origin image.'); assert_equals(entry.renderTime, 0, 'The renderTime value should be 0 for a cross origin image.');
assert_equals(entry.startTime, 0); assert_equals(entry.startTime, entry.loadTime, 'startTime should equal loadTime');
assert_equals(entry.duration, 0); assert_equals(entry.duration, 0);
// blue.png is 133 x 106. // blue.png is 133 x 106.
assert_equals(entry.size, 14098); assert_equals(entry.size, 14098);
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
'The rendering timestamp should occur after script starts running.'); 'The rendering timestamp should occur after script starts running.');
assert_greater_than_equal(performance.now(), entry.renderTime, assert_greater_than_equal(performance.now(), entry.renderTime,
'The rendering timestamp should occur before the entry is dispatched to the observer.'); 'The rendering timestamp should occur before the entry is dispatched to the observer.');
assert_equals(entry.startTime, 0); assert_equals(entry.startTime, entry.renderTime, 'startTime should equal renderTime');
assert_equals(entry.duration, 0); assert_equals(entry.duration, 0);
// black-rectangle.png is 100 x 50. It occupies 300 x 300 so size will be bounded by the intrinsic size. // black-rectangle.png is 100 x 50. It occupies 300 x 300 so size will be bounded by the intrinsic size.
assert_equals(entry.size, 5000); assert_equals(entry.size, 5000);
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
'The rendering timestamp should occur after script starts running.'); 'The rendering timestamp should occur after script starts running.');
assert_greater_than_equal(performance.now(), entry.renderTime, assert_greater_than_equal(performance.now(), entry.renderTime,
'The rendering timestamp should occur before the entry is dispatched to the observer.'); 'The rendering timestamp should occur before the entry is dispatched to the observer.');
assert_equals(entry.startTime, 0); assert_equals(entry.startTime, entry.renderTime, 'startTime should equal renderTime');
assert_equals(entry.duration, 0); assert_equals(entry.duration, 0);
if (firstCallback) { if (firstCallback) {
// blue.png is 133 x 106. // blue.png is 133 x 106.
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
assert_equals(entryList.getEntries().length, 1); assert_equals(entryList.getEntries().length, 1);
const entry = entryList.getEntries()[0]; const entry = entryList.getEntries()[0];
assert_equals(entry.entryType, 'largest-contentful-paint'); assert_equals(entry.entryType, 'largest-contentful-paint');
assert_equals(entry.startTime, 0); assert_equals(entry.startTime, entry.renderTime, 'startTime should equal renderTime');
assert_equals(entry.duration, 0); assert_equals(entry.duration, 0);
assert_equals(entry.url, window.location.origin + '/images/black-rectangle.png'); assert_equals(entry.url, window.location.origin + '/images/black-rectangle.png');
assert_greater_than(entry.renderTime, entry.loadTime, assert_greater_than(entry.renderTime, entry.loadTime,
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
'The rendering timestamp should occur after script starts running.'); 'The rendering timestamp should occur after script starts running.');
assert_greater_than_equal(performance.now(), entry.renderTime, assert_greater_than_equal(performance.now(), entry.renderTime,
'The rendering timestamp should occur before the entry is dispatched to the observer.'); 'The rendering timestamp should occur before the entry is dispatched to the observer.');
assert_equals(entry.startTime, 0); assert_equals(entry.startTime, entry.renderTime, 'startTime should equal renderTime');
assert_equals(entry.duration, 0); assert_equals(entry.duration, 0);
// blue.png is 133 x 106. // blue.png is 133 x 106.
assert_equals(entry.size, 14098); assert_equals(entry.size, 14098);
......
...@@ -22,7 +22,7 @@ p { ...@@ -22,7 +22,7 @@ p {
assert_equals(entry.entryType, 'largest-contentful-paint'); assert_equals(entry.entryType, 'largest-contentful-paint');
assert_greater_than_equal(entry.renderTime, beforeRender); assert_greater_than_equal(entry.renderTime, beforeRender);
assert_greater_than_equal(performance.now(), entry.renderTime); assert_greater_than_equal(performance.now(), entry.renderTime);
assert_equals(entry.startTime, 0); assert_equals(entry.startTime, entry.renderTime, 'startTime should equal renderTime');
assert_equals(entry.duration, 0); assert_equals(entry.duration, 0);
// Some lower bound: height of at least 12 px. // Some lower bound: height of at least 12 px.
// Width of at least 100 px. // Width of at least 100 px.
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
assert_equals(entryList.getEntries().length, 1); assert_equals(entryList.getEntries().length, 1);
const entry = entryList.getEntries()[0]; const entry = entryList.getEntries()[0];
assert_equals(entry.entryType, 'largest-contentful-paint'); assert_equals(entry.entryType, 'largest-contentful-paint');
assert_equals(entry.startTime, 0); assert_equals(entry.startTime, entry.renderTime, 'startTime should equal renderTime');
assert_equals(entry.duration, 0); assert_equals(entry.duration, 0);
assert_equals(entry.url, path); assert_equals(entry.url, path);
assert_less_than(entry.renderTime, performance.now(), assert_less_than(entry.renderTime, performance.now(),
......
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