diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/performance/tests/test_performance_paint_timing_helper.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/performance/tests/test_performance_paint_timing_helper.html')
-rw-r--r-- | dom/performance/tests/test_performance_paint_timing_helper.html | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/dom/performance/tests/test_performance_paint_timing_helper.html b/dom/performance/tests/test_performance_paint_timing_helper.html new file mode 100644 index 0000000000..c05b38cac0 --- /dev/null +++ b/dom/performance/tests/test_performance_paint_timing_helper.html @@ -0,0 +1,65 @@ +<!-- + Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ +--> +<!DOCTYPE HTML> +<html> + <!-- + https://bugzilla.mozilla.org/show_bug.cgi?id=1518999 + --> + <head> + <title>Test for Bug 1518999</title> + <meta http-equiv="content-type" content="text/html; charset=UTF-8"> + </head> + <body> + <div id="main"></div> + <div id="image"></div> + <div id="test"> + <script class="testbody" type="text/javascript"> + async function runTest() { + const paintEntries = performance.getEntriesByType('paint'); + opener.is(paintEntries.length, 0, "No paint entries yet"); + + const img = document.createElement("img"); + img.src = "http://example.org/tests/dom/performance/tests/logo.png"; + + img.onload = function() { + function getAndTestEntries(runCount) { + function testEntries(entries) { + opener.is(entries.length, 1, "FCP Only returns"); + opener.is(entries[0].entryType, "paint", "entryType is paint"); + opener.is(entries[0].name, "first-contentful-paint", + "Returned entry should be first-contentful-paint" ); + const fcpEntriesGotByName = + performance.getEntriesByName('first-contentful-paint'); + opener.is(fcpEntriesGotByName.length, 1, "entries length should match"); + opener.is(entries[0], fcpEntriesGotByName[0], "should be the same entry"); + opener.done(); + } + const entries = performance.getEntriesByType('paint'); + if (entries.length < 1) { + if (runCount < 4) { + opener.SimpleTest.requestFlakyTimeout("FCP is being registered asynchronously, so wait a bit of time"); + setTimeout(function() { + getAndTestEntries(runCount + 1); + }, 20); + } else { + opener.ok(false, "Unable to find paint entries within a reasonable amount of time"); + opener.done(); + } + } else { + testEntries(entries); + } + } + getAndTestEntries(1); + } + document.body.appendChild(img); + } + window.onload = function() { + runTest(); + } + </script> + </div> + </div> + </body> +</html> |