2009-05-20 20:22:38 -07:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Satchel Test for Form Submisstion Field Cap</title>
|
|
|
|
<script type="text/javascript" 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" onsubmit="return checkSubmit(1)">
|
|
|
|
<button type="submit">Submit</button>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
|
|
|
|
/* Test for bug 492701.
|
|
|
|
Save only the first MAX_FIELDS_SAVED changed fields in a form.
|
|
|
|
Generate numInputFields = MAX_FIELDS_SAVED + 1 fields, change all values,
|
|
|
|
and test that only MAX_FIELDS_SAVED are actually saved and that
|
|
|
|
field # numInputFields was not saved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
var numSubmittedForms = 0;
|
|
|
|
var numInputFields = 101;
|
|
|
|
|
|
|
|
function startTest() {
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
|
|
|
ok(!fh.hasEntries, "checking for initially empty storage");
|
|
|
|
|
|
|
|
var form = document.getElementById("form1");
|
|
|
|
for (i = 1; i <= numInputFields; i++) {
|
|
|
|
var newField = document.createElement("input");
|
|
|
|
newField.setAttribute("type", "text");
|
|
|
|
newField.setAttribute("name", "test" + i);
|
|
|
|
form.appendChild(newField);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fill in values for the various fields. We could just set the <input>'s
|
|
|
|
// value attribute, but we don't save default form values (and we want to
|
|
|
|
// ensure unsaved values are because of autocomplete=off or whatever).
|
|
|
|
for (i = 1; i <= numInputFields; i++) {
|
|
|
|
$_(1, "test" + i).value = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
// submit the first form.
|
|
|
|
var button = getFormSubmitButton(1);
|
|
|
|
button.click();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Called by each form's onsubmit handler.
|
|
|
|
function checkSubmit(formNum) {
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
|
|
|
|
|
|
|
ok(true, "form " + formNum + " submitted");
|
|
|
|
numSubmittedForms++;
|
|
|
|
|
|
|
|
// check that the first (numInputFields - 1) CHANGED fields are saved
|
|
|
|
for (i = 1; i < numInputFields; i++) { // check all but last
|
2010-08-16 21:10:36 -07:00
|
|
|
checkForSave("test" + i, i, "checking saved value " + i);
|
2009-05-20 20:22:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// End the test at the last form.
|
|
|
|
if (formNum == 1) {
|
|
|
|
is(numSubmittedForms, 1, "Ensuring all forms were submitted.");
|
2010-08-16 21:10:36 -07:00
|
|
|
Services.obs.removeObserver(checkObserver, "satchel-storage-changed");
|
2009-05-20 20:22:38 -07:00
|
|
|
SimpleTest.finish();
|
|
|
|
return false; // return false to cancel current form submission
|
|
|
|
}
|
|
|
|
|
2010-08-16 21:10:36 -07:00
|
|
|
checkObserver.waitForChecks(function() {
|
|
|
|
// submit the next form.
|
|
|
|
var button = getFormSubmitButton(formNum + 1);
|
|
|
|
button.click();
|
|
|
|
});
|
2009-05-20 20:22:38 -07:00
|
|
|
|
|
|
|
return false; // cancel current form submission
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
|
|
|
|
|
|
|
var fh = Components.classes["@mozilla.org/satchel/form-history;1"].
|
|
|
|
getService(Components.interfaces.nsIFormHistory2);
|
|
|
|
ok(fh != null, "Got formHistory service");
|
|
|
|
|
|
|
|
window.onload = startTest;
|
|
|
|
|
2010-08-16 21:10:36 -07:00
|
|
|
Services.obs.addObserver(checkObserver, "satchel-storage-changed", false);
|
|
|
|
|
2009-05-20 20:22:38 -07:00
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|