toolkit/components/satchel/test/test_form_submission_cap.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <head>
     4   <title>Satchel Test for Form Submisstion Field Cap</title>
     5   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     6   <script type="text/javascript" src="satchel_common.js"></script>
     7   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     8 </head>
     9 <body>
    10 <p id="display"></p>
    11 <div id="content" style="display: none">
    13   <form id="form1" onsubmit="return checkSubmit(1)">
    14     <button type="submit">Submit</button>
    15   </form>
    17 </div>
    18 <pre id="test">
    19 <script class="testbody" type="text/javascript">
    21 /* Test for bug 492701.
    22    Save only the first MAX_FIELDS_SAVED changed fields in a form.
    23    Generate numInputFields = MAX_FIELDS_SAVED + 1 fields, change all values,
    24    and test that only MAX_FIELDS_SAVED are actually saved and that
    25    field # numInputFields was not saved.
    26 */
    28 var numSubmittedForms = 0;
    29 var numInputFields = 101;
    31 function checkInitialState() {
    32   countEntries(null, null,
    33     function (num) {
    34       ok(!num, "checking for initially empty storage");
    35       startTest();
    36     });
    37 }
    39 function startTest() {
    40   var form = document.getElementById("form1");
    41   for (i = 1; i <= numInputFields; i++) {
    42     var newField = document.createElement("input");
    43     newField.setAttribute("type", "text");
    44     newField.setAttribute("name", "test" + i);
    45     form.appendChild(newField);
    46   }
    48   // Fill in values for the various fields. We could just set the <input>'s
    49   // value attribute, but we don't save default form values (and we want to
    50   // ensure unsaved values are because of autocomplete=off or whatever).
    51   for (i = 1; i <= numInputFields; i++) {
    52     $_(1, "test" + i).value = i;
    53   }
    55   // submit the first form.
    56   var button = getFormSubmitButton(1);
    57   button.click();
    58 }
    61 // Called by each form's onsubmit handler.
    62 function checkSubmit(formNum) {
    63   ok(true, "form " + formNum + " submitted");
    64   numSubmittedForms++;
    66   // check that the first (numInputFields - 1) CHANGED fields are saved
    67   for (i = 1; i < numInputFields; i++) { // check all but last
    68     checkForSave("test" + i, i, "checking saved value " + i);
    69   }
    71   // End the test.
    72   is(numSubmittedForms, 1, "Ensuring all forms were submitted.");
    73   SimpleTest.finish();
    74   return false; // return false to cancel current form submission
    75 }
    78 window.onload = checkInitialState;
    80 SimpleTest.waitForExplicitFinish();
    82 </script>
    83 </pre>
    84 </body>
    85 </html>

mercurial