summaryrefslogtreecommitdiffstats
path: root/dom/performance/tests/test_performance_paint_timing_helper.html
diff options
context:
space:
mode:
Diffstat (limited to 'dom/performance/tests/test_performance_paint_timing_helper.html')
-rw-r--r--dom/performance/tests/test_performance_paint_timing_helper.html65
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>