Skip to content

Commit

Permalink
Fix brave/brave-ios#8585 - Fix Javascript Disabling <NoScript> (brave…
Browse files Browse the repository at this point in the history
…/brave-ios#8586)

- Fix Javascript Disabling not working
  • Loading branch information
Brandon-T authored Jan 4, 2024
1 parent 73af832 commit 3391257
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,18 @@ extension BrowserViewController: WKNavigationDelegate {
if let documentTargetURL = documentTargetURL {
let domainForShields = Domain.getOrCreate(forUrl: documentTargetURL, persistent: !isPrivateBrowsing)
let isScriptsEnabled = !domainForShields.isShieldExpected(.NoScript, considerAllShieldsOption: true)

// Due to a bug in iOS WKWebpagePreferences.allowsContentJavaScript does NOT work!
// https://github.com/brave/brave-ios/issues/8585
//
// However, the deprecated API WKWebViewConfiguration.preferences.javaScriptEnabled DOES work!
// Even though `configuration` is @NSCopying, somehow this actually updates the preferences LIVE!!
// This follows the same behaviour as Safari
//
// - Brandon T.
//
preferences.allowsContentJavaScript = isScriptsEnabled
webView.configuration.preferences.javaScriptEnabled = isScriptsEnabled
}

// Cookie Blocking code below
Expand Down

0 comments on commit 3391257

Please sign in to comment.