PageRenderTime 20ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/third_party/WebKit/LayoutTests/imported/web-platform-tests/html/semantics/forms/the-form-element/form-elements-matches.html

https://gitlab.com/jonnialva90/iridium-browser
HTML | 46 lines | 46 code | 0 blank | 0 comment | 0 complexity | 3761bfaf117533ed4dfef69c0ca861ba MD5 | raw file
  1. <!DOCTYPE html>
  2. <title>form.elements: matches</title>
  3. <link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
  4. <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-form-elements">
  5. <script src="../../../../../../resources/testharness.js"></script>
  6. <script src="../../../../../../resources/testharnessreport.js"></script>
  7. <div id="log"></div>
  8. <div id="test">
  9. <form id="form">
  10. <input type="image">
  11. </form>
  12. </div>
  13. <script>
  14. test(function() {
  15. assert_equals(document.getElementById("form").elements.length, 0);
  16. }, "input type=image should not be present in the form.elements collection")
  17. test(function() {
  18. var form = document.getElementById("form");
  19. var i = document.createElement("input");
  20. i.name = "2";
  21. form.appendChild(i);
  22. var j = document.createElement("input");
  23. j.name = "03";
  24. form.appendChild(j);
  25. assert_equals(form.elements[-1], undefined, '[-1]');
  26. assert_equals(form.elements["-1"], undefined, '["-1"]');
  27. assert_equals(form.elements[0], i, '[0]');
  28. assert_equals(form.elements["0"], i, '["0"]');
  29. assert_equals(form.elements[1], j, '[1]');
  30. assert_equals(form.elements["1"], j, '["1"]');
  31. assert_equals(form.elements[2], undefined, '[2]');
  32. assert_equals(form.elements["2"], undefined, '["2"]');
  33. assert_equals(form.elements[03], undefined, '[03]');
  34. assert_equals(form.elements["03"], j, '["03"]');
  35. assert_equals(form.elements.item(-1), null, 'item(-1)');
  36. assert_equals(form.elements.item(0), i, 'item(0)');
  37. assert_equals(form.elements.item(1), j, 'item(1)');
  38. assert_equals(form.elements.item(2), null, 'item(2)');
  39. assert_equals(form.elements.namedItem("2"), i, 'namedItem("2")');
  40. assert_equals(form.elements.namedItem("03"), j, 'namedItem("03")');
  41. assert_equals(form.elements.namedItem("3"), null, 'namedItem("3")');
  42. assert_array_equals(form.elements, [i, j]);
  43. form.removeChild(i);
  44. form.removeChild(j);
  45. }, "form.elements should include elements whose name starts with a number");
  46. </script>