Menu

#399 window.open("", "myOldWin") shouldn't clear myOldWin

Latest SVN
closed
None
7
2012-10-21
2006-11-08
No

var myWin = window.open("","existing_window") in IE
compatibility mode changes the URL to "about:blank"
(...javascript.host.Window.makeUrlForOpenWindow)
which causes the already-existing window's content to
be replaced, yet this is the standard JS code used
when the user is only trying to get a reference to an
existing window or frame without changing it.

For example, if you open a window with a URL that
defines the function blah(), then later do the above
code to get a reference to the window, you are
supposed to be able to use that reference to execute
myWin.blah(). In IE compatibility mode in HTML Unit
you get an error that "blah" is null.

I don't know what the exact patch should be, but it
seems that the code needs to recognize when it FINDS
the window already open vs. when it CREATED the
window to decide if it should change the URL.

WORKAROUND that I'm using right now: set the
BrowserVersion's appname to Netscape before code that
executes that, then change it back. - this could
affect more than that, though.

Watch out for #1584437 which is an extension of the
current about:blank url replacement.

Discussion

  • David Blackledge

    Logged In: YES
    user_id=1639252

    (this is the case in 1.9 and apparently 1.10, too)

     
  • David Blackledge

    Logged In: YES
    user_id=1639252
    Originator: YES

    attaching two html files and one JUnit Test

     
  • David Blackledge

    starting web page

     
  • David Blackledge

    popup page

     
  • David Blackledge

    JUnit Test for html files

     
  • Marc Guillemot

    Marc Guillemot - 2006-11-21

    Logged In: YES
    user_id=402164
    Originator: NO

    Now fixed in SVN.

    PS: thanks for the unit test but please have a look at existing htmlunit tests to provide ready to integrate tests ;-)

     

Log in to post a comment.