Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Firefox/dom/html/test/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 4 kB image not shown  

Quelle  test_bug590363.html   Sprache: HTML

 
 products/sources/formale Sprachen/C/Firefox/dom/html/test/test_bug590363.html


<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=590363
-->

<head>
  <title>Test for Bug 590363</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=590363">Mozilla Bug 590363</a>
<p id="display"></p>
<div id="content" style="display: none">
  
</div>
<pre id="test">
<script type="application/javascript">

/** Test for Bug 590363 **/

var testData = [
  /* type to test | is the value reset when changing to file then reverting */
  [ "button",   false ],
  [ "checkbox", false ],
  [ "hidden",   false ],
  [ "reset",    false ],
  [ "image",    false ],
  [ "radio",    false ],
  [ "submit",   false ],
  [ "tel",      true ],
  [ "text",     true ],
  [ "url",      true ],
  [ "email",    true ],
  [ "search",   true ],
  [ "password", true ],
  [ "number",   true ],
  [ "date",     true ],
  [ "time",     true ],
  [ "range",    true ],
  [ "color",    true ],
  [ 'month',    true ],
  [ 'week',     true ],
  [ 'datetime-local', true ]
  // 'file' is treated separately.
];

var nonTrivialSanitizing = [ 'number''date''time''color''month''week',
                             'datetime-local' ];

var length = testData.length;
for (var i=0; i<length; ++i) {
  for (var j=0; j<length; ++j) {
    var e = document.createElement('input');
    e.type = testData[i][0];

    var expectedValue;

    // range will sanitize its value to 50 (the default) if it isn't a valid
    // number. We need to handle that specially.
    if (testData[j][0] == 'range' || testData[i][0] == 'range') {
      if (testData[j][0] == 'date' || testData[j][0] == 'time' ||
          testData[j][0] == 'month' || testData[j][0] == 'week' ||
          testData[j][0] == 'datetime-local') {
        expectedValue = '';
      } else if (testData[j][0] == 'color') {
        expectedValue = '#000000';
      } else {
        expectedValue = '50';
      }
    } else if (testData[i][0] == 'color' || testData[j][0] == 'color') {
        if (testData[j][0] == 'number' || testData[j][0] == 'date' ||
            testData[j][0] == 'time' || testData[j][0] == 'month' ||
            testData[j][0] == 'week' || testData[j][0] == 'datetime-local') {
          expectedValue = ''
        } else {
          expectedValue = '#000000';
        }
    } else if (nonTrivialSanitizing.includes(testData[i][0]) &&
               nonTrivialSanitizing.includes(testData[j][0])) {
      expectedValue = '';
    } else if (testData[i][0] == 'number' || testData[j][0] == 'number') {
      expectedValue = '42';
    } else if (testData[i][0] == 'date' || testData[j][0] == 'date') {
      expectedValue = '2012-12-21';
    } else if (testData[i][0] == 'time' || testData[j][0] == 'time') {
      expectedValue = '21:21';
    } else if (testData[i][0] == 'month' || testData[j][0] == 'month') {
      expectedValue = '2013-03';
    } else if (testData[i][0] == 'week' || testData[j][0] == 'week') {
      expectedValue = '2016-W35';
    } else if (testData[i][0] == 'datetime-local' ||
               testData[j][0] == 'datetime-local') {
      expectedValue = '2016-11-07T16:40';
    } else {
      expectedValue = "foo";
    }
    e.value = expectedValue;

    e.type = testData[j][0];
    is(e.value, expectedValue, ".value should still return the same value after " +
       "changing type from " + testData[i][0] + " to " + testData[j][0]);
  }
}

// For type='file' .value doesn't behave the same way.
// We are just going to check that we do not loose the value.
for (var data of testData) {
  var e = document.createElement('input');
  e.type = data[0];
  e.value = 'foo';
  e.type = 'file';
  e.type = data[0];

  if (data[0] == 'range') {
    is(e.value, '50'".value should still return the same value after " +
       "changing type from " + data[0] + " to 'file' then reverting to " + data[0]);
  } else if (data[0] == 'color') {
    is(e.value, '#000000'".value should have been reset to the default color after " +
       "changing type from " + data[0] + " to 'file' then reverting to " + data[0]);
  } else if (data[1]) {
    is(e.value, ''".value should have been reset to the empty string after " +
       "changing type from " + data[0] + " to 'file' then reverting to " + data[0]);
  } else {
    is(e.value, 'foo'".value should still return the same value after " +
       "changing type from " + data[0] + " to 'file' then reverting to " + data[0]);
  }
}

</script>
</pre>
</body>
</html>

Messung V0.5
C=97 H=99 G=97

¤ Dauer der Verarbeitung: 0.24 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.