Add some minor tweaks to LargestContentfulPaint WPTs

This patch mainly just adds `hide_test_state: true` to
LargestContentfulPaint related tests because the intermittent
test status can be considered as painted elements, which
may interfere the test results.

Plus a few minor tweaks.

Differential Revision: https://phabricator.services.mozilla.com/D151074

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1829388
gecko-commit: 5a6967f96af58025e795f10f462721e612469c1f
gecko-reviewers: emilio
diff --git a/element-timing/image-src-change.html b/element-timing/image-src-change.html
index 9927121..7416a3f 100644
--- a/element-timing/image-src-change.html
+++ b/element-timing/image-src-change.html
@@ -14,6 +14,8 @@
   <script src="resources/element-timing-helpers.js"></script>
   <img elementtiming='my_image' id='my_id' />
   <script>
+    setup({"hide_test_state": true});
+
     const performanceEntryPromise = (pathname) => {
       return new Promise(resolve => {
         new PerformanceObserver((entryList, observer) => {
diff --git a/largest-contentful-paint/element-only-when-fully-active.html b/largest-contentful-paint/element-only-when-fully-active.html
index 41bdc8f..519b249 100644
--- a/largest-contentful-paint/element-only-when-fully-active.html
+++ b/largest-contentful-paint/element-only-when-fully-active.html
@@ -6,6 +6,7 @@
 <script src="/resources/testharnessreport.js"></script>
 <iframe src="resources/iframe-stores-entry.html" id="ifr"></iframe>
 <script>
+  setup({"hide_test_state": true});
   let t = async_test('Only expose element attribute for fully active documents');
   window.triggerTest = t.step_func_done(entry => {
     assert_not_equals(entry.element, null);
diff --git a/largest-contentful-paint/expanded-image.html b/largest-contentful-paint/expanded-image.html
index 55adff9..90f8039 100644
--- a/largest-contentful-paint/expanded-image.html
+++ b/largest-contentful-paint/expanded-image.html
@@ -12,6 +12,7 @@
 <script src="/resources/testharnessreport.js"></script>
 <script src="resources/largest-contentful-paint-helpers.js"></script>
 <script>
+  setup({"hide_test_state": true});
   async_test(function (t) {
     assert_implements(window.LargestContentfulPaint, "LargestContentfulPaint is not implemented");
     const beforeLoad = performance.now();
diff --git a/largest-contentful-paint/first-letter-background.html b/largest-contentful-paint/first-letter-background.html
index d2abd5d..56ac105 100644
--- a/largest-contentful-paint/first-letter-background.html
+++ b/largest-contentful-paint/first-letter-background.html
@@ -14,6 +14,7 @@
 <script src="/resources/testharnessreport.js"></script>
 <script src="resources/largest-contentful-paint-helpers.js"></script>
 <script>
+  setup({"hide_test_state": true});
   async_test(function (t) {
     assert_implements(window.LargestContentfulPaint, "LargestContentfulPaint is not implemented");
     let beforeLoad = performance.now();
diff --git a/largest-contentful-paint/first-paint-equals-lcp-text.html b/largest-contentful-paint/first-paint-equals-lcp-text.html
index 97eb67e..50bccd0 100644
--- a/largest-contentful-paint/first-paint-equals-lcp-text.html
+++ b/largest-contentful-paint/first-paint-equals-lcp-text.html
@@ -5,6 +5,7 @@
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script>
+  setup({"hide_test_state": true});
   async_test(function (t) {
     assert_implements(window.PerformancePaintTiming, "PerformancePaintTiming is not implemented");
     assert_implements(window.LargestContentfulPaint, "LargestContentfulPaint is not implemented");
@@ -27,9 +28,14 @@
             assert_equals(entry.entryType, 'largest-contentful-paint');
             largestContentfulPaintTime = entry.renderTime;
           }
-          if (firstPaintTime && firstContentfulPaintTime && largestContentfulPaintTime) {
-            assert_less_than_equal(firstPaintTime, firstContentfulPaintTime, 'FP should be less than or equal to FCP.');
+          // LCP fires necessarily after first-paint and first-contentful-paint.
+          if (largestContentfulPaintTime) {
             assert_equals(firstContentfulPaintTime, largestContentfulPaintTime, 'FCP should equal LCP.');
+            // In PaintTiming spec, first-paint isn't a hard requirement, browsers can support
+            // first-contentful-paint only.
+            if (firstPaintTime) {
+              assert_less_than_equal(firstPaintTime, firstContentfulPaintTime, 'FP should be less than or equal to FCP.');
+            }
             t.done();
           }
         });
diff --git a/largest-contentful-paint/image-TAO.sub.html b/largest-contentful-paint/image-TAO.sub.html
index 8b7d99e..296fe5e 100644
--- a/largest-contentful-paint/image-TAO.sub.html
+++ b/largest-contentful-paint/image-TAO.sub.html
@@ -7,6 +7,7 @@
 <script src="resources/largest-contentful-paint-helpers.js"></script>
 <div id='my_div'></div>
 <script>
+  setup({"hide_test_state": true});
   async_test(t => {
     assert_implements(window.LargestContentfulPaint, "LargestContentfulPaint is not implemented");
     const remote_img = 'http://{{domains[www]}}:{{ports[http][1]}}/element-timing/resources/TAOImage.py?'
diff --git a/largest-contentful-paint/image-full-viewport.html b/largest-contentful-paint/image-full-viewport.html
index 7da6c5c..e67e21a 100644
--- a/largest-contentful-paint/image-full-viewport.html
+++ b/largest-contentful-paint/image-full-viewport.html
@@ -15,6 +15,7 @@
 <script>
   const viewportWidth = document.documentElement.clientWidth;
   const viewportHeight = document.documentElement.clientHeight;
+  setup({"hide_test_state": true});
   async_test(function (t) {
     assert_implements(window.LargestContentfulPaint, "LargestContentfulPaint is not implemented");
     const beforeLoad = performance.now();
diff --git a/largest-contentful-paint/image-inside-svg.html b/largest-contentful-paint/image-inside-svg.html
index ce965746..77e42fc 100644
--- a/largest-contentful-paint/image-inside-svg.html
+++ b/largest-contentful-paint/image-inside-svg.html
@@ -5,6 +5,7 @@
 <script src="/resources/testharnessreport.js"></script>
 <script src="resources/largest-contentful-paint-helpers.js"></script>
 <script>
+setup({"hide_test_state": true});
 async_test(function (t) {
   assert_implements(window.LargestContentfulPaint, "LargestContentfulPaint is not implemented");
   const beforeLoad = performance.now();
diff --git a/largest-contentful-paint/image-not-fully-visible.html b/largest-contentful-paint/image-not-fully-visible.html
index 8990fd1..1aee495 100644
--- a/largest-contentful-paint/image-not-fully-visible.html
+++ b/largest-contentful-paint/image-not-fully-visible.html
@@ -14,6 +14,7 @@
 <script src="/resources/testharnessreport.js"></script>
 <script src="resources/largest-contentful-paint-helpers.js"></script>
 <script>
+  setup({"hide_test_state": true});
   let beforeRender;
   const viewportWidth = document.documentElement.clientWidth;
   const viewportHeight = document.documentElement.clientHeight;
diff --git a/largest-contentful-paint/image-removed-before-load.html b/largest-contentful-paint/image-removed-before-load.html
index b4e92b4..3e557a4 100644
--- a/largest-contentful-paint/image-removed-before-load.html
+++ b/largest-contentful-paint/image-removed-before-load.html
@@ -8,6 +8,7 @@
 <img id="target"/>
 <img id="target2"/>
 <script>
+  setup({"hide_test_state": true});
   const numInitial = 100;
   const sleep = 1000;
   const small_img_src = '/images/green-16x16.png';
diff --git a/largest-contentful-paint/image-src-change.html b/largest-contentful-paint/image-src-change.html
index f35d803..e0701a2 100644
--- a/largest-contentful-paint/image-src-change.html
+++ b/largest-contentful-paint/image-src-change.html
@@ -7,6 +7,7 @@
 <script src="resources/largest-contentful-paint-helpers.js"></script>
 <img src='/images/black-rectangle.png' id='image_id'/>
 <script>
+  setup({"hide_test_state": true});
   async_test(function (t) {
     assert_implements(window.LargestContentfulPaint, "LargestContentfulPaint is not implemented");
     let beforeLoad = performance.now();
diff --git a/largest-contentful-paint/image-upscaling.html b/largest-contentful-paint/image-upscaling.html
index 5cb3767..b3ce16f 100644
--- a/largest-contentful-paint/image-upscaling.html
+++ b/largest-contentful-paint/image-upscaling.html
@@ -7,12 +7,13 @@
 <script src="resources/largest-contentful-paint-helpers.js"></script>
 <script src="/common/utils.js"></script>
 <script>
+    setup({"hide_test_state": true});
     setup(() =>
         assert_implements(window.LargestContentfulPaint, "LargestContentfulPaint is not implemented"));
 
     const imageURL = `${window.location.origin}/images/blue.png`;
     async function load_image_and_get_lcp_size(t, imageStyle = {}, containerStyle = {}) {
-        const popup = window.open('about:blank');
+        const popup = window.open();
         t.add_cleanup(() => popup.close());
         const image = popup.document.createElement('img');
         image.src = imageURL;
diff --git a/largest-contentful-paint/initially-invisible-images.html b/largest-contentful-paint/initially-invisible-images.html
index d0bede6..b4d68a5 100644
--- a/largest-contentful-paint/initially-invisible-images.html
+++ b/largest-contentful-paint/initially-invisible-images.html
@@ -24,6 +24,7 @@
 </div>
 <script>
 // Spin the carousel
+setup({"hide_test_state": true});
 const images = document.querySelectorAll('img');
 
 let selected = 0;
diff --git a/largest-contentful-paint/invisible-images-composited-1.html b/largest-contentful-paint/invisible-images-composited-1.html
index 7723d2f..6b33c42 100644
--- a/largest-contentful-paint/invisible-images-composited-1.html
+++ b/largest-contentful-paint/invisible-images-composited-1.html
@@ -20,6 +20,9 @@
     will-change: opacity;
   }
 </style>
+<script>
+setup({"hide_test_state": true});
+</script>
 <img src='/images/blue.png' class='opacity0 willChangeTransform' id='opacity0-willChangeTransform'/>
 <img src='/images/green.png' class='visibilityHidden willChangeTransform' id='visibilityHidden'/>
 <img src='/images/red.png' class='displayNone willChangeTransform' id='displayNone'/>
diff --git a/largest-contentful-paint/loadTime-after-appendChild.html b/largest-contentful-paint/loadTime-after-appendChild.html
index 2d19e73..52d8f06 100644
--- a/largest-contentful-paint/loadTime-after-appendChild.html
+++ b/largest-contentful-paint/loadTime-after-appendChild.html
@@ -6,6 +6,7 @@
 <script src="/resources/testharnessreport.js"></script>
 <script src="resources/largest-contentful-paint-helpers.js"></script>
 <script>
+  setup({"hide_test_state": true});
   async_test(function (t) {
     assert_implements(window.LargestContentfulPaint, "LargestContentfulPaint is not implemented");
     let beforeLoad;
diff --git a/largest-contentful-paint/multiple-redirects-TAO.html b/largest-contentful-paint/multiple-redirects-TAO.html
index 50130ee..b974517 100644
--- a/largest-contentful-paint/multiple-redirects-TAO.html
+++ b/largest-contentful-paint/multiple-redirects-TAO.html
@@ -11,6 +11,7 @@
 <img id='image'></img>
 <body>
 <script>
+setup({"hide_test_state": true});
 async_test(t => {
     assert_implements(window.LargestContentfulPaint, "LargestContentfulPaint is not implemented");
     let destUrl = get_host_info().HTTP_REMOTE_ORIGIN
diff --git a/largest-contentful-paint/observe-css-generated-text.html b/largest-contentful-paint/observe-css-generated-text.html
index d4f10fb..21ae685 100644
--- a/largest-contentful-paint/observe-css-generated-text.html
+++ b/largest-contentful-paint/observe-css-generated-text.html
@@ -20,6 +20,7 @@
 </style>
 <body>
   <script>
+    setup({"hide_test_state": true});
     const checkText = (entry, expectedSize, expectedID, beforeRender) => {
       assert_equals(entry.entryType, 'largest-contentful-paint',
         'Entry should be of type largest-contentful-paint');
diff --git a/largest-contentful-paint/redirects-tao-star.html b/largest-contentful-paint/redirects-tao-star.html
index f01c249..5607ed7 100644
--- a/largest-contentful-paint/redirects-tao-star.html
+++ b/largest-contentful-paint/redirects-tao-star.html
@@ -10,6 +10,7 @@
 </head>
 <body>
 <script>
+setup({"hide_test_state": true});
 async_test(t => {
     assert_implements(window.LargestContentfulPaint, "LargestContentfulPaint is not implemented");
     let destUrl = get_host_info().HTTP_REMOTE_ORIGIN
diff --git a/largest-contentful-paint/repeated-image.html b/largest-contentful-paint/repeated-image.html
index a28409a..c69cc5b 100644
--- a/largest-contentful-paint/repeated-image.html
+++ b/largest-contentful-paint/repeated-image.html
@@ -12,6 +12,7 @@
 <script src="/resources/testharnessreport.js"></script>
 <script src="resources/largest-contentful-paint-helpers.js"></script>
 <script>
+  setup({"hide_test_state": true});
   async_test(function (t) {
     assert_implements(window.LargestContentfulPaint, "LargestContentfulPaint is not implemented");
     let beforeLoad = performance.now();
diff --git a/largest-contentful-paint/video-poster.html b/largest-contentful-paint/video-poster.html
index b3a2918..fdc6918 100644
--- a/largest-contentful-paint/video-poster.html
+++ b/largest-contentful-paint/video-poster.html
@@ -5,6 +5,7 @@
 <script src="/resources/testharnessreport.js"></script>
 <script src="resources/largest-contentful-paint-helpers.js"></script>
 <script>
+setup({"hide_test_state": true});
 async_test(function (t) {
     assert_implements(window.LargestContentfulPaint, "LargestContentfulPaint is not implemented");
   const beforeLoad = performance.now();