Title: [295580] trunk/LayoutTests
Revision
295580
Author
[email protected]
Date
2022-06-15 16:55:06 -0700 (Wed, 15 Jun 2022)

Log Message

Web Inspector: inspector/page/setShowPaintRects.html is a flakey failure since introduction
https://bugs.webkit.org/show_bug.cgi?id=233047
rdar://85345706

Reviewed by Antoine Quint.

Adding test results to the page causes a paint to be scheduled, which can cause paint rects to be requested at times we
are not expecting them as part of the flow of the test. We expect only our explicit change to an element to cause paints
to occur, but currently those paints end up interleaved with paints for adding results to the test page.

To resolve this, we now defer writing results to the test page until the end of each test case. This allows us to wait
to start each test case until there are no paint rects, and to avoid accidently causing a paint rect to appear at
inopportune times for our testing.

* LayoutTests/inspector/page/setShowPaintRects-expected.txt:
* LayoutTests/inspector/page/setShowPaintRects.html:
* LayoutTests/platform/mac/TestExpectations:

Canonical link: https://commits.webkit.org/251585@main

Modified Paths

Diff

Modified: trunk/LayoutTests/inspector/page/setShowPaintRects-expected.txt (295579 => 295580)


--- trunk/LayoutTests/inspector/page/setShowPaintRects-expected.txt	2022-06-15 23:32:32 UTC (rev 295579)
+++ trunk/LayoutTests/inspector/page/setShowPaintRects-expected.txt	2022-06-15 23:55:06 UTC (rev 295580)
@@ -2,12 +2,16 @@
 
 
 == Running test suite: Page.setShowPaintRects
+-- Running test setup.
 -- Running test case: Page.setShowPaintRects.Enabled
 PASS: Should not have paint rects displayed.
 PASS: Should have paint rects displayed.
 PASS: Should not have paint rects displayed.
+-- Running test teardown.
 
+-- Running test setup.
 -- Running test case: Page.setShowPaintRects.Disabled
 PASS: Should not have paint rects displayed.
 PASS: Should not have had any paint rects displayed.
+-- Running test teardown.
 

Modified: trunk/LayoutTests/inspector/page/setShowPaintRects.html (295579 => 295580)


--- trunk/LayoutTests/inspector/page/setShowPaintRects.html	2022-06-15 23:32:32 UTC (rev 295579)
+++ trunk/LayoutTests/inspector/page/setShowPaintRects.html	2022-06-15 23:55:06 UTC (rev 295580)
@@ -17,6 +17,21 @@
 
 function test()
 {
+    // Because adding test results to the page also causes painting (of the new result elements) we need to defer adding
+    // results to the page until we are between test cases.
+    let deferredTestResults = [];
+
+    const inspectorTestOriginalAddResult = InspectorTest.addResult.bind(InspectorTest);
+    InspectorTest.addResult = function(result) {
+        deferredTestResults.push(result);
+    }
+
+    function writeDeferredTestOutputToPage() {
+        for (let result of deferredTestResults)
+            inspectorTestOriginalAddResult(result);
+        deferredTestResults = [];
+    }
+
     async function expectHasPaintRectsDidChangeTo(expected) {
         await InspectorTest.awaitEvent("TestHasPaintRectsDidChange");
         await expectHasPaintRects(expected);
@@ -27,11 +42,27 @@
         InspectorTest.expectEqual(hasPaintRects, expected, `Should ${expected ? "" : "not "}have paint rects displayed.`);
     }
 
+    async function setup() {
+        await PageAgent.setShowPaintRects(false);
+
+        // Existing paint rects still need to fade out, so it isn't safe to assume we will immediately have zero paint
+        // rects visible.
+        if (!(await InspectorTest.evaluateInPage(`window._test_hasPaintRects`)))
+            return;
+        await InspectorTest.awaitEvent("TestHasPaintRectsDidChange");
+    }
+
+    async function teardown() {
+        writeDeferredTestOutputToPage();
+    }
+
     let suite = InspectorTest.createAsyncSuite("Page.setShowPaintRects");
 
     suite.addTestCase({
         name: "Page.setShowPaintRects.Enabled",
         description: "Test that paint rects are correctly created and removed while enabled.",
+        setup,
+        teardown,
         async test() {
             await PageAgent.setShowPaintRects(true);
             await expectHasPaintRects(false);
@@ -47,6 +78,8 @@
     suite.addTestCase({
         name: "Page.setShowPaintRects.Disabled",
         description: "Test that paint rects are not created while disabled.",
+        setup,
+        teardown,
         async test() {
             await PageAgent.setShowPaintRects(false);
             await expectHasPaintRects(false);

Modified: trunk/LayoutTests/platform/mac/TestExpectations (295579 => 295580)


--- trunk/LayoutTests/platform/mac/TestExpectations	2022-06-15 23:32:32 UTC (rev 295579)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2022-06-15 23:55:06 UTC (rev 295580)
@@ -2245,8 +2245,6 @@
 
 webkit.org/b/237172 imported/w3c/web-platform-tests/speech-api/SpeechSynthesis-speak-twice.html [ Pass Failure Crash ]
 
-webkit.org/b/233047 inspector/page/setShowPaintRects.html [ Pass Failure ]
-
 webkit.org/b/237680 imported/w3c/web-platform-tests/service-workers/service-worker/partitioned-service-worker-matchAll.tentative.https.html [ Pass Failure ]
 
 # Plugins
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to