tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug590353-2.html (1982B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=590353
      5 -->
      6 <head>
      7  <title>Test for Bug 590353</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     10 </head>
     11 <body>
     12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=590353">Mozilla Bug 590353</a>
     13 <p id="display"></p>
     14 <div id="content" style="display: none">
     15 </div>
     16 <pre id="test">
     17 <script type="application/javascript">
     18 
     19 /** Test for Bug 590353 */
     20 
     21 var testData = [
     22  [ "text", "foo", "" ],
     23  [ "email", "foo@bar.com", "" ],
     24  [ "url", "http:///foo.com", "" ],
     25  [ "tel", "555 555 555 555", "" ],
     26  [ "search", "foo", "" ],
     27  [ "password", "secret", "" ],
     28  [ "hidden", "foo", "foo" ],
     29  [ "button", "foo", "foo" ],
     30  [ "reset", "foo", "foo" ],
     31  [ "submit", "foo", "foo" ],
     32  [ "checkbox", true, false ],
     33  [ "radio", true, false ],
     34  [ "file", "590353_file", "" ],
     35 ];
     36 
     37 function createFileWithData(fileName, fileData) {
     38  return new File([new Blob([fileData], { type: "text/plain" })], fileName);
     39 }
     40 
     41 var content = document.getElementById('content');
     42 var form = document.createElement('form');
     43 content.appendChild(form);
     44 
     45 for (var data of testData) {
     46  var e = document.createElement('input');
     47  e.type = data[0];
     48 
     49  if (data[0] == 'checkbox' || data[0] == 'radio') {
     50    e.checked = data[1];
     51  } else if (data[0] == 'file') {
     52    var file = createFileWithData(data[1], "file content");
     53    SpecialPowers.wrap(e).mozSetFileArray([file]);
     54  } else {
     55    e.value = data[1];
     56  }
     57 
     58  form.appendChild(e);
     59 }
     60 
     61 form.reset();
     62 
     63 var size = form.elements.length;
     64 for (var i=0; i<size; ++i) {
     65  var e = form.elements[i];
     66 
     67  if (e.type == 'radio' || e.type == 'checkbox') {
     68    is(e.checked, testData[i][2],
     69       "the element checked value should be " + testData[i][2]);
     70  } else {
     71    is(e.value, testData[i][2],
     72       "the element value should be " + testData[i][2]);
     73  }
     74 }
     75 
     76 </script>
     77 </pre>
     78 </body>
     79 </html>