Skip to content

Commit

Permalink
fast/editing/document-leak-altered-text-field.html is flaky
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cdumez committed Jun 20, 2023
1 parent 0449dbc commit 4860f7c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 27 deletions.
Expand Up @@ -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

Expand Down
64 changes: 38 additions & 26 deletions LayoutTests/fast/editing/document-leak-altered-text-field.html
Expand Up @@ -6,40 +6,52 @@
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);
testPassed("The Document didn't leak");
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);
};
}
};
</script>
</body>
Expand Down

0 comments on commit 4860f7c

Please sign in to comment.