Try the first test from the bug URL - Firefox and Opera both don't match anything, while WebKit matches one element.
Created attachment 12919 [details]
This fixes the bug, but cannot be landed until bug 12583 is fixed (otherwise, two other tests break). I hope this won't take long, so submitting for review anyway.
Comment on attachment 12919 [details]
Created attachment 13115 [details]
A fix that special-cases HTML documents, as discussed with Hyatt on IRC.
Comment on attachment 13115 [details]
Also check for node->isHTMLElement(), sincei n the future we may end up letting XML elements be in HTML docs by various means (e.g., XBL).
Committed revision 19564.