-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
document-leak-altered-text-field.html
58 lines (52 loc) · 1.87 KB
/
document-leak-altered-text-field.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!DOCTYPE html> <!-- webkit-test-runner [ UsesBackForwardCache=true ] -->
<html>
<body>
<script src="../../resources/js-test.js"></script>
<script>
description("Make sure that the document doesn't leak if it contains a modified text input field.");
jsTestIsAsync = true;
let documentIdentifiers = [];
const popupCount = 30;
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);
}
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>
</html>