tor-browser

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

delete-caption.html (3270B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>deleteCaption()</title>
      5  <link rel="author" title="Ben Boyle" href="mailto:benjamins.boyle@gmail.com">
      6  <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-table-deletecaption" />
      7  <script src="/resources/testharness.js"></script>
      8  <script src="/resources/testharnessreport.js"></script>
      9 </head>
     10 <body>
     11  <table id="one-caption">
     12    <caption>Fixture table caption</caption>
     13  </table>
     14 
     15  <table id="two-captions">
     16    <caption>Fixture table caption</caption>
     17    <caption>A second caption element</caption>
     18  </table>
     19 
     20  <table id="zero-captions"></table>
     21 
     22  <table id="descendent-caption">
     23    <tr>
     24      <td>
     25        <table>
     26          <caption>Nested caption</caption>
     27        </table>
     28      </td>
     29    </tr>
     30  </table>
     31 
     32  <script>
     33  // The deleteCaption() method must remove the first caption element child of the table element, if any.
     34  // https://html.spec.whatwgorg/multipage/tables.html#dom-table-deletecaption
     35  test(function() {
     36    var table = document.getElementById('one-caption');
     37 
     38    table.deleteCaption();
     39    assert_equals(table.getElementsByTagName('caption').length, 0, 'caption was removed');
     40 
     41  }, 'deleteCaption() delete only caption on table');
     42 
     43  test(function() {
     44    var table = document.getElementById('one-caption');
     45    var result;
     46 
     47    result = table.deleteCaption();
     48    // does .deleteCaption() have a return value?
     49    assert_equals(result, undefined, '.deleteCaption() returns undefined');
     50  }, 'deleteCaption() returns undefined');
     51 
     52  test(function() {
     53    var table = document.getElementById('two-captions');
     54 
     55    table.deleteCaption();
     56    assert_equals(table.getElementsByTagName('caption').length, 1, '1 caption (of 2) was removed');
     57    assert_equals(table.getElementsByTagName('caption')[0].textContent, 'A second caption element', 'The first caption was removed');
     58 
     59    // removing the only caption
     60    table.deleteCaption();
     61    assert_equals(table.getElementsByTagName('caption').length, 0, 'last caption was removed');
     62  }, 'deleteCaption()');
     63 
     64  test(function() {
     65    var table = document.getElementById('zero-captions');
     66    // removing a caption when none exists
     67    table.deleteCaption();
     68 
     69    assert_equals(table.getElementsByTagName('caption').length, 0, 'no exceptions using .deleteCaption() on a table without any captions');
     70 
     71  }, 'deleteCaption() does not throw any exceptions when called on a table without a caption');
     72 
     73  test(function() {
     74    var table = document.getElementById( 'descendent-caption' );
     75    table.deleteCaption();
     76 
     77    assert_equals(table.getElementsByTagName('caption').length, 1, 'descendent caption was not deleted');
     78  }, 'deleteCaption() does not delete captions in descendent tables');
     79 
     80  test(function() {
     81    var table = document.getElementById('zero-captions');
     82    var caption;
     83 
     84    caption = document.createElementNS('http://www.w3.org/2000/svg', 'caption');
     85    table.insertBefore(caption, table.firstChild);
     86    assert_equals(table.getElementsByTagName('caption').length, 1, 'SVG:caption is created');
     87 
     88    table.deleteCaption();
     89    assert_equals(table.getElementsByTagName('caption').length, 1, 'SVG:caption is not deleted');
     90 
     91  }, 'deleteCaption() handles captions from different namespaces');
     92 </script>
     93 </body>
     94 </html>