[ htmlunit-Bugs-1210759 ] HtmlUnit doesn't allow JavaScriptURL inside document.write()

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ htmlunit-Bugs-1210759 ] HtmlUnit doesn't allow JavaScriptURL inside document.write()

SourceForge.net
Bugs item #1210759, was opened at 2005-05-29 14:28
Message generated for change (Comment added) made by mguillem
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=448266&aid=1210759&group_id=47038

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: xingj (xingj)
>Assigned to: Marc Guillemot (mguillem)
Summary: HtmlUnit doesn't allow JavaScriptURL inside document.write()

Initial Comment:
To enable that, I have to turn the Javascript engine on

in WebClient.java
===============

    private WebResponse
makeWebResponseForJavaScriptUrl( final WebWindow
webWindow, final URL url ) {
        if (!(webWindow instanceof
BaseFrame.FrameWindow)) {
            throw new IllegalArgumentException(
                "javascript urls can only be used to load
content into frames and iframes");
        }

        final BaseFrame.FrameWindow frameWindow =
(BaseFrame.FrameWindow) webWindow;
        final HtmlPage enclosingPage =
frameWindow.getEnclosingPage();

        // ************************
        //    Patch part 1
        // ************************

        boolean bIsJavaScriptEnabled =
this.isJavaScriptEnabled();
        this.setJavaScriptEnabled(true);

        // end of patch part 1

        final ScriptResult scriptResult =
enclosingPage.executeJavaScriptIfPossible(
            url.toExternalForm(), "javascript url", false, null );

        // ************************
        //    Patch part 2
        // ************************

        this.setJavaScriptEnabled(bIsJavaScriptEnabled);

        // end of patch part 2

        final String contentString =
scriptResult.getJavaScriptResult().toString();
        return new StringWebResponse(contentString);
    }


----------------------------------------------------------------------

>Comment By: Marc Guillemot (mguillem)
Date: 2006-09-17 16:34

Message:
Logged In: YES
user_id=402164

No feedback provided since too long time. Please reopen if
you can provide requested information.

----------------------------------------------------------------------

Comment By: Marc Guillemot (mguillem)
Date: 2005-11-16 11:36

Message:
Logged In: YES
user_id=402164

The provided unit test doesn't seem to show anything: as
there  is no test I guess that it should throw, but it is
not the case.

----------------------------------------------------------------------

Comment By: mkillow (mkillow)
Date: 2005-11-15 22:57

Message:
Logged In: YES
user_id=1267197

What is the current status on this bug? Has a developer
had a chance to have a look into the cause/fix?   Thanks

----------------------------------------------------------------------

Comment By: sheldong (sheldong)
Date: 2005-10-13 00:27

Message:
Logged In: YES
user_id=1075416

The fix described does fix a few issues related to this
problem. A problem in 1.7 remains where the ScriptObject
associated with the Window passed into the executejavascript
function is null. This produces a null pointer exception.

The HTML works fine in IE and FF.

Thanks.

Here is the Unit Test:

            public void testJavascriptURL1210759() throws Exception {

                final String htmlContent =
                        "<html>"
                        + "<head>"
                        + "<script>\n"
                        + "function empty(){\n"
                        + " return  \"<html><body> </body></html>\";\n"
                        + "}\n"
                        + "</script>\n"
                        + "</head>\n"
                        + "<body>\n"
                        + "<script>\n"
                        + "  document.write('<iframe
src=\"javascript:parent.empty();\" width=\"200\"
height=\"200\"></iframe>');\n"
                        + "</script>\n"
                       
                        + "<iframe src=\"javascript:parent.empty();\"
width=\"100\" height=\"100\"></iframe>"
                        + "</body></html>";

                final HtmlPage page = loadPage(htmlContent);

            }

----------------------------------------------------------------------

Comment By: Marc Guillemot (mguillem)
Date: 2005-09-20 17:41

Message:
Logged In: YES
user_id=402164

Can you provide some precision? A unit test?

Your fix proposition is strange: why should javascript be
temporarily enabled?

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=448266&aid=1210759&group_id=47038

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
HtmlUnit-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop