scrollingcoordinator/ios/ui-scrolling-tree.html is a Flaky Failure on iPad
https://bugs.webkit.org/show_bug.cgi?id=203119
rdar://problem/52970947

Reviewed by Wenson Hsieh.

iPad viewport heuristics (WebPage::immediatelyShrinkToFitContent()) run on a zero-delay
timer after page load, which races with this test getting the UI-side scrolling tree
and makes the test flakey.

Fix by turning off the heuristics with "contentMode=mobile". Also fix the test
to use UIHelper to get the scrolling tree.

* platform/ipad/TestExpectations:
* platform/ipad/scrollingcoordinator/ios/ui-scrolling-tree-expected.txt:
* scrollingcoordinator/ios/ui-scrolling-tree.html:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251375 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 45f3a44..905c06c 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,5 +1,24 @@
 2019-10-21  Simon Fraser  <simon.fraser@apple.com>
 
+        scrollingcoordinator/ios/ui-scrolling-tree.html is a Flaky Failure on iPad
+        https://bugs.webkit.org/show_bug.cgi?id=203119
+        rdar://problem/52970947
+
+        Reviewed by Wenson Hsieh.
+
+        iPad viewport heuristics (WebPage::immediatelyShrinkToFitContent()) run on a zero-delay
+        timer after page load, which races with this test getting the UI-side scrolling tree
+        and makes the test flakey.
+
+        Fix by turning off the heuristics with "contentMode=mobile". Also fix the test
+        to use UIHelper to get the scrolling tree.
+
+        * platform/ipad/TestExpectations:
+        * platform/ipad/scrollingcoordinator/ios/ui-scrolling-tree-expected.txt:
+        * scrollingcoordinator/ios/ui-scrolling-tree.html:
+
+2019-10-21  Simon Fraser  <simon.fraser@apple.com>
+
         [iOS WK2] Support hiding iframe scrollbars via ::-webkit-scrollbar style
         https://bugs.webkit.org/show_bug.cgi?id=203178
 
diff --git a/LayoutTests/platform/ipad/TestExpectations b/LayoutTests/platform/ipad/TestExpectations
index bf9f96b..0d5ae99 100644
--- a/LayoutTests/platform/ipad/TestExpectations
+++ b/LayoutTests/platform/ipad/TestExpectations
@@ -63,6 +63,3 @@
 
 # <rdar://problem/52914585> (Layout Test fast/forms/file/file-input-reset-using-open-panel.html is Failing)
 fast/forms/file/file-input-reset-using-open-panel.html [ ImageOnlyFailure ]
-
-# rdar://52970947 (Layout Test scrollingcoordinator/ios/ui-scrolling-tree.html is a Flaky Failure on iPad iOS 13)
-scrollingcoordinator/ios/ui-scrolling-tree.html [ Pass Failure ]
diff --git a/LayoutTests/platform/ipad/scrollingcoordinator/ios/ui-scrolling-tree-expected.txt b/LayoutTests/platform/ipad/scrollingcoordinator/ios/ui-scrolling-tree-expected.txt
index a7b53cf..2905a9a 100644
--- a/LayoutTests/platform/ipad/scrollingcoordinator/ios/ui-scrolling-tree-expected.txt
+++ b/LayoutTests/platform/ipad/scrollingcoordinator/ios/ui-scrolling-tree-expected.txt
@@ -1,7 +1,7 @@
 
 (scrolling tree
   (frame scrolling node
-    (scrollable area size width=1280 height=1673)
+    (scrollable area size width=768 height=1004)
     (total content size width=1308 height=2021)
     (last committed scroll position (0,0))
     (scrollable area parameters 
@@ -9,12 +9,12 @@
       (vertical scroll elasticity 1)
       (horizontal scrollbar mode 0)
       (vertical scrollbar mode 0))
-    (layout viewport (0,0) width=1280 height=1673)
+    (layout viewport (0,0) width=768 height=1004)
     (min layoutViewport origin (0,0))
-    (max layoutViewport origin (28,348))
+    (max layoutViewport origin (540,1017))
     (behavior for fixed 0)
     (fixed node
       (fixed constraints 
-        (viewport-rect-at-last-layout (0,0) width=1280 height=1673)
+        (viewport-rect-at-last-layout (0,0) width=768 height=1004)
         (layer-position-at-last-layout (12,10)))
       (layer top left (12,10)))))
diff --git a/LayoutTests/scrollingcoordinator/ios/ui-scrolling-tree.html b/LayoutTests/scrollingcoordinator/ios/ui-scrolling-tree.html
index 4ad0413..fcd332b 100644
--- a/LayoutTests/scrollingcoordinator/ios/ui-scrolling-tree.html
+++ b/LayoutTests/scrollingcoordinator/ios/ui-scrolling-tree.html
@@ -1,4 +1,4 @@
-<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true contentMode=mobile ] -->
 <html>
 <head>
     <meta name="viewport" content="initial-scale=1.0">
@@ -17,28 +17,19 @@
             background-color: blue;
         }
     </style>
+    <script src="../../resources/ui-helper.js"></script>
     <script>
         if (window.testRunner) {
             testRunner.waitUntilDone();
             testRunner.dumpAsText();
         }
 
-        function getScrollingTreeUIScript()
+        async function doTest()
         {
-            return `(function() {
-                return uiController.scrollingTreeAsText;
-            })();`;
-        }
-
-        function doTest()
-        {
-            if (!testRunner.runUIScript)
-                return
-
-            testRunner.runUIScript(getScrollingTreeUIScript(), function(scrollingTree) {
-                document.getElementById('layers').textContent = scrollingTree;
-                testRunner.notifyDone();
-            });
+            await UIHelper.ensureStablePresentationUpdate();
+            let scrollingTree = await UIHelper.getScrollingTree();
+            document.getElementById('layers').textContent = scrollingTree;
+            testRunner.notifyDone();
         }
         
         window.addEventListener('load', doTest, false);