Closed Bug 505783 Opened 13 years ago Closed 12 years ago

Setting dynamically xml:base for XHTML elements has no effect in HTML documents


(Core :: DOM: Core & HTML, defect)

Windows XP
Not set



Tracking Status
status1.9.2 --- beta1-fixed


(Reporter: nanto, Assigned: hsivonen)



(Keywords: html5)


(3 files)

Setting the xml:base attribute on an XML (including XHTML) element changes the base URI of the element, but Mozilla now ignores xml:base if the elements is an XHTML element and the document is an HTML document (served as text/html).

See the attachment to reproduce this.



This is a regression.  Firefox 3.5 and older works as expected.  This breaks resolving-relative-URIs techniques [1] and some Greasemonkey scripts that use the techniques [2] [3].

I think this is a regression from Bug 468708.
Blocks: 468708
I suppose we could enable xml:base in HTML too :( I'm not a big fan of xml:base in general since I think it's somewhat over complicated, but if people really use it that seems like a reasonable solution.
IIRC, HTML5/Hixie says that script-inserted xml:base in HTML documents should work.
Assignee: nobody → hsivonen
Isn't this just a matter of this code in nsGenericHTMLElement::GetBaseURI() bailing out early?

Do we need to make sure to fix this in 1.9.2, if this is breaking real things out there?

We could just take out the early-bail and see what happens, perf-wise, I suppose...

Maybe we should flag nodes that have an ancestor with xml:base set, so that we can fast-path all the other (common!) cases?
Need to get some perf numbers for this.
Comment on attachment 394261 [details] [diff] [review]
Don't make xml:base special in HTML

Looks OK on tryserver talos.
Attachment #394261 - Flags: review?(jonas)
Flags: wanted1.9.2?
Keywords: html5

Are the flags on this bug now right for 3.6 approval consideration?
Closed: 12 years ago
Resolution: --- → FIXED
Is this really important enough for 1.9.2? Seems very much like an edgecase. If you think we need it you need to set the approval 1.9.2? flag on the patch.
Comment on attachment 394261 [details] [diff] [review]
Don't make xml:base special in HTML

This is unlikely to matter for Web compat. However, not having this patch in 1.9.2 could break Greasemonkey scripts or extensions as stated in the bug description.
Attachment #394261 - Flags: approval1.9.2?
Comment on attachment 394261 [details] [diff] [review]
Don't make xml:base special in HTML

I can't imagine taking this on branch without a test (and it should have a test anyway, no?)
Attached patch MochitestSplinter Review
Could this bug get branch approval with this test case, please?
Attachment #404235 - Flags: review?(jonas)
Flags: in-testsuite?
Comment on attachment 404235 [details] [diff] [review]

Could you *also* test that things work if the <a> is inserted into the document.

r=me with that
Attachment #404235 - Flags: review?(jonas) → review+
Comment on attachment 394261 [details] [diff] [review]
Don't make xml:base special in HTML

a=sicking with the testcase once fixed per above comment.
Attachment #394261 - Flags: approval1.9.2? → approval1.9.2+
Test pushed with additional in-document check:

Pushed to branch:

Flags: in-testsuite? → in-testsuite+
Flags: wanted1.9.2?
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.