toolkit/components/satchel/test/test_form_submission.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <title>Satchel Test for Form Submisstion</title>
michael@0 5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 6 <script type="text/javascript" src="satchel_common.js"></script>
michael@0 7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 8 </head>
michael@0 9 <body>
michael@0 10 <p id="display"></p>
michael@0 11 <iframe id="iframe" src="https://example.com/tests/toolkit/components/satchel/test/subtst_form_submission_1.html"></iframe>
michael@0 12 <div id="content" style="display: none">
michael@0 13
michael@0 14 <!-- ===== Things that should not be saved. ===== -->
michael@0 15
michael@0 16 <!-- autocomplete=off for input -->
michael@0 17 <form id="form1" onsubmit="return checkSubmit(1)">
michael@0 18 <input type="text" name="test1" autocomplete="off">
michael@0 19 <button type="submit">Submit</button>
michael@0 20 </form>
michael@0 21
michael@0 22 <!-- autocomplete=off for form -->
michael@0 23 <form id="form2" onsubmit="return checkSubmit(2)" autocomplete="off">
michael@0 24 <input type="text" name="test1">
michael@0 25 <button type="submit">Submit</button>
michael@0 26 </form>
michael@0 27
michael@0 28 <!-- don't save type=hidden -->
michael@0 29 <form id="form3" onsubmit="return checkSubmit(3)">
michael@0 30 <input type="hidden" name="test1">
michael@0 31 <button type="submit">Submit</button>
michael@0 32 </form>
michael@0 33
michael@0 34 <!-- don't save type=checkbox -->
michael@0 35 <form id="form4" onsubmit="return checkSubmit(4)">
michael@0 36 <input type="checkbox" name="test1">
michael@0 37 <button type="submit">Submit</button>
michael@0 38 </form>
michael@0 39
michael@0 40 <!-- Don't save empty values. -->
michael@0 41 <form id="form5" onsubmit="return checkSubmit(5)">
michael@0 42 <input type="text" name="test1" value="originalValue">
michael@0 43 <button type="submit">Submit</button>
michael@0 44 </form>
michael@0 45
michael@0 46 <!-- Don't save unchanged values. -->
michael@0 47 <form id="form6" onsubmit="return checkSubmit(6)">
michael@0 48 <input type="text" name="test1" value="dontSaveThis">
michael@0 49 <button type="submit">Submit</button>
michael@0 50 </form>
michael@0 51
michael@0 52 <!-- Don't save unchanged values. (.value not touched) -->
michael@0 53 <form id="form7" onsubmit="return checkSubmit(7)">
michael@0 54 <input type="text" name="test1" value="dontSaveThis">
michael@0 55 <button type="submit">Submit</button>
michael@0 56 </form>
michael@0 57
michael@0 58 <!-- No field name or ID. -->
michael@0 59 <form id="form8" onsubmit="return checkSubmit(8)">
michael@0 60 <input type="text">
michael@0 61 <button type="submit">Submit</button>
michael@0 62 </form>
michael@0 63
michael@0 64 <!-- Nothing to save! -->
michael@0 65 <form id="form9" onsubmit="return checkSubmit(9)">
michael@0 66 <button type="submit">Submit</button>
michael@0 67 </form>
michael@0 68
michael@0 69 <!-- input with name too long (300 chars.) -->
michael@0 70 <form id="form10" onsubmit="return checkSubmit(10)">
michael@0 71 <input type="text" name="12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890">
michael@0 72 <button type="submit">Submit</button>
michael@0 73 </form>
michael@0 74
michael@0 75 <!-- input with value too long (300 chars.) -->
michael@0 76 <form id="form11" onsubmit="return checkSubmit(11)">
michael@0 77 <input type="text" name="test1">
michael@0 78 <button type="submit">Submit</button>
michael@0 79 </form>
michael@0 80
michael@0 81 <!-- input with value of one space (which should be trimmed) -->
michael@0 82 <form id="form12" onsubmit="return checkSubmit(12)">
michael@0 83 <input type="text" name="test1">
michael@0 84 <button type="submit">Submit</button>
michael@0 85 </form>
michael@0 86
michael@0 87 <!-- password field -->
michael@0 88 <form id="form13" onsubmit="return checkSubmit(13)">
michael@0 89 <input type="password" name="test1">
michael@0 90 <button type="submit">Submit</button>
michael@0 91 </form>
michael@0 92
michael@0 93 <!-- password field (type changed after pageload) -->
michael@0 94 <form id="form14" onsubmit="return checkSubmit(14)">
michael@0 95 <input type="text" name="test1">
michael@0 96 <button type="submit">Submit</button>
michael@0 97 </form>
michael@0 98
michael@0 99 <!-- input with sensitive data (16 digit credit card number) -->
michael@0 100 <form id="form15" onsubmit="return checkSubmit(15)">
michael@0 101 <script type="text/javascript">
michael@0 102 var form = document.getElementById('form15');
michael@0 103 for (var i = 0; i != 10; i++)
michael@0 104 {
michael@0 105 var input = document.createElement('input');
michael@0 106 input.type = 'text';
michael@0 107 input.name = 'test' + (i + 1);
michael@0 108 form.appendChild(input);
michael@0 109 }
michael@0 110 </script>
michael@0 111 <button type="submit">Submit</button>
michael@0 112 </form>
michael@0 113
michael@0 114 <!-- input with sensitive data (15 digit credit card number) -->
michael@0 115 <form id="form16" onsubmit="return checkSubmit(16)">
michael@0 116 <script type="text/javascript">
michael@0 117 var form = document.getElementById('form16');
michael@0 118 for (var i = 0; i != 10; i++)
michael@0 119 {
michael@0 120 var input = document.createElement('input');
michael@0 121 input.type = 'text';
michael@0 122 input.name = 'test' + (i + 1);
michael@0 123 form.appendChild(input);
michael@0 124 }
michael@0 125 </script>
michael@0 126 <button type="submit">Submit</button>
michael@0 127 </form>
michael@0 128
michael@0 129 <!-- input with sensitive data (9 digit credit card number) -->
michael@0 130 <form id="form17" onsubmit="return checkSubmit(17)">
michael@0 131 <input type="text" name="test1">
michael@0 132 <button type="submit">Submit</button>
michael@0 133 </form>
michael@0 134
michael@0 135 <!-- input with sensitive data (16 digit hyphenated credit card number) -->
michael@0 136 <form id="form18" onsubmit="return checkSubmit(18)">
michael@0 137 <input type="text" name="test1">
michael@0 138 <button type="submit">Submit</button>
michael@0 139 </form>
michael@0 140
michael@0 141 <!-- input with sensitive data (15 digit whitespace-separated credit card number) -->
michael@0 142 <form id="form19" onsubmit="return checkSubmit(19)">
michael@0 143 <input type="text" name="test1">
michael@0 144 <button type="submit">Submit</button>
michael@0 145 </form>
michael@0 146
michael@0 147 <!-- form data submitted through HTTPS, when browser.formfill.saveHttpsForms is false -->
michael@0 148 <form id="form20" action="https://www.example.com/" onsubmit="return checkSubmit(20)">
michael@0 149 <input type="text" name="test1">
michael@0 150 <button type="submit">Submit</button>
michael@0 151 </form>
michael@0 152
michael@0 153 <!-- Form 21 is submitted into an iframe, not declared here. -->
michael@0 154
michael@0 155 <!-- Don't save values if the form is invalid. -->
michael@0 156 <form id="form22" onsubmit="return checkSubmit(22);">
michael@0 157 <input type='email' name='test1' oninvalid="return checkSubmit(22);">
michael@0 158 <button type='submit'>Submit</button>
michael@0 159 </form>
michael@0 160
michael@0 161 <!-- Don't save values if the form is invalid. -->
michael@0 162 <form id="form23" onsubmit="return checkSubmit(23);">
michael@0 163 <input type='email' value='foo' oninvalid="return checkSubmit(23);">
michael@0 164 <input type='text' name='test1'>
michael@0 165 <button type='submit'>Submit</button>
michael@0 166 </form>
michael@0 167
michael@0 168 <!-- Don't save values if the input name is 'searchbar-history' -->
michael@0 169 <form id="form24" onsubmit="return checkSubmit(24);">
michael@0 170 <input type='text' name='searchbar-history'>
michael@0 171 <button type='submit'>Submit</button>
michael@0 172 </form>
michael@0 173
michael@0 174 <!-- ===== Things that should be saved ===== -->
michael@0 175
michael@0 176 <!-- Form 100 is submitted into an iframe, not declared here. -->
michael@0 177
michael@0 178 <!-- input with no default value -->
michael@0 179 <form id="form101" onsubmit="return checkSubmit(101)">
michael@0 180 <input type="text" name="test1">
michael@0 181 <button type="submit">Submit</button>
michael@0 182 </form>
michael@0 183
michael@0 184 <!-- input with a default value -->
michael@0 185 <form id="form102" onsubmit="return checkSubmit(102)">
michael@0 186 <input type="text" name="test2" value="originalValue">
michael@0 187 <button type="submit">Submit</button>
michael@0 188 </form>
michael@0 189
michael@0 190 <!-- input uses id but not name -->
michael@0 191 <form id="form103" onsubmit="return checkSubmit(103)">
michael@0 192 <input type="text" id="test3">
michael@0 193 <button type="submit">Submit</button>
michael@0 194 </form>
michael@0 195
michael@0 196 <!-- input with leading and trailing space -->
michael@0 197 <form id="form104" onsubmit="return checkSubmit(104)">
michael@0 198 <input type="text" name="test4">
michael@0 199 <button type="submit">Submit</button>
michael@0 200 </form>
michael@0 201
michael@0 202 <!-- input with leading and trailing whitespace -->
michael@0 203 <form id="form105" onsubmit="return checkSubmit(105)">
michael@0 204 <input type="text" name="test5">
michael@0 205 <button type="submit">Submit</button>
michael@0 206 </form>
michael@0 207
michael@0 208 <!-- input that looks like sensitive data but doesn't
michael@0 209 satisfy the requirements (incorrect length) -->
michael@0 210 <form id="form106" onsubmit="return checkSubmit(106)">
michael@0 211 <input type="text" name="test6">
michael@0 212 <button type="submit">Submit</button>
michael@0 213 </form>
michael@0 214
michael@0 215 <!-- input that looks like sensitive data but doesn't
michael@0 216 satisfy the requirements (Luhn check fails for 16 chars) -->
michael@0 217 <form id="form107" onsubmit="return checkSubmit(107)">
michael@0 218 <script type="text/javascript">
michael@0 219 var form = document.getElementById('form107');
michael@0 220 for (var i = 0; i != 10; i++)
michael@0 221 {
michael@0 222 var input = document.createElement('input');
michael@0 223 input.type = 'text';
michael@0 224 input.name = 'test7_' + (i + 1);
michael@0 225 form.appendChild(input);
michael@0 226 }
michael@0 227 </script>
michael@0 228 <button type="submit">Submit</button>
michael@0 229 </form>
michael@0 230
michael@0 231 <!-- input that looks like sensitive data but doesn't
michael@0 232 satisfy the requirements (Luhn check fails for 15 chars) -->
michael@0 233 <form id="form108" onsubmit="return checkSubmit(108)">
michael@0 234 <script type="text/javascript">
michael@0 235 var form = document.getElementById('form108');
michael@0 236 for (var i = 0; i != 10; i++)
michael@0 237 {
michael@0 238 var input = document.createElement('input');
michael@0 239 input.type = 'text';
michael@0 240 input.name = 'test8_' + (i + 1);
michael@0 241 form.appendChild(input);
michael@0 242 }
michael@0 243 </script>
michael@0 244 <button type="submit">Submit</button>
michael@0 245 </form>
michael@0 246
michael@0 247 <!-- form data submitted through HTTPS, when browser.formfill.saveHttpsForms is true -->
michael@0 248 <form id="form109" action="https://www.example.com/" onsubmit="return checkSubmit(109)">
michael@0 249 <input type="text" name="test9">
michael@0 250 <button type="submit">Submit</button>
michael@0 251 </form>
michael@0 252
michael@0 253 <!-- regular form data, when browser.formfill.saveHttpsForms is false -->
michael@0 254 <form id="form110" onsubmit="return checkSubmit(110)">
michael@0 255 <input type="text" name="test10">
michael@0 256 <button type="submit">Submit</button>
michael@0 257 </form>
michael@0 258
michael@0 259 </div>
michael@0 260 <pre id="test">
michael@0 261 <script class="testbody" type="text/javascript">
michael@0 262
michael@0 263 var numSubmittedForms = 0;
michael@0 264
michael@0 265 var ccNumbers = {
michael@0 266 valid15: [
michael@0 267 "930771457288760", "474915027480942",
michael@0 268 "924894781317325", "714816113937185",
michael@0 269 "790466087343106", "474320195408363",
michael@0 270 "219211148122351", "633038472250799",
michael@0 271 "354236732906484", "095347810189325",
michael@0 272 ],
michael@0 273 valid16: [
michael@0 274 "3091269135815020", "5471839082338112",
michael@0 275 "0580828863575793", "5015290610002932",
michael@0 276 "9465714503078607", "4302068493801686",
michael@0 277 "2721398408985465", "6160334316984331",
michael@0 278 "8643619970075142", "0218246069710785"
michael@0 279 ],
michael@0 280 invalid15: [
michael@0 281 "526931005800649", "724952425140686",
michael@0 282 "379761391174135", "030551436468583",
michael@0 283 "947377014076746", "254848023655752",
michael@0 284 "226871580283345", "708025346034339",
michael@0 285 "917585839076788", "918632588027666"
michael@0 286 ],
michael@0 287 invalid16: [
michael@0 288 "9946177098017064", "4081194386488872",
michael@0 289 "3095975979578034", "3662215692222536",
michael@0 290 "6723210018630429", "4411962856225025",
michael@0 291 "8276996369036686", "4449796938248871",
michael@0 292 "3350852696538147", "5011802870046957"
michael@0 293 ],
michael@0 294 };
michael@0 295
michael@0 296 function checkInitialState() {
michael@0 297 countEntries(null, null,
michael@0 298 function (num) {
michael@0 299 ok(!num, "checking for initially empty storage");
michael@0 300 startTest();
michael@0 301 });
michael@0 302 }
michael@0 303
michael@0 304 function startTest() {
michael@0 305 // Fill in values for the various fields. We could just set the <input>'s
michael@0 306 // value attribute, but we don't save default form values (and we want to
michael@0 307 // ensure unsaved values are because of autocomplete=off or whatever).
michael@0 308 $_(1, "test1").value = "dontSaveThis";
michael@0 309 $_(2, "test1").value = "dontSaveThis";
michael@0 310 $_(3, "test1").value = "dontSaveThis";
michael@0 311 $_(4, "test1").value = "dontSaveThis";
michael@0 312 $_(5, "test1").value = "";
michael@0 313 $_(6, "test1").value = "dontSaveThis";
michael@0 314 // Form 7 deliberately left untouched.
michael@0 315 // Form 8 has an input with no name or input attribute.
michael@0 316 var input = document.getElementById("form8").elements[0];
michael@0 317 is(input.type, "text", "checking we got unidentified input");
michael@0 318 input.value = "dontSaveThis";
michael@0 319 // Form 9 has nothing to modify.
michael@0 320 $_(10, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890").value = "dontSaveThis";
michael@0 321 $_(11, "test1").value = "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
michael@0 322 $_(12, "test1").value = " ";
michael@0 323 $_(13, "test1").value = "dontSaveThis";
michael@0 324 $_(14, "test1").type = "password";
michael@0 325 $_(14, "test1").value = "dontSaveThis";
michael@0 326
michael@0 327 var testData = ccNumbers.valid16;
michael@0 328 for (var i = 0; i != testData.length; i++) {
michael@0 329 $_(15, "test" + (i + 1)).value = testData[i];
michael@0 330 }
michael@0 331
michael@0 332 testData = ccNumbers.valid15;
michael@0 333 for (var i = 0; i != testData.length; i++) {
michael@0 334 $_(16, "test" + (i + 1)).value = testData[i];
michael@0 335 }
michael@0 336 $_(17, "test1").value = "001064088";
michael@0 337 $_(18, "test1").value = "0000-0000-0080-4609";
michael@0 338 $_(19, "test1").value = "0000 0000 0222 331";
michael@0 339 $_(20, "test1").value = "dontSaveThis";
michael@0 340 $_(22, "test1").value = "dontSaveThis";
michael@0 341 $_(23, "test1").value = "dontSaveThis";
michael@0 342 $_(24, "searchbar-history").value = "dontSaveThis";
michael@0 343
michael@0 344 $_(101, "test1").value = "savedValue";
michael@0 345 $_(102, "test2").value = "savedValue";
michael@0 346 $_(103, "test3").value = "savedValue";
michael@0 347 $_(104, "test4").value = " trimTrailingAndLeadingSpace ";
michael@0 348 $_(105, "test5").value = "\t trimTrailingAndLeadingWhitespace\t ";
michael@0 349 $_(106, "test6").value = "00000000109181";
michael@0 350
michael@0 351 var testData = ccNumbers.invalid16;
michael@0 352 for (var i = 0; i != testData.length; i++) {
michael@0 353 $_(107, "test7_" + (i + 1)).value = testData[i];
michael@0 354 }
michael@0 355
michael@0 356 var testData = ccNumbers.invalid15;
michael@0 357 for (var i = 0; i != testData.length; i++) {
michael@0 358 $_(108, "test8_" + (i + 1)).value = testData[i];
michael@0 359 }
michael@0 360
michael@0 361 $_(109, "test9").value = "savedValue";
michael@0 362 $_(110, "test10").value = "savedValue";
michael@0 363
michael@0 364 // submit the first form.
michael@0 365 var button = getFormSubmitButton(1);
michael@0 366 button.click();
michael@0 367 }
michael@0 368
michael@0 369
michael@0 370 // Called by each form's onsubmit handler.
michael@0 371 function checkSubmit(formNum) {
michael@0 372 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
michael@0 373
michael@0 374 ok(true, "form " + formNum + " submitted");
michael@0 375 numSubmittedForms++;
michael@0 376
michael@0 377 // Check for expected storage state.
michael@0 378 switch (formNum) {
michael@0 379 // Test 1-24 should not save anything.
michael@0 380 case 1:
michael@0 381 case 2:
michael@0 382 case 3:
michael@0 383 case 4:
michael@0 384 case 5:
michael@0 385 case 6:
michael@0 386 case 7:
michael@0 387 case 8:
michael@0 388 case 9:
michael@0 389 case 10:
michael@0 390 case 11:
michael@0 391 case 12:
michael@0 392 case 13:
michael@0 393 case 14:
michael@0 394 case 15:
michael@0 395 case 16:
michael@0 396 case 17:
michael@0 397 case 18:
michael@0 398 case 19:
michael@0 399 case 20:
michael@0 400 case 21:
michael@0 401 case 22:
michael@0 402 case 23:
michael@0 403 case 24:
michael@0 404 countEntries(null, null,
michael@0 405 function (num) {
michael@0 406 ok(!num, "checking for empty storage");
michael@0 407 submitForm(formNum);
michael@0 408 });
michael@0 409 return false;
michael@0 410 break;
michael@0 411 case 100:
michael@0 412 checkForSave("subtest2", "subtestValue", "checking saved subtest value");
michael@0 413 break;
michael@0 414 case 101:
michael@0 415 checkForSave("test1", "savedValue", "checking saved value");
michael@0 416 break;
michael@0 417 case 102:
michael@0 418 checkForSave("test2", "savedValue", "checking saved value");
michael@0 419 break;
michael@0 420 case 103:
michael@0 421 checkForSave("test3", "savedValue", "checking saved value");
michael@0 422 break;
michael@0 423 case 104:
michael@0 424 checkForSave("test4", "trimTrailingAndLeadingSpace", "checking saved value is trimmed on both sides");
michael@0 425 break;
michael@0 426 case 105:
michael@0 427 checkForSave("test5", "trimTrailingAndLeadingWhitespace", "checking saved value is trimmed on both sides");
michael@0 428 break;
michael@0 429 case 106:
michael@0 430 checkForSave("test6", "00000000109181", "checking saved value");
michael@0 431 break;
michael@0 432 case 107:
michael@0 433 for (var i = 0; i != ccNumbers.invalid16.length; i++) {
michael@0 434 checkForSave("test7_" + (i + 1), ccNumbers.invalid16[i], "checking saved value");
michael@0 435 }
michael@0 436 break;
michael@0 437 case 108:
michael@0 438 for (var i = 0; i != ccNumbers.invalid15.length; i++) {
michael@0 439 checkForSave("test8_" + (i + 1), ccNumbers.invalid15[i], "checking saved value");
michael@0 440 }
michael@0 441 break;
michael@0 442 case 109:
michael@0 443 checkForSave("test9", "savedValue", "checking saved value");
michael@0 444 break;
michael@0 445 case 110:
michael@0 446 checkForSave("test10", "savedValue", "checking saved value");
michael@0 447 break;
michael@0 448 default:
michael@0 449 ok(false, "Unexpected form submission");
michael@0 450 break;
michael@0 451 }
michael@0 452
michael@0 453 return submitForm(formNum);
michael@0 454 }
michael@0 455
michael@0 456 function submitForm(formNum)
michael@0 457 {
michael@0 458 // Forms 13 and 14 would trigger a save-password notification. Temporarily
michael@0 459 // disable pwmgr, then reenable it.
michael@0 460 if (formNum == 12)
michael@0 461 SpecialPowers.setBoolPref("signon.rememberSignons", false);
michael@0 462 if (formNum == 14)
michael@0 463 SpecialPowers.clearUserPref("signon.rememberSignons");
michael@0 464
michael@0 465 // Forms 20 and 21 requires browser.formfill.saveHttpsForms to be false
michael@0 466 if (formNum == 19)
michael@0 467 SpecialPowers.setBoolPref("browser.formfill.saveHttpsForms", false);
michael@0 468 // Reset preference now that 20 and 21 are over
michael@0 469 if (formNum == 21)
michael@0 470 SpecialPowers.clearUserPref("browser.formfill.saveHttpsForms");
michael@0 471
michael@0 472 // End the test now on SeaMonkey.
michael@0 473 if (formNum == 21 && navigator.userAgent.match(/ SeaMonkey\//)) {
michael@0 474 Services.obs.removeObserver(checkObserver, "satchel-storage-changed");
michael@0 475 is(numSubmittedForms, 21, "Ensuring all forms were submitted.");
michael@0 476
michael@0 477 todo(false, "Skipping remaining checks on SeaMonkey ftb. (Bug 589471)");
michael@0 478 // finish(), yet let the test actually end first, to be safe.
michael@0 479 SimpleTest.executeSoon(SimpleTest.finish);
michael@0 480
michael@0 481 return false; // return false to cancel current form submission
michael@0 482 }
michael@0 483
michael@0 484 // Form 109 requires browser.formfill.save_https_forms to be true;
michael@0 485 // Form 110 requires it to be false.
michael@0 486 if (formNum == 108)
michael@0 487 SpecialPowers.setBoolPref("browser.formfill.saveHttpsForms", true);
michael@0 488 if (formNum == 109)
michael@0 489 SpecialPowers.setBoolPref("browser.formfill.saveHttpsForms", false);
michael@0 490 if (formNum == 110)
michael@0 491 SpecialPowers.clearUserPref("browser.formfill.saveHttpsForms");
michael@0 492
michael@0 493 // End the test at the last form.
michael@0 494 if (formNum == 110) {
michael@0 495 is(numSubmittedForms, 35, "Ensuring all forms were submitted.");
michael@0 496 Services.obs.removeObserver(checkObserver, "satchel-storage-changed");
michael@0 497 SimpleTest.finish();
michael@0 498 return false; // return false to cancel current form submission
michael@0 499 }
michael@0 500
michael@0 501 // This timeout is here so that button.click() is never called before this
michael@0 502 // function returns. If button.click() is called before returning, a long
michael@0 503 // chain of submits will happen recursively since the submit is dispatched
michael@0 504 // immediately.
michael@0 505 //
michael@0 506 // This in itself is fine, but if there are errors in the code, mochitests
michael@0 507 // will in some cases give you "server too busy", which is hard to debug!
michael@0 508 //
michael@0 509 setTimeout(function() {
michael@0 510 checkObserver.waitForChecks(function() {
michael@0 511 var nextFormNum = formNum == 24 ? 100 : (formNum + 1);
michael@0 512
michael@0 513 // Submit the next form. Special cases are Forms 21 and 100, which happen
michael@0 514 // from an HTTPS domain in an iframe.
michael@0 515 if (nextFormNum == 21 || nextFormNum == 100) {
michael@0 516 ok(true, "submitting iframe test " + nextFormNum);
michael@0 517 document.getElementById("iframe").contentWindow.clickButton(nextFormNum);
michael@0 518 }
michael@0 519 else {
michael@0 520 var button = getFormSubmitButton(nextFormNum);
michael@0 521 button.click();
michael@0 522 }
michael@0 523 });
michael@0 524 }, 0);
michael@0 525
michael@0 526 return false; // cancel current form submission
michael@0 527 }
michael@0 528
michael@0 529 Services.obs.addObserver(checkObserver, "satchel-storage-changed", false);
michael@0 530
michael@0 531 window.onload = checkInitialState;
michael@0 532
michael@0 533 SimpleTest.waitForExplicitFinish();
michael@0 534
michael@0 535 </script>
michael@0 536 </pre>
michael@0 537 </body>
michael@0 538 </html>

mercurial