Menu

#1681 History Object to implement pushState() and replaceState()

Latest SVN
closed
RBRi
None
1
2015-11-03
2015-05-03
CoronA
No

The methods pushState and replaceState are not implememented. This causes htmlunit to fail (infinite loop) on websites that use angularjs-routing.

Discussion

  • CoronA

    CoronA - 2015-05-04

    I am using 2.16. I cannot use a snapshot easily because at work access to snapshots is restricted. But I do not think that an empty implementation is sufficient.

    My scenario is very complex, so I won't be able to provide a test. Would the patch probably be related to only a few classes (e.g. both classes named History)?

     
  • Ahmed Ashour

    Ahmed Ashour - 2015-05-04
    • summary: History Object does not support Full HTML5 API --> History Object to implement pushState() and replaceState()
     
  • Adam Afeltowicz

    Adam Afeltowicz - 2015-09-06

    Minimal test case for angular-ui-router:
    - $locationProvider.html5Mode(false); aka hashbangMode works fine -> no JS exception, both routes rendered correctly
    - $locationProvider.html5Mode(true); -> mode utilizing html5 history api -> JS exceptions, first route displayed, second route (after goToPage2 anchor click) throws JS exception, but stays on previous route.

    Some info that I have gathered:
    - pushState have some similarities to "hash-driven routes" (see: https://developer.mozilla.org/en-US/docs/Web/API/History_API)
    - if HU will use naive pushState implementation setting location to passed url and will angular will have disabled throwing infdig through for example ScriptPreProcessor:

    public String preProcess(HtmlPage htmlPage, String sourceCode, String sourceName, int lineNumber,
            HtmlElement htmlElement) {
        int infdigIdx = sourceCode.indexOf("'infdig'");
        if (infdigIdx != -1) {
            int throwIdx = sourceCode.substring(0, infdigIdx).lastIndexOf("throw ");
            if (throwIdx != -1) {
                StringBuilder sb = new StringBuilder(sourceCode);
                sb.insert(throwIdx, "alert('angular infdig occured - ignoring exception');break;");
                sourceCode = sb.toString();
            }
        }
        return sourceCode;
    }
    

    second test case works. Although this is just workaround, maybe it will let someone to prepare fix.

     

    Last edit: Ahmed Ashour 2015-09-06
  • Adam Afeltowicz

    Adam Afeltowicz - 2015-09-26

    Please find in attachment html5 history api implementation (history.pushState, history.replaceState, history.state) and unit tests.

     
  • RBRi

    RBRi - 2015-09-27
    • status: open --> accepted
    • assigned_to: RBRi
     
  • RBRi

    RBRi - 2015-10-04
    • assigned_to: RBRi --> nobody
     
  • RBRi

    RBRi - 2015-10-04

    Sorry, but no time at the moment to merge in this stuff. Hopefully someone else can jump in...

     
  • Adam Afeltowicz

    Adam Afeltowicz - 2015-10-18

    Any possibility to go forward with this issue?

     
  • RBRi

    RBRi - 2015-10-18

    just back from vacation, will work on media queries the next days and then i like to finish this one

     
  • RBRi

    RBRi - 2015-11-03

    Changes are in SVN now. Many thanks for the patch (and youre patience).

     
  • RBRi

    RBRi - 2015-11-03
    • status: accepted --> closed
    • assigned_to: RBRi
     

Log in to post a comment.