Closed Bug 469122 Opened 16 years ago Closed 16 years ago

doing document.write() in documents loaded from file:// changes the location

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 445004

People

(Reporter: amnonaar, Unassigned)

References

(Depends on 1 open bug)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5

Doing document.write() in any document loaded from a local directory will change the location to first document loaded from that directory, until another page is visited in the same tab.



Reproducible: Always

Steps to Reproduce:

1. Visit any file in a directory on disk
2. Then immediately visit another file *in the same directory*
3. do a "document.write" in the new file after it's loaded, e.g. by entering 
javascript:document.write("test");document.close();
in the address bar.
4. The write succeeds, but additionally the location changes to the first opened file. This is visible both in the address bar and using document.location.
5. visit an http site in the same tab, then repeat steps 2-3 to see that this time the location stays the same
Amnon, is this a regression from 3.0.4?
I don't know. However, I believe this is a regression from version 2.
This is quite likely due to the fix for bug 230606 (or related), a behavior change in Firefox 3. In order to keep related files able to access each other, but not work their way around your disk, we need to remember the starting point. When you document.write() in a loaded document you're starting a brand-new document, and if it's going to still access the same documents as the original then it needs to pick up the original location.

For documents in the same directory it maybe doesn't make much difference, but if the second document you opened was in a subfolder then if the location changed that new document would no longer be able to access the document which opened it.
This was fixed in bug 445004.  The fix is waiting for 1.9.0.6 approval, and if that's granted it will be fixed in Firefox 3.0.6.

We should probably write a test for this, though (and maybe for the file:// aspects of bug 445004).  Need file:// mochitests.
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Depends on: 424484
Flags: in-testsuite?
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.