Closed Bug 229294 Opened 19 years ago Closed 6 years ago

XMLHttpRequest - doesn't calculate baseURI correctly (scriptcontext?)


(Core :: XML, defect)

Not set





(Reporter: doronr, Unassigned)




The setup:

2 pages, on at /foo/ (A) and one at /foo/bar/ (B).

Page A has a javascript function that creates an XMLHttpRequest object and
fetches an xml file located at /foo/file.xml.

Page B, which gets opened by A, then proceeds to do a
window.opener.functionCall().  The document.baseURI shows that no matter where
functionCall() is called from (page A or B), it has the same baseURI.

However, when page B calls the function in page A, it fails.  It seems that
is returning "/foo/bar/", and trying to fetch "/foo/bar/file.xml" rather than

Note that this can be worked-around by defining the xmlhttprequest object not in
the function but in the global namespace of page A.

Perhaps GetDocumentFromScriptContext() is returning the document from page B?
I meant XML, sorry.
Component: Web Services → XML
Putting some printfs confirms that GetDocumentFromScriptContext() returns the
document from page B.
Blocks: 246518
Yes, this is exactly what is happening. Are you sure that is "wrong" though? I.e, what does IE do?
Note that I raised this with the web apis WG today.
IE(In reply to comment #3)
> Yes, this is exactly what is happening. Are you sure that is "wrong" though?
> I.e, what does IE do?

Tested this on IE, it does not produce the same bug (i.e. uses URL from page A).

This can be worked around in FF by having page A use window.setTimeout to execute the function (found workaround at

I believe we've decided that the W3C spec will define more or less IEs behaviour as the correct one, so keeping this bug open to make us conform with the spec once the spec is out.
I will wait a patch.
Windows Vista, Firefox
Flags: in-testsuite?
Note that the specification now defines this. has a bunch of related testcases.
Assignee: web-services → nobody
QA Contact: doronr → xml
I can't reproduce this problem.  In particular, shows that we use the base URI of the callee here, as do WebKit and Blink.
Closed: 6 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.