Bug 20378 - Need to define base URI for the document created via DOMParser
Summary: Need to define base URI for the document created via DOMParser
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: DOM Parsing and Serialization (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Travis Leithead [MSFT]
QA Contact: public-webapps-bugzilla
Depends on:
Reported: 2012-12-13 17:43 UTC by Boris Zbarsky
Modified: 2014-12-01 18:30 UTC (History)
5 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Boris Zbarsky 2012-12-13 17:43:21 UTC
This is needed by various DOM methods.

Note that in Gecko this is the base URI of the document of the current window of the browsing context of the window the DOMParser is created from or something like that.  No idea what other UAs do.
Comment 1 Anne 2012-12-14 09:02:44 UTC
The base URL would not be simply the document's URL? (The latter I think should be about:blank.)
Comment 2 Boris Zbarsky 2012-12-14 09:10:26 UTC
It could be, sure.  Just needs to be defined.
Comment 3 Anne 2012-12-14 10:58:10 UTC
Ah right, so for Gecko the document's URL is indeed the "page URL". Other browsers use null, which I think they should change to about:blank so we can make document.documentURI and document.URL always be a string.

I can change the document to remove the open issue and just say that URL should be about:blank.
Comment 4 Travis Leithead [MSFT] 2014-10-13 23:55:21 UTC
In, ... this currently says:

"Additionally, the document must have a URL value equal to the URL of the active document"

This does not say "base URI". That should be added. Anything else here?
Comment 5 Anne 2014-10-14 07:08:56 UTC
Can't we use about:blank as the document's URL? That seems much cleaner than some kind of override.

No need to add a base URL, it's derived.
Comment 6 Boris Zbarsky 2014-10-14 12:04:27 UTC
Assuming that's web-compatible, that seems doable.

Right now interop seems to be mixed.  Consider this testcase meant to test simple base URI behavior: http://jsfiddle.net/n9zb6yox/

The results I see are as follows:

Gecko: http://fiddle.jshell.net/n9zb6yox/show/foo
Blink: empty string
Safari: foo
IE11: http://fiddle.jshell.net/n9zb6yox/show/foo

and this testcase tests document.URL: http://jsfiddle.net/n9zb6yox/2/


Gecko: http://fiddle.jshell.net/n9zb6yox/2/show/
Blink: empty string
Safari: empty string
IE11: http://fiddle.jshell.net/n9zb6yox/2/show/

and this testcase tests document.baseURI: http://jsfiddle.net/n9zb6yox/3/


Gecko: http://fiddle.jshell.net/n9zb6yox/3/show/
Blink: null
Safari: null
IE11: undefined; looks like it has no .baseURI support yet.

and this testcase tests what happens with <base> in the main doc: http://jsfiddle.net/n9zb6yox/4/


Gecko: http://example.com/foo
Blink: empty string
Safari: foo
IE11: http://fiddle.jshell.net/n9zb6yox/4/foo

And with <base> in the parsed doc: http://jsfiddle.net/n9zb6yox/5/


Gecko: http://example.com/foo
Blink: http://example.com/foo
Safari: http://example.com/foo
IE11: http://example.com/foo

Hey, some sanity at last!