I tried out the bmw.com website, and when I tried to select my country or region from the list, the list wouldn't open and the page formatting went crazy.
Confirmed with a local debug build of WebKit r19572 with Safari 2.0.4 (419.3) on Mac OS X 10.4.8 (8L127). This is not a regression as shipping Safari looks and acts about the same. I don't see any JavaScript errors in the JS Console, nor do I see any console output when visiting the page.
I can also confirm this, 05/11/2007, still exists in Safari 2.0.4 (419.3) and today's latest WebKit build. Want to lease a BMW 328i, went to page in Safari. www.bmw.com main webpage is totally messed up and useless in Safari, works with Firefox (QA engineer on FCP 4 at Apple, 2001-2003 Please fix, thanks jklimeck@mac.com
Adding NeedsRadar keyword since this is a fairly high-profile web site (and brand).
Created attachment 14511 [details] test case
This is a parsing problem; Firefox DOM tree matches html5lib one. <div style="display:none"> <table> <div> <table> </table> </div> </div>
Hmmm, WebKit basically does what I implemented here, which seems more sensible to me than the behavior I'm seeing in Firefox.
WebKit's model is to detect when you enter stray table content. When this happens you pull that content out and put it before the table. (Firefox does this as well for the div that is inside the table. Where we differ is with what happens next. We assume that until we encounter a <tr> or <td> that we are still inside that stray table content. I guess Mozilla assumes <table> should end the stray table content section. Because we put the second <table> inside the <div>, when we hit the first close</div>, we close up the stray table content and then we are back inside the outer table. The second </div> is not sufficient to close up (since </div> never wins when inside a <table>), and so the <p> ends up inside the <div> as well. Firefox closes up the stray content the minute it hits the second table, and so the first </div> encountered actually closed up the *outer* div. The second </div> is then ignored. The <p> is then outside the outer div. I'll have to go study the HTML5 spec. It may be that <table> is on the list of tags to be considered as "ending" stray table content. I'm not so sure that it should be though, since you should really be looking for things that would logically be elements of *your* table (like <tr> and <td> and <tbody> etc.).
My guess is that html5lib just parses this dumbly as a tree and doesn't do any of the stray table content stuff that real browsers have to do.
This example shows that my analysis of what Firefox is doing is correct. <body> <p>Should say "SUCCESS" below:</p> <div style="border:2px solid red"> <table> <div style="border:2px solid green"> <table border=2><tr><td>Table </table> </div> <p>SUCCESS</p> </body> I don't even have the second close </div> in that example, proving that the first </div> closed up the outermost one.
In Firefox and html5lib and IE a <table> encountered while in stray table content actually has the effect of closing up the original table! This is a rule we are simply missing. I'll try implementing it and see what breaks.
Created attachment 14513 [details] Easy, the html5 spec covers this. Will land the test case.
Comment on attachment 14513 [details] Easy, the html5 spec covers this. r=me
<rdar://problem/5199034>
Fixed in r21428.