Skip to content

Commit

Permalink
Fix brave/brave-ios#7403: Fix ServerTrust notification to update the …
Browse files Browse the repository at this point in the history
…URL bar (brave/brave-ios#7420)

Server Trust does not post a notification if the trust itself hasn't changed. Problem is that the trust on NTP is the same as on an HTTP site. So visiting an HTTP site takes the same trust as on NTP, which is wrong. To fix this, we post a notification ourselves to let us know that the URL changed but the trust stayed the same.
This in turn causes the revalidation to happen.
  • Loading branch information
Brandon-T authored May 9, 2023
1 parent 43c7123 commit 04d8d8e
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,16 @@ extension BrowserViewController: WKNavigationDelegate {
// Set the committed url which will also set tab.url
tab.committedURL = webView.url

DispatchQueue.main.async {
// Server Trust and URL is also updated in didCommit
// However, WebKit does NOT trigger the `serverTrust` observer when the URL changes, but the trust has not.
// So manually trigger it with the current trust.
self.observeValue(forKeyPath: KVOConstants.serverTrust.rawValue,
of: webView,
change: [.newKey: webView.serverTrust, .kindKey: 1],
context: nil)
}

// Need to evaluate Night mode script injection after url is set inside the Tab
tab.nightMode = Preferences.General.nightModeEnabled.value
tab.clearSolanaConnectedAccounts()
Expand Down

0 comments on commit 04d8d8e

Please sign in to comment.