From 4860f7c8dba8d33fd268bbf56241a2bd6e10fa43 Mon Sep 17 00:00:00 2001 From: Chris Dumez Date: Tue, 20 Jun 2023 16:12:07 -0700 Subject: [PATCH] fast/editing/document-leak-altered-text-field.html is flaky https://bugs.webkit.org/show_bug.cgi?id=258289 Reviewed by Ryosuke Niwa. Our GC is conservative so instead of constructing one document and naming sure it gets GC'd, we now construct 30 and make sure at least one of them gets GC'd. * LayoutTests/fast/editing/document-leak-altered-text-field-expected.txt: * LayoutTests/fast/editing/document-leak-altered-text-field.html: Canonical link: https://commits.webkit.org/265339@main --- ...ument-leak-altered-text-field-expected.txt | 1 - .../document-leak-altered-text-field.html | 64 +++++++++++-------- 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/LayoutTests/fast/editing/document-leak-altered-text-field-expected.txt b/LayoutTests/fast/editing/document-leak-altered-text-field-expected.txt index 5220fa2cc01f..e4254a15adca 100644 --- a/LayoutTests/fast/editing/document-leak-altered-text-field-expected.txt +++ b/LayoutTests/fast/editing/document-leak-altered-text-field-expected.txt @@ -3,7 +3,6 @@ Make sure that the document doesn't leak if it contains a modified text input fi On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". -PASS w.document.getElementById('textField').value is "test" PASS The Document didn't leak PASS successfullyParsed is true diff --git a/LayoutTests/fast/editing/document-leak-altered-text-field.html b/LayoutTests/fast/editing/document-leak-altered-text-field.html index 66a34274b683..4c2ceb67dfa7 100644 --- a/LayoutTests/fast/editing/document-leak-altered-text-field.html +++ b/LayoutTests/fast/editing/document-leak-altered-text-field.html @@ -6,25 +6,15 @@ description("Make sure that the document doesn't leak if it contains a modified text input field."); jsTestIsAsync = true; -onload = () => { - w = open("resources/document-leak-altered-text-field-popup.html"); - w.onload = () => { - // The navigation needs to happen outside the load event in order to create a history item and put the - // page in the back/forward cache. - setTimeout(async () => { - documentIdentifier = internals.documentIdentifier(w.document); - // Type in the input field. - w.document.getElementById("textField").focus(); - w.document.execCommand("InsertText", false, "test"); - shouldBeEqualToString("w.document.getElementById('textField').value", "test"); - - // Submit the form, which will navigate the page. - w.document.getElementById("submitButton").click(); +let documentIdentifiers = []; +const popupCount = 30; - w = null; - handle = setInterval(() => { - internals.clearBackForwardCache(); - gc(); +function checkForLeaks() +{ + handle = setInterval(() => { + internals.clearBackForwardCache(); + gc(); + for (let documentIdentifier of documentIdentifiers) { if (!internals.isDocumentAlive(documentIdentifier)) { clearInterval(handle); clearTimeout(timeoutHandle); @@ -32,14 +22,36 @@ finishJSTest(); return; } - }, 50); - timeoutHandle = setTimeout(() => { - testFailed("The document leaked"); - clearInterval(handle); - finishJSTest(); - }, 10000); - }, 0); - }; + } + }, 50); + timeoutHandle = setTimeout(() => { + testFailed("The document leaked"); + clearInterval(handle); + finishJSTest(); + }, 10000); +} + +onload = () => { + for (let i = 0; i < popupCount; i++) { + let w = open("resources/document-leak-altered-text-field-popup.html"); + w.onload = () => { + // The navigation needs to happen outside the load event in order to create a history item and put the + // page in the back/forward cache. + setTimeout(async () => { + documentIdentifiers.push(internals.documentIdentifier(w.document)); + + // Type in the input field. + w.document.getElementById("textField").focus(); + w.document.execCommand("InsertText", false, "test"); + + // Submit the form, which will navigate the page. + w.document.getElementById("submitButton").click(); + + if (documentIdentifiers.length == popupCount) + checkForLeaks(); + }, 0); + }; + } };