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




15 years ago
2 years ago


(Reporter: Doron Rosenberg (IBM), Unassigned)


Dependency tree / graph
Bug Flags:
in-testsuite ?

Firefox Tracking Flags

(Not tracked)





15 years ago
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?

Comment 1

15 years ago
I meant XML, sorry.
Component: Web Services → XML

Comment 2

15 years ago
Putting some printfs confirms that GetDocumentFromScriptContext() returns the
document from page B.
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.

Comment 5

12 years ago
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 http://dema.ruby.com.br/articles/2005/05/06/be-careful-when-mixing-ajax-and-popup-windows-on-firefox).

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.

Comment 7

11 years ago
I will wait a patch.

Comment 8

11 years ago
Windows Vista, Firefox
Flags: in-testsuite?

Comment 9

11 years ago
Note that the specification now defines this. http://tc.labs.opera.com/apis/XMLHttpRequest/open/ has a bunch of related testcases.
Assignee: web-services → nobody
QA Contact: doronr → xml
I can't reproduce this problem.  In particular, http://web.mit.edu/bzbarsky/www/testcases/xmlhttprequest/base-uri-1.html shows that we use the base URI of the callee here, as do WebKit and Blink.
Last Resolved: 2 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.