Closed Bug 308667 Opened 19 years ago Closed 14 years ago

child window, when using document.open, document.write, document.close cannot access parent window

Categories

(Core :: Security, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: ferrigno_lou, Assigned: dveditz)

References

()

Details

(Keywords: testcase)

Attachments

(1 file)

User-Agent:       Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
Build Identifier: Firefox 1.06

when javascript is used to create a new window, then the code opens the 
document in the child window (newWindow.document.open()) to write html to it 
(newWindow.document.write(someContent)) and then close the child window 
document (newWindow.document.close()), the child window cannot access anything 
in the parent window.  Javascript variables, form fields, etc are all denied 
and the Javascript console gives the following error (when I try to set a form 
field value in the parent from the child):

Error:  uncaugh exception: Permission denied to get property HTMLDocument.forms


Reproducible: Always

Steps to Reproduce:
1. create a child window from javascript
2. open and close the child window's document
3. try to use javascript in the child to access the parent

Actual Results:  
Error:  uncaugh exception: Permission denied [to get x property]

Expected Results:  
it should have allowed me to get get/set the property in question.
I  have 2 other test html pages for this bug:

http://pluto.mindedge.com/firefox_window.opener_test2.html
 - opens a pre-existing html page and _doesn't_ modify the child doc from the 
parent with document.open (works fine)

http://pluto.mindedge.com/firefox_window.opener_test_blankhtml.html
 - opens a pre-existing blank html page and modifies the child doc from the 
parent with document.open.  (error thrown)

When the child window pops up, the "finished" button, when clicked, will first 
try to get the value of the textarea in the parent window and show this value 
in an alert(), then set the value of the parent window's textarea with the 
value of the child window's textarea.
Could you check this perhaps with the latest nightly trunk build?
http://ftp.scarlet.be/pub/mozilla.org/firefox/nightly/latest-trunk/
(In reply to comment #2)
> Could you check this perhaps with the latest nightly trunk build?
> http://ftp.scarlet.be/pub/mozilla.org/firefox/nightly/latest-trunk/

just downloaded and installed it.  Same error thrown.
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8b4) Gecko/20050915
Firefox/1.4 ID:2005091504

when trying local i get:

Security Error: Content at wyciwyg://1/file:///C:/testdir/test.html may not load
or link to file:///C:/testdir/test.html.

when the popup is opened.

Summary: chiild window, when using document.open, document.write, document.close cannot access parent window → child window, when using document.open, document.write, document.close cannot access parent window
test cases created from http://pluto.mindedge.com/firefox_window.opener_test.html    

Lou, 
test case also have work arround for this issue.
funny test_permission.html wont give error when attached
to https://bugzilla.mozilla.org/
Assignee: nobody → dveditz
Component: General → Security
Keywords: testcase
Product: Firefox → Core
QA Contact: general → toolkit
Version: unspecified → Trunk
well, the popup window and the script which initiated it must be in the
same domain. (for eg). when you have a html file in "c:\sample.htm",
from which you popup "http://localhost/canvas.html", you cannot access
its properties. Its a security thing that browsers have implemented.

i tried myself and it worked
Resolving unconfirmed bugs older than a year with no activity as INCOMPLETE.  Please reopen or file a new bug if you can still reproduce the bug.
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: