Acid3 expects empty table caption to produce (!table.caption == false) Likewise an empty tHead to produce (!table.tHead == false) These both evaluate to empty strings in WebKit when set, but set to empty. We'll have to check other browsers to see what they do (or check the spec(s). function () { // test 65: construct a table, and see if the table is as expected var ok = true; var table = document.createElement('table'); table.appendChild(document.createElement('tbody')); var tr1 = document.createElement('tr'); table.appendChild(tr1); table.appendChild(document.createElement('caption')); table.appendChild(document.createElement('thead')); // <table><tbody/><tr/><caption/><thead/> table.insertBefore(table.firstChild.nextSibling, null); // move the <tr/> to the end // <table><tbody/><caption/><thead/><tr/> table.replaceChild(table.firstChild, table.lastChild); // move the <tbody/> to the end and remove the <tr> // <table><caption/><thead/><tbody/> var tr2 = table.tBodies[0].insertRow(0); // <table><caption/><thead/><tbody><tr/></tbody> if ((table.tBodies[0].rows[0].rowIndex != 0) || (table.tBodies[0].rows[0].sectionRowIndex != 0) || (table.childNodes.length != 3) || (!table.caption) || (!table.tHead) || (table.tFoot) || (table.tBodies.length != 1) || (table.rows.length != 1)) ok = false; if (tr1.parentNode) ok = false; if ((table.caption != table.createCaption()) || (table.tFoot != null) || (table.tHead != table.createTHead())) ok = false; if (table.createTFoot() != table.tFoot) ok = false; // either: <table><caption/><thead/><tbody><tr/></tbody><tfoot/> // or: <table><caption/><thead/><tfoot/><tbody><tr/></tbody> table.tHead.appendChild(tr1); // either: <table><caption/><thead><tr/></thead><tbody><tr/></tbody><tfoot/> // or: <table><caption/><thead><tr/></thead><tfoot/><tbody><tr/></tbody> if ((table.rows[0] != table.tHead.firstChild) || (table.rows.length != 2) || (table.rows[1] != table.tBodies[0].firstChild)) ok = false; if (ok) return 5; },
It looks like the addChild logic is never called for appendChild, thus the HTMLTableElement doesn't know to fix up its m_caption pointer.
I've got a fix for this.
Created attachment 18233 [details] patch (fixes this and bug 16659 too)
Comment on attachment 18233 [details] patch (fixes this and bug 16659 too) I think this patch looks great. I wondered what our testing coverage is for multiple <tfoot> <thead> elements is, since those look like edge cases we need to support (and looks like we try to currently). I'd r+ this, except that I don't 100% trust my review given my fatigue and lack of table knowledge. A second pair of eyes is recommended before landing.
Comment on attachment 18233 [details] patch (fixes this and bug 16659 too) r=me
r29101