| OLD | NEW |
| 1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <meta charset="utf-8"> |
| 4 <title>Creating and deleting captions</title> | 5 <title>Creating and deleting captions</title> |
| 5 <link rel="author" title="Erika Navara" href="mailto:edoyle@microsoft.com"> | 6 <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" /> | 7 <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" /> | 8 <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" /> | 9 <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-table-delet
ecaption" /> |
| 9 <script src="/resources/testharness.js"></script> | 10 <script src="/resources/testharness.js"></script> |
| 10 <script src="/resources/testharnessreport.js"></script> | 11 <script src="/resources/testharnessreport.js"></script> |
| 11 </head> | 12 </head> |
| 12 <body> | 13 <body> |
| 13 <div id="log"></div> | 14 <div id="log"></div> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 31 <caption id="caption3">caption 3</caption> | 32 <caption id="caption3">caption 3</caption> |
| 32 <tr> | 33 <tr> |
| 33 <td>cell</td> | 34 <td>cell</td> |
| 34 <td>cell</td> | 35 <td>cell</td> |
| 35 </tr> | 36 </tr> |
| 36 </table> | 37 </table> |
| 37 <table id="table4" style="display:none"> | 38 <table id="table4" style="display:none"> |
| 38 </table> | 39 </table> |
| 39 <table id="table5" style="display:none"> | 40 <table id="table5" style="display:none"> |
| 40 </table> | 41 </table> |
| 42 <table id="table6" style="display:none"> |
| 43 <caption id="caption6">caption 6</caption> |
| 44 <tr> |
| 45 <td>cell</td> |
| 46 <td>cell</td> |
| 47 </tr> |
| 48 </table> |
| 49 <table id="table7" style="display:none"> |
| 50 <caption id="caption7">caption 7</caption> |
| 51 <tbody id="tbody7"> |
| 52 <tr> |
| 53 <td>cell</td> |
| 54 <td>cell</td> |
| 55 </tr> |
| 56 </tbody> |
| 57 </table> |
| 41 <script> | 58 <script> |
| 42 test(function () { | 59 test(function () { |
| 43 var table0 = document.getElementById('table0'); | 60 var table0 = document.getElementById('table0'); |
| 44 var caption = document.createElementNS("foo", "caption"); | 61 var caption = document.createElementNS("foo", "caption"); |
| 45 table0.appendChild(caption); | 62 table0.appendChild(caption); |
| 46 var table0FirstNode = table0.firstChild; | 63 var table0FirstNode = table0.firstChild; |
| 47 var testCaption = table0.createCaption(); | 64 var testCaption = table0.createCaption(); |
| 48 assert_not_equals(testCaption, table0FirstNode); | 65 assert_not_equals(testCaption, table0FirstNode); |
| 49 assert_equals(testCaption, table0.firstChild); | 66 assert_equals(testCaption, table0.firstChild); |
| 50 }, "createCaption method creates new caption if existing caption is not in h
tml namespace") | 67 }, "createCaption method creates new caption if existing caption is not in h
tml namespace") |
| 68 |
| 51 test(function () { | 69 test(function () { |
| 52 var table1 = document.getElementById('table1'); | 70 var table1 = document.getElementById('table1'); |
| 53 var testCaption = table1.createCaption(); | 71 var testCaption = table1.createCaption(); |
| 54 var table1FirstCaption = table1.caption; | 72 var table1FirstCaption = table1.caption; |
| 55 assert_equals(testCaption, table1FirstCaption); | 73 assert_equals(testCaption, table1FirstCaption); |
| 56 }, "createCaption method returns the first caption element child of the tabl
e") | 74 }, "createCaption method returns the first caption element child of the tabl
e") |
| 75 |
| 57 test(function () { | 76 test(function () { |
| 58 var table2 = document.getElementById('table2'); | 77 var table2 = document.getElementById('table2'); |
| 59 var test2Caption = table2.createCaption(); | 78 var test2Caption = table2.createCaption(); |
| 60 var table2FirstNode = table2.firstChild; | 79 var table2FirstNode = table2.firstChild; |
| 61 assert_true(test2Caption instanceof HTMLTableCaptionElement); | 80 assert_true(test2Caption instanceof HTMLTableCaptionElement); |
| 62 assert_equals(table2FirstNode, test2Caption); | 81 assert_equals(table2FirstNode, test2Caption); |
| 63 }, "createCaption method creates a new caption and inserts it as the first n
ode of the table element") | 82 }, "createCaption method creates a new caption and inserts it as the first n
ode of the table element") |
| 83 |
| 64 test(function () { | 84 test(function () { |
| 65 var table = document.createElement('table'); | 85 var table = document.createElement('table'); |
| 66 assert_equals(table.createCaption(), table.createCaption()); | 86 assert_equals(table.createCaption(), table.createCaption()); |
| 67 }, "createCaption will not create new caption if one exists") | 87 }, "createCaption will not create new caption if one exists") |
| 88 |
| 68 test(function () { | 89 test(function () { |
| 69 var table = document.createElementNS("http://www.w3.org/1999/xhtml", "foo:
table") | 90 var table = document.createElementNS("http://www.w3.org/1999/xhtml", "foo:
table") |
| 70 var caption = table.createCaption(); | 91 var caption = table.createCaption(); |
| 71 assert_equals(caption.prefix, null); | 92 assert_equals(caption.prefix, null); |
| 72 }, "createCaption will not copy table's prefix") | 93 }, "createCaption will not copy table's prefix") |
| 94 |
| 73 test(function () { | 95 test(function () { |
| 74 var table3 = document.getElementById('table3'); | 96 var table3 = document.getElementById('table3'); |
| 75 assert_equals(table3.caption.textContent, "caption 3"); | 97 assert_equals(table3.caption.textContent, "caption 3"); |
| 76 table3.deleteCaption(); | 98 table3.deleteCaption(); |
| 77 assert_equals(table3.caption, null); | 99 assert_equals(table3.caption, null); |
| 78 }, "deleteCaption method removes the first caption element child of the tabl
e element") | 100 }, "deleteCaption method removes the first caption element child of the tabl
e element") |
| 101 |
| 79 test(function () { | 102 test(function () { |
| 80 var table4 = document.getElementById('table4'); | 103 var table4 = document.getElementById('table4'); |
| 81 var caption = document.createElementNS("foo", "caption"); | 104 var caption = document.createElementNS("foo", "caption"); |
| 82 table4.appendChild(caption); | 105 table4.appendChild(caption); |
| 83 table4.deleteCaption(); | 106 table4.deleteCaption(); |
| 84 assert_equals(caption.parentNode, table4); | 107 assert_equals(caption.parentNode, table4); |
| 85 }, "deleteCaption method not remove caption that is not in html namespace") | 108 }, "deleteCaption method not remove caption that is not in html namespace") |
| 109 |
| 86 test(function() { | 110 test(function() { |
| 87 var table5 = document.getElementById('table5'); | 111 var table5 = document.getElementById('table5'); |
| 88 var caption = document.createElement('caption'); | 112 var caption = document.createElement('caption'); |
| 89 caption.appendChild(table5) | 113 caption.appendChild(table5) |
| 90 | 114 |
| 91 // Node cannot be inserted at the specified point in the hierarchy | 115 // Node cannot be inserted at the specified point in the hierarchy |
| 92 assert_throws("HierarchyRequestError", function() { | 116 assert_throws("HierarchyRequestError", function() { |
| 93 table5.caption = caption; | 117 table5.caption = caption; |
| 94 }); | 118 }); |
| 95 | 119 |
| 96 assert_not_equals(table5.caption, caption); | 120 assert_not_equals(table5.caption, caption); |
| 97 }, "Setting caption rethrows exception"); | 121 }, "Setting caption rethrows exception"); |
| 122 |
| 123 test(function() { |
| 124 var table6 = document.getElementById("table6"); |
| 125 var caption = document.getElementById("caption6"); |
| 126 assert_equals(table6.caption, caption); |
| 127 |
| 128 var newCaption = document.createElement("caption"); |
| 129 table6.caption = newCaption; |
| 130 assert_equals(newCaption.parentNode, table6); |
| 131 assert_equals(table6.firstChild, newCaption); |
| 132 assert_equals(table6.caption, newCaption); |
| 133 }, "Assigning a caption to table.caption") |
| 134 |
| 135 test(function() { |
| 136 var table7 = document.getElementById("table7"); |
| 137 var caption = document.getElementById("caption7"); |
| 138 assert_equals(table7.caption, caption); |
| 139 |
| 140 table7.caption = null; |
| 141 assert_equals(caption.parentNode, null); |
| 142 assert_equals(table7.firstElementChild, document.getElementById("tbody7"))
; |
| 143 assert_equals(table7.caption, null); |
| 144 }, "Assigning null to table.caption") |
| 145 |
| 146 test(function() { |
| 147 var table8 = document.createElement("table"); |
| 148 var caption = document.createElement("captİon"); |
| 149 assert_throws(new TypeError(), function() { |
| 150 table8.caption = caption; |
| 151 }); |
| 152 }, "Assigning a non-caption to table.caption") |
| 153 |
| 154 test(function() { |
| 155 var table9 = document.createElement("table"); |
| 156 var caption = document.createElementNS("http://www.example.com", "caption"
); |
| 157 assert_throws(new TypeError(), function() { |
| 158 table9.caption = caption; |
| 159 }); |
| 160 }, "Assigning a foreign caption to table.caption") |
| 98 </script> | 161 </script> |
| 99 </body> | 162 </body> |
| 100 </html> | 163 </html> |
| OLD | NEW |