Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow updating history in WebView async. #5654

Merged
merged 2 commits into from May 27, 2020
Merged

Conversation

copybara-robolectric
Copy link
Contributor

Allow updating history in WebView async.

WebView does not update its history inline when loadUrl() is called. It goes into a "navigation" which can be dropped or "committed". When a navigation is "committed" it is then pushed into the history.

We cannot just change this behaviour directly as that would break a lot of existing tests. Instead we allow simulating the async behaviour with a boolean flag. This should not change anything semantically unless opted-in.

WebView does not update its history inline when loadUrl() is called. It starts a "navigation" which might or might not "commit" (i.e. decide to show something to the user). For example, a gen204 request never commits, calling loadUrl() with such a request would never "commit" to the history. Or two loadUrl() calls can be made immediately after one another, in which case the first is never committed as it is dropped. This commit always happens async and never inline. As such, ShadowWebView behaviour is inconsistent with the prod behaviour.

Introducing pushEntryToHistory() API allows this commit to be performed asynchronously when requested. This API also takes a URL, which does not have to be the same as the one in loadUrl() as there might have been e.g. server-side redirects until the page is committed. Though if the URL does not go through any changes the caller can also perform pushEntryToHistory(webView.getUrl()).

This API can also be used without an associated loadUrl() call to simulate a renderer-initiated navigation, such as when the user-clicks on a link.

PiperOrigin-RevId: 311727608
@brettchabot brettchabot merged commit 7e933ef into master May 27, 2020
@brettchabot brettchabot deleted the piper_311727608 branch May 27, 2020 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants