Skip to content

Commit

Permalink
Improve URL handling so we display the correct url at the correct time (
Browse files Browse the repository at this point in the history
#531)

- Display correct url at the correct time to match user expectations and protect against phishing attacks.
- Fix issue where omnibar text from previous url could show on home screen
- Make extraction of website title hardier so that it is displayed correctly in tabs
  • Loading branch information
subsymbolic authored Jul 23, 2019
1 parent b14b872 commit 3796e32
Show file tree
Hide file tree
Showing 18 changed files with 680 additions and 489 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,46 +78,17 @@ class BrowserChromeClientTest {

@UiThreadTest
@Test
fun whenOnProgressChangedCalledThenListenerInstructedToUpdateProgressAndNavigationOptions() {
fun whenOnProgressChangedCalledThenListenerInstructedToUpdateProgress() {
testee.onProgressChanged(webView, 10)
verify(mockWebViewClientListener).progressChanged(webView.stubUrl, 10)
verify(mockWebViewClientListener).navigationOptionsChanged(any())
verify(mockWebViewClientListener).progressChanged(10)
}

@UiThreadTest
@Test
fun whenOnProgressChangedCalledButNoUrlChangeThenListenerInstructedToUpdateProgressASecondTime() {
webView.stubUrl = "foo.com"
fun whenOnProgressChangedCalledThenListenerInstructedToUpdateNavigationState() {
testee.onProgressChanged(webView, 10)
testee.onProgressChanged(webView, 20)
verify(mockWebViewClientListener, times(2)).progressChanged(any(), any())
verify(mockWebViewClientListener).navigationStateChanged(any())
}

@UiThreadTest
@Test
fun whenOnProgressChangedCalledAfterUrlChangeThenListenerInstructedToUpdateProgressAgain() {
webView.stubUrl = "foo.com"
testee.onProgressChanged(webView, 10)
testee.onProgressChanged(webView, 20)
webView.stubUrl = "bar.com"
testee.onProgressChanged(webView, 30)
verify(mockWebViewClientListener, times(3)).progressChanged(any(), any())
}

@UiThreadTest
@Test
fun whenOnProgressChangedCalledThenPassedOnToWebClient() {
val url = "https://example.com"
webView.stubUrl = url
testee.onProgressChanged(webView, 10)
verify(mockWebViewClientListener).progressChanged(url, 10)
}

private class TestWebView(context: Context) : WebView(context) {
var stubUrl: String = ""

override fun getUrl(): String {
return stubUrl
}
}
private class TestWebView(context: Context) : WebView(context)
}
Loading

0 comments on commit 3796e32

Please sign in to comment.