diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /toolkit/components/satchel/test/test_capture_limit.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/satchel/test/test_capture_limit.html')
-rw-r--r-- | toolkit/components/satchel/test/test_capture_limit.html | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/toolkit/components/satchel/test/test_capture_limit.html b/toolkit/components/satchel/test/test_capture_limit.html new file mode 100644 index 0000000000..8591544016 --- /dev/null +++ b/toolkit/components/satchel/test/test_capture_limit.html @@ -0,0 +1,61 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Form History capture no more than 100 changes</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <script type="text/javascript" src="satchel_common.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<p id="display"></p> +<div id="content" style="display: none"> + <form id="form1"> + <button type="submit">Submit</button> + </form> +</div> +<script> + +add_setup(async () => { + const count = await countEntries(null, null); + ok(!count, "initial storage is empty"); +}); + +add_task(async function captureLimit() { + // Capture no more than 100 fields per submit. See FormHistoryChild.jsm. + const inputsCount = 100 + 2; + const form = document.getElementById("form1"); + for (let i = 1; i <= inputsCount; i++) { + const newField = document.createElement("input"); + newField.setAttribute("type", "text"); + newField.setAttribute("name", "test" + i); + form.appendChild(newField); + if( i != 50) { + SpecialPowers.wrap(newField).setUserInput(i); + } + } + + form.addEventListener("submit", e => e.preventDefault(), { once: true }); + const storageUpdated = promiseNextStorageEvent(); + getFormSubmitButton(1).click(); + await storageUpdated; + + for (let i = 1; i <= inputsCount; i++) { // check all but last + const historyEntries = await countEntries("test" + i, i); + + switch(i) { + case 50: + is(historyEntries, 0, `no history saved for input ${i} because user didn't modify it`); + break; + case 102: + is(historyEntries, 0, `no history saved for input ${i} because form already captured 100 fields`); + break; + default: + is(historyEntries, 1, `history saved for input ${i}`); + break; + } + } +}); + +</script> +</body> +</html> |