[LCP] non-trusted event does not stop the metric (#18083)
* [LCP] non-trusted event does not stop the metric
* Changed test description
diff --git a/largest-contentful-paint/observe-after-untrusted-scroll.html b/largest-contentful-paint/observe-after-untrusted-scroll.html
new file mode 100644
index 0000000..abe753f
--- /dev/null
+++ b/largest-contentful-paint/observe-after-untrusted-scroll.html
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML>
+<meta charset=utf-8>
+<title>Largest Contentful Paint: observe image.</title>
+<body>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+ async_test(function (t) {
+ if (!window.LargestContentfulPaint) {
+ assert_unreached("LargestContentfulPaint is not implemented");
+ }
+ const beforeRender = performance.now();
+ const observer = new PerformanceObserver(
+ t.step_func_done(function(entryList) {
+ assert_equals(entryList.getEntries().length, 1);
+ const entry = entryList.getEntries()[0];
+ assert_equals(entry.entryType, 'largest-contentful-paint');
+ assert_greater_than_equal(entry.renderTime, beforeRender,
+ 'The rendering timestamp should occur after script starts running.');
+ assert_greater_than_equal(performance.now(), entry.renderTime,
+ 'The rendering timestamp should occur before the entry is dispatched to the observer.');
+ assert_equals(entry.startTime, 0);
+ assert_equals(entry.duration, 0);
+ // blue.png is 133 x 106.
+ assert_equals(entry.size, 14098);
+ assert_equals(entry.id, 'image_id');
+ // 25 is the length of "largest-contentful-paint/".
+ const index = window.location.href.lastIndexOf('/') - 25;
+ const pathname = window.location.href.substring(0, index) + '/images/blue.png';
+ assert_equals(entry.url, pathname);
+ assert_greater_than(entry.loadTime, beforeRender,
+ 'The load timestamp should occur after script starts running.');
+ assert_less_than(entry.loadTime, entry.renderTime,
+ 'The load timestamp should occur before the render timestamp.')
+ assert_equals(entry.element, document.getElementById('image_id'));
+ })
+ );
+ observer.observe({type: 'largest-contentful-paint', buffered: true});
+ }, 'Same-origin image after a JS initiated scroll event is observable.');
+ document.body.dispatchEvent(new Event('scroll'));
+ const image = new Image();
+ image.id = 'image_id';
+ image.src = '/images/blue.png';
+ document.body.appendChild(image);
+</script>
+
+</body>