Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Fix #8585 - Fix Javascript Disabling <NoScript> #8586

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
kylehickinson marked this conversation as resolved.
Show resolved Hide resolved
}

// Cookie Blocking code below
Expand Down