| OLD | NEW |
| 1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Creating and deleting captions</title> | 4 <title>Creating and deleting captions</title> |
| 5 <link rel="author" title="Erika Navara" href="mailto:edoyle@microsoft.com"> | 5 <link rel="author" title="Erika Navara" href="mailto:edoyle@microsoft.com"> |
| 6 <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-table-eleme
nt" /> | 6 <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-table-eleme
nt" /> |
| 7 <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-table-creat
ecaption" /> | 7 <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-table-creat
ecaption" /> |
| 8 <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-table-delet
ecaption" /> | 8 <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-table-delet
ecaption" /> |
| 9 <script src="../../../../../../resources/testharness.js"></script> | 9 <script src="../../../../../../resources/testharness.js"></script> |
| 10 <script src="../../../../../../resources/testharnessreport.js"></script> | 10 <script src="../../../../../../resources/testharnessreport.js"></script> |
| 11 </head> | 11 </head> |
| 12 <body> | 12 <body> |
| 13 <div id="log"></div> | 13 <div id="log"></div> |
| 14 <table id="table0" style="display:none"> |
| 15 </table> |
| 14 <table id="table1" style="display:none"> | 16 <table id="table1" style="display:none"> |
| 15 <caption id="caption1">caption</caption> | 17 <caption id="caption1">caption</caption> |
| 16 <tr> | 18 <tr> |
| 17 <td>cell</td> | 19 <td>cell</td> |
| 18 <td>cell</td> | 20 <td>cell</td> |
| 19 </tr> | 21 </tr> |
| 20 </table> | 22 </table> |
| 21 <table id="table2" style="display:none"> | 23 <table id="table2" style="display:none"> |
| 24 <foo:caption>caption</foo:caption> |
| 22 <tr> | 25 <tr> |
| 23 <td>cell</td> | 26 <td>cell</td> |
| 24 <td>cell</td> | 27 <td>cell</td> |
| 25 </tr> | 28 </tr> |
| 26 </table> | 29 </table> |
| 27 <table id="table3" style="display:none"> | 30 <table id="table3" style="display:none"> |
| 28 <caption id="caption3">caption 3</caption> | 31 <caption id="caption3">caption 3</caption> |
| 29 <tr> | 32 <tr> |
| 30 <td>cell</td> | 33 <td>cell</td> |
| 31 <td>cell</td> | 34 <td>cell</td> |
| 32 </tr> | 35 </tr> |
| 33 </table> | 36 </table> |
| 37 <table id="table4" style="display:none"> |
| 38 </table> |
| 34 <script> | 39 <script> |
| 35 test(function () { | 40 test(function () { |
| 41 var table0 = document.getElementById('table0'); |
| 42 var caption = document.createElementNS("foo", "caption"); |
| 43 table0.appendChild(caption); |
| 44 var table0FirstNode = table0.firstChild; |
| 45 var testCaption = table0.createCaption(); |
| 46 assert_not_equals(testCaption, table0FirstNode); |
| 47 assert_equals(testCaption, table0.firstChild); |
| 48 }, "createCaption method creates new caption if existing caption is not in h
tml namespace") |
| 49 test(function () { |
| 36 var table1 = document.getElementById('table1'); | 50 var table1 = document.getElementById('table1'); |
| 37 var testCaption = table1.createCaption(); | 51 var testCaption = table1.createCaption(); |
| 38 var table1FirstCaption = table1.caption; | 52 var table1FirstCaption = table1.caption; |
| 39 assert_equals(testCaption, table1FirstCaption); | 53 assert_equals(testCaption, table1FirstCaption); |
| 40 }, "createCaption method returns the first caption element child of the tabl
e") | 54 }, "createCaption method returns the first caption element child of the tabl
e") |
| 41 test(function () { | 55 test(function () { |
| 42 var table2 = document.getElementById('table2'); | 56 var table2 = document.getElementById('table2'); |
| 43 var test2Caption = table2.createCaption(); | 57 var test2Caption = table2.createCaption(); |
| 44 var table2FirstNode = table2.firstChild; | 58 var table2FirstNode = table2.firstChild; |
| 45 assert_true(test2Caption instanceof HTMLTableCaptionElement); | 59 assert_true(test2Caption instanceof HTMLTableCaptionElement); |
| 46 assert_equals(table2FirstNode, test2Caption); | 60 assert_equals(table2FirstNode, test2Caption); |
| 47 }, "createCaption method creates a new caption and inserts it as the first n
ode of the table element") | 61 }, "createCaption method creates a new caption and inserts it as the first n
ode of the table element") |
| 48 test(function () { | 62 test(function () { |
| 63 var table = document.createElement('table'); |
| 64 assert_equals(table.createCaption(), table.createCaption()); |
| 65 }, "createCaption will not create new caption if one exists") |
| 66 test(function () { |
| 67 var table = document.createElementNS("http://www.w3.org/1999/xhtml", "foo:
table") |
| 68 var caption = table.createCaption(); |
| 69 assert_equals(caption.prefix, null); |
| 70 }, "createCaption will not copy table's prefix") |
| 71 test(function () { |
| 49 var table3 = document.getElementById('table3'); | 72 var table3 = document.getElementById('table3'); |
| 50 assert_equals(table3.caption.textContent, "caption 3"); | 73 assert_equals(table3.caption.textContent, "caption 3"); |
| 51 table3.deleteCaption(); | 74 table3.deleteCaption(); |
| 52 assert_equals(table3.caption, null); | 75 assert_equals(table3.caption, null); |
| 53 }, "deleteCaption method removes the first caption element child of the tabl
e element") | 76 }, "deleteCaption method removes the first caption element child of the tabl
e element") |
| 77 test(function () { |
| 78 var table4 = document.getElementById('table4'); |
| 79 var caption = document.createElementNS("foo", "caption"); |
| 80 table4.appendChild(caption); |
| 81 table4.deleteCaption(); |
| 82 assert_equals(caption.parentNode, table4); |
| 83 }, "deleteCaption method not remove caption that is not in html namespace") |
| 54 </script> | 84 </script> |
| 55 </body> | 85 </body> |
| 56 </html> | 86 </html> |
| OLD | NEW |