Menu

#1628 Page not loaded if the URL ends with "#"

Latest SVN
closed
RBRi
None
1
2014-08-08
2014-07-29
No

In case the target URL of an anchor ends with "#" and the anchor is clicked, the target page is not loaded even though the URL of the current page is different from the target URL. If there is no hash or a proper hash ("#aaa"), everything works as expected. Test case attached.

The reason could be that HtmlAnchor gives a wrong hint to WebClient about whether or not we have a hash jump:

htmlPage.getWebClient().download(htmlPage.getEnclosingWindow(),
            htmlPage.getResolvedTarget(getTargetAttribute()),
            webRequest, href.endsWith("#"), "Link click");

Maybe the expression 'href.endsWith("#")' is not sufficient/correct.

Thanks,
J.

1 Attachments

Discussion

  • Hartmut Arlt

    Hartmut Arlt - 2014-07-29

    According to the JavaDoc of WebClient#download() regarding the parameter isHashJump:

    isHashJump 
        in at least one case (anchor url is '#') it is not possible to decide that this is only a hash jump; 
        in this case you can provide true here; otherwise use false
    

    the proper code in HtmlAnchor#doClickStateUpdate should read

    :::java
    htmlPage.getWebClient().download(htmlPage.getEnclosingWindow(),
            htmlPage.getResolvedTarget(getTargetAttribute()),
            webRequest, href.equals("#"), "Link click");
    

    instead of

    ::::java
    htmlPage.getWebClient().download(htmlPage.getEnclosingWindow(),
            htmlPage.getResolvedTarget(getTargetAttribute()),
            webRequest, href.endsWith("#"), "Link click");
    

    The "spec" defines the correct handling of fragment identifiers here at step 8.

     
  • RBRi

    RBRi - 2014-08-01
    • assigned_to: RBRi
     
  • RBRi

    RBRi - 2014-08-02

    Sch..., i really forgot this case while writing all the cases in PageReloadTest. Sorry for that.
    Interesting that nobody notice that during the last year.
    Fix is on the way, and as usual please review and report back.

     
  • RBRi

    RBRi - 2014-08-02
    • status: open --> pending
     
  • Joerg Werner

    Joerg Werner - 2014-08-04

    The test is green now, thanks.

    I have a couple of remarks regarding your changes:

    • In WebClient.download(): I believe, URL.sameFile() checks also the query part. Since the file part (including the query) must always be identical for a hash jump, the next line dealing with the query string is not necessary.
    • The spec says something about hash jumps are possible for GET only. Do we have to include this somehow when calculating justHashJump?
    • The JavaDoc of WebClient.download() states that it is not possible to detect an empty hash in a URL. I think it is, as URL.getRef() returns an empty string in this case. This may make the urlEndsWithHash parameter obsolete and simplifies the code.

    What do you think?

    Best,
    J.

     
  • RBRi

    RBRi - 2014-08-04

    I think it is, as URL.getRef() returns an empty string in this case.

    Seems like you are right here. The info about the empty ref is dropped somewhere else. Will try to fix this. Hopefully we can get rid of this nasty parameter.

    Will check your other points also.

     
  • RBRi

    RBRi - 2014-08-04

    Ok, updated version is in SVN. Please check

     
  • Joerg Werner

    Joerg Werner - 2014-08-05

    Looks really good. Cheers!

     
  • RBRi

    RBRi - 2014-08-05
    • status: pending --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB