tor-browser

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

table-insertRow.html (2491B)


      1 <!DOCTYPE html>
      2 <meta charset=utf-8>
      3 <title>HTMLTableElement.insertRow</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <div id="log"></div>
      7 <script>
      8 test(function() {
      9  var HTMLNS = "http://www.w3.org/1999/xhtml"
     10  var parentEl = document.createElementNS(HTMLNS, "html:table")
     11  assert_equals(parentEl.namespaceURI, HTMLNS, "Parent should be in the HTML namespace")
     12  assert_equals(parentEl.prefix, "html", "Parent prefix should be html")
     13  assert_equals(parentEl.localName, "table", "Parent local name should be table")
     14  assert_equals(parentEl.tagName, "HTML:TABLE", "Parent tag name should be HTML:TABLE")
     15 
     16  var row = parentEl.insertRow(-1)
     17  assert_equals(row.namespaceURI, HTMLNS, "Row should be in the HTML namespace")
     18  assert_equals(row.prefix, null, "Row prefix should be null")
     19  assert_equals(row.localName, "tr", "Row local name should be tr")
     20  assert_equals(row.tagName, "TR", "Row tag name should be TR")
     21 
     22  var body = row.parentNode
     23  assert_equals(body.namespaceURI, HTMLNS, "Body should be in the HTML namespace")
     24  assert_equals(body.prefix, null, "Body prefix should be null")
     25  assert_equals(body.localName, "tbody", "Body local name should be tr")
     26  assert_equals(body.tagName, "TBODY", "Body tag name should be TR")
     27 
     28  assert_array_equals(parentEl.childNodes, [body])
     29  assert_array_equals(body.childNodes, [row])
     30  assert_array_equals(parentEl.rows, [row])
     31 }, "insertRow should not copy prefixes")
     32 test(function() {
     33  var table = document.createElement("table")
     34  var head = table.appendChild(document.createElement("thead"))
     35  assert_array_equals(table.rows, [])
     36 
     37  var row = table.insertRow(-1)
     38  var body = row.parentNode
     39  assert_array_equals(table.childNodes, [head, body])
     40  assert_array_equals(head.childNodes, [])
     41  assert_array_equals(body.childNodes, [row])
     42  assert_array_equals(table.rows, [row])
     43 }, "insertRow should insert into a tbody, not into a thead, if table.rows is empty")
     44 test(function() {
     45  var table = document.createElement("table")
     46  var foot = table.appendChild(document.createElement("tfoot"))
     47  assert_array_equals(table.rows, [])
     48 
     49  var row = table.insertRow(-1)
     50  var body = row.parentNode
     51  assert_array_equals(table.childNodes, [foot, body])
     52  assert_array_equals(foot.childNodes, [])
     53  assert_array_equals(body.childNodes, [row])
     54  assert_array_equals(table.rows, [row])
     55 }, "insertRow should insert into a tbody, not into a tfoot, if table.rows is empty")
     56 </script>