https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 1614d65d2cd50d167c605cf212f35db792a38c31 authored by Yutaka Hirano on 03 April 2018, 01:48:59 UTC
fix
Tip revision: 1614d65
form_owner_and_table.html
<!DOCTYPE html>
<html>
  <head>
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
  </head>
  <body>
    <div id="root">
      <form id='form1'></form>
      <table id='table1'>
        <form id='form2'>
        <tr><td><input id='input1'></td></tr>
        <tr><td><input id='input2' form='form1'></td></tr>
      </table>
      <form id="form3">
        <input id="input3" />
      </form>
    </div>

    <script>
      test(function() {
        var input1 = document.getElementById('input1');
        var input2 = document.getElementById('input2');
        var input3 = document.getElementById('input3');
        var form1 = document.getElementById('form1');
        var form2 = document.getElementById('form2');
        var form3 = document.getElementById('form3');

        var root = document.getElementById('root');

        assert_equals(input1.form, form2,
          "input1's form owner must be form2 as per the parsing rules");
        assert_equals(input2.form, form1,
          "input2's form owner must be the form with id 'form1'");
        assert_equals(input3.form, form2,
          "input3's form owner must be form2 as per the parsing rules");

        root.parentNode.removeChild(root);

        assert_equals(input1.form, form2,
          "input1's form owner must not have changed since they are both in the same subtree");
        assert_equals(input2.form, null,
          "input2 must not have a form owner since it has the form attribute set");
        assert_equals(input3.form, form2,
          "input3's form owner must not have changed since they are both in the same subtree");

      }, "Form element and form controls nested inside a table are correctly handled");
    </script>
  </body>
</html>
back to top