Skip to content

React Native WebView onNavigationStateChange event value is incorrect on Android #14585

Closed
@fernandofranca

Description

@fernandofranca

Description

Setting document.title and window.location.hash triggers onNavigationStateChange but the values passed into onNavigationStateChange aren't the same.

This behaviour isn't consistent with a real device and the Expo simulator.

The wrong behaviour can also be seen on Android 5.0.0 Genymotion Simulator.

I've just opened the snack on my device and it has the expected behaviour.

This issue seems to be related to tooling. I dont't know which part of the tooling should be responsible.

Ex.:
Script on the WebView modifies document.title and window.location:

function updateHeight() {
    document.title = wrapper.clientHeight;
    window.location.hash = ++i;
}

Results for Android device:

{
title:"data:text/html; charset=utf-8,<body>...", 
url:"data:text/html; charset=utf-8,<body>..."
}

Reproduction Steps

Here: https://gist.github.com/epeli/10c77c1710dd137a1335

Sample Code

https://snack.expo.io/HkKOaHV7W

It must print a integer value below the WebView.

Note: Behaviour on simulator isn't consistent with a real device.

Additional Information

  • React Native version: react-native: 0.44.2
  • Platform: Android 6.0 and 5.0 (didn't tested on previous versions)
  • Development Operating System: macOS 10.12.4
  • Build tools: Xcode 8.3.3, Android Studio 2.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions