Bug 16657 - Acid3 failure since table.caption and table.thead do not work for nodes added by appendChild
Summary: Acid3 failure since table.caption and table.thead do not work for nodes added...
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Darin Adler
Depends on:
Reported: 2007-12-28 22:09 PST by Eric Seidel (no email)
Modified: 2008-01-02 17:26 PST (History)
4 users (show)

See Also:

patch (fixes this and bug 16659 too) (88.22 KB, patch)
2008-01-01 22:38 PST, Darin Adler
mjs: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Seidel (no email) 2007-12-28 22:09:58 PST
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');
      var tr1 = document.createElement('tr');
      // <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>
      // 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;
Comment 1 Eric Seidel (no email) 2007-12-30 23:45:23 PST
It looks like the addChild logic is never called for appendChild, thus the HTMLTableElement doesn't know to fix up its m_caption pointer.
Comment 2 Darin Adler 2008-01-01 21:58:26 PST
I've got a fix for this.
Comment 3 Darin Adler 2008-01-01 22:38:30 PST
Created attachment 18233 [details]
patch (fixes this and bug 16659 too)
Comment 4 Eric Seidel (no email) 2008-01-01 22:53:55 PST
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 5 Maciej Stachowiak 2008-01-02 15:45:14 PST
Comment on attachment 18233 [details]
patch (fixes this and bug 16659 too)

Comment 6 Darin Adler 2008-01-02 17:26:19 PST