Skip to content

Commit 675b351

Browse files
committed
Bug 1575301 [wpt PR 18569] - [LargestContentfulPaint] Add tests for invisible images and iframe, a=testonly
Automatic update from web-platform-tests [LargestContentfulPaint] Add tests for invisible images and iframe Bug: 994414 Change-Id: Ica33ea747b8985956ab791f9e55950f46016bda6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1762334 Reviewed-by: Steve Kobes <skobeschromium.org> Commit-Queue: Nicolás Peña Moreno <npmchromium.org> Cr-Commit-Position: refs/heads/master{#689002} -- wpt-commits: 24dc5f097c1bbf98be038b534f3ba83c75c809e1 wpt-pr: 18569 UltraBlame original commit: 0d061585604052d655be17bac418ba092e4578f4
1 parent 6059f1c commit 675b351

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<!DOCTYPE html>
2+
<body>
3+
<p>Text</p>
4+
<img src='/images/blue.png'/>
5+
</body>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE HTML>
2+
<meta charset=utf-8>
3+
<head>
4+
<title>Largest Contentful Paint: do NOT observe elements from same-origin iframes</title>
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
</head>
8+
<body>
9+
<script>
10+
async_test((t) => {
11+
if (!window.LargestContentfulPaint) {
12+
assert_unreached("LargestContentfulPaint is not implemented");
13+
}
14+
const observer = new PerformanceObserver(
15+
t.step_func_done(entryList => {
16+
assert_unreached("Should not have received an entry!");
17+
})
18+
);
19+
observer.observe({type: 'largest-contentful-paint', buffered: true});
20+
// After a delay, assume that no entry was produced.
21+
t.step_timeout(() => {
22+
t.done();
23+
}, 200);
24+
}, 'Element in child iframe is not observed, even if same-origin.');
25+
</script>
26+
<iframe src='resources/iframe-with-content.html'></iframe>
27+
</body>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!DOCTYPE HTML>
2+
<meta charset=utf-8>
3+
<head>
4+
<title>Largest Contentful Paint: invisible images are not observable</title>
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
<style>
8+
.opacity0 {
9+
opacity: 0;
10+
}
11+
.visibilityHidden {
12+
visibility: hidden;
13+
}
14+
.displayNone {
15+
display: none;
16+
}
17+
</style>
18+
</head>
19+
<body>
20+
<script>
21+
async_test(t => {
22+
if (!window.LargestContentfulPaint) {
23+
assert_unreached("LargestContentfulPaint is not implemented");
24+
}
25+
const observer = new PerformanceObserver(
26+
t.step_func_done(entryList => {
27+
// The images should not have caused an entry, so fail test.
28+
assert_unreached('Should not have received an entry! Received one with id '
29+
+ entryList.getEntries()[0].id);
30+
})
31+
);
32+
observer.observe({type: 'largest-contentful-paint', buffered: true});
33+
// Images have been added but should not cause entries to be dispatched.
34+
// Wait for 500ms and end test, ensuring no entry was created.
35+
t.step_timeout(() => {
36+
t.done();
37+
}, 500);
38+
}, 'Images with opacity: 0, visibility: hidden, or display: none are not observable by LargestContentfulPaint.');
39+
</script>
40+
<img src='/images/blue.png' class='opacity0' id='opacity0'/>
41+
<img src='/images/green.png' class='visibilityHidden' id='visibilityHidden'/>
42+
<img src='/images/red.png' class='displayNone' id='displayNone'/>
43+
<div class='opacity0'><img src='/images/yellow.png' id='divOpacity0'/></div>
44+
<div class='visibilityHidden'><img src='/images/yellow.png' id='divVisibilityHidden'/></div>
45+
<div class='displayNone'><img src='/images/yellow.png' id='divDisplayNone'/></div>
46+
</body>

0 commit comments

Comments
 (0)