Skip to content

WebView history is wrong when second page is loaded using Ajax and the UserAgent has been modified #1701

@czuck

Description

@czuck

Steps to Reproduce

  1. Run the attached BackButtonTest app on a physical device running Android 5.0 or higher, which loads the JQueryMobile Navigation page . Scroll down and tap the link "To the homepage, with Ajax"
  2. Tap the hardware back button. You will see an alert that shows the history.length. It is 1, it should be 2. clear the alert. The page does not change back to the initial page. Quit the app.
  3. Run the app a second time, this time scroll down and tap the link "To the homepage, no Ajax". Tap the hardware back button. This time the alert displays 2, and upon clearing it the page will change back.
  4. Scroll to the "with Ajax" link and tap it, then tap the hardware back button. Now the history shows 2 and the page will change back.
  5. Stop the app and edit \BackButtonTest.Droid\CustomWebViewRenderer.cs and comment out line 41 which adds to the UserAgentString. Repeat steps 1 & 2, this time the history.length is 2 and the page does change back

BackButtonTest.zip

Expected Behavior

The back button should work the same in all cases.

Actual Behavior

The back button does not work when the UserAgentString is modified AND the page is loaded with Ajax.

Version Information

This works on a device running Android 4.4.2, but does not work on devices running Android 5.0 and above. According to the documentation, the Android Webview User Agent was changed for KitKat (4.4.4). I can not recreate the issue using my emulators, only physical devices. The version of Xamarin does not appear to affect the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions