Flaky Test: fast/events/resize-subframe-in-rendering-update.html
https://bugs.webkit.org/show_bug.cgi?id=203140

Reviewed by Simon Fraser.

The flakiness was caused by the race condition between rAF and setTimeout. In many cases,
setTimeout was getting scheduled after the next rAF and prevented some assertions to run in time.

Fixed the flakiness by moving setTimeout to outside the setTimeout in which tests run so that
those assertions would always run.

Rebaselined the test since these assertions in setTimeout are now always included in the results.

* fast/events/resize-subframe-in-rendering-update-expected.txt:
* fast/events/resize-subframe-in-rendering-update.html:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251294 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index c6a0e13..114fbf4 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,21 @@
+2019-10-18  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Flaky Test: fast/events/resize-subframe-in-rendering-update.html
+        https://bugs.webkit.org/show_bug.cgi?id=203140
+
+        Reviewed by Simon Fraser.
+
+        The flakiness was caused by the race condition between rAF and setTimeout. In many cases,
+        setTimeout was getting scheduled after the next rAF and prevented some assertions to run in time.
+
+        Fixed the flakiness by moving setTimeout to outside the setTimeout in which tests run so that
+        those assertions would always run.
+
+        Rebaselined the test since these assertions in setTimeout are now always included in the results.
+
+        * fast/events/resize-subframe-in-rendering-update-expected.txt:
+        * fast/events/resize-subframe-in-rendering-update.html:
+
 2019-10-18  Said Abou-Hallawa  <sabouhallawa@apple.com>
 
         Load event must be fired only for the SVG structurally external elements and the outermost SVG element
diff --git a/LayoutTests/fast/events/resize-subframe-in-rendering-update-expected.txt b/LayoutTests/fast/events/resize-subframe-in-rendering-update-expected.txt
index 27af3b1..e4cddc6 100644
--- a/LayoutTests/fast/events/resize-subframe-in-rendering-update-expected.txt
+++ b/LayoutTests/fast/events/resize-subframe-in-rendering-update-expected.txt
@@ -7,6 +7,8 @@
 iframeA.style.width = "200px"; updateLayout(iframeA)
 iframeAA.style.width = "200px"; updateLayout(iframeAA)
 PASS logs.length is 0
+After 0s setTimeout
+PASS logs.length is 0
 After requestAnimationFrame
 PASS logs.length is 3
 PASS logs.join(", ") is "A, AA, B"
diff --git a/LayoutTests/fast/events/resize-subframe-in-rendering-update.html b/LayoutTests/fast/events/resize-subframe-in-rendering-update.html
index 4c207fd..289a3e8 100644
--- a/LayoutTests/fast/events/resize-subframe-in-rendering-update.html
+++ b/LayoutTests/fast/events/resize-subframe-in-rendering-update.html
@@ -37,10 +37,6 @@
         evalAndLog('iframeA.style.width = "200px"; updateLayout(iframeA)');
         evalAndLog('iframeAA.style.width = "200px"; updateLayout(iframeAA)');
         shouldBe('logs.length', '0');
-        setTimeout(() => {
-            debug('After 0s setTimeout');
-            shouldBe('logs.length', '0');
-        }, 0);
         requestAnimationFrame(() => {
             debug('After requestAnimationFrame');
             shouldBe('logs.length', '3');
@@ -50,6 +46,10 @@
             finishJSTest();
         });
     }, 0);
+    setTimeout(() => {
+        debug('After 0s setTimeout');
+        shouldBe('logs.length', '0');
+    }, 0);
 });
 
 </script>