diff --git a/ios/brave-ios/Sources/Brave/Frontend/UserContent/UserScripts/Scripts_Dynamic/Scripts/Sandboxed/SelectorsPollerScript.js b/ios/brave-ios/Sources/Brave/Frontend/UserContent/UserScripts/Scripts_Dynamic/Scripts/Sandboxed/SelectorsPollerScript.js
index 4a79fb6cf25b..6516a8720ba1 100644
--- a/ios/brave-ios/Sources/Brave/Frontend/UserContent/UserScripts/Scripts_Dynamic/Scripts/Sandboxed/SelectorsPollerScript.js
+++ b/ios/brave-ios/Sources/Brave/Frontend/UserContent/UserScripts/Scripts_Dynamic/Scripts/Sandboxed/SelectorsPollerScript.js
@@ -564,6 +564,10 @@ window.__firefox__.execute(function($) {
return false
} else if (queryResults.foundFirstPartyResource) {
return true
+ } else if (showsSignificantText(element)) {
+ // If the subtree HAS a significant amount of text (e.g., it doesn't just says "Advertisement")
+ // it should be unhidden.
+ return true
} else if (queryResults.foundThirdPartyResource || queryResults.pendingSrcAttributes.size > 0) {
if (pendingSrcAttributes !== undefined) {
queryResults.pendingSrcAttributes.forEach((src) => {
@@ -572,12 +576,8 @@ window.__firefox__.execute(function($) {
}
return false
- } else {
- // If the subtree doesn't have a significant amount of text (e.g., it
- // just says "Advertisement"), then no need to change anything; it should
- // stay hidden.
- return showsSignificantText(element)
}
+ return false
}
const shouldUnhideElementAsync = async (element) => {
diff --git a/ios/brave-ios/Tests/ClientTests/Resources/html/index.html b/ios/brave-ios/Tests/ClientTests/Resources/html/index.html
index 9850369aa42a..39f812877bb3 100644
--- a/ios/brave-ios/Tests/ClientTests/Resources/html/index.html
+++ b/ios/brave-ios/Tests/ClientTests/Resources/html/index.html
@@ -27,7 +27,12 @@
Test Ads
- This element should be always hidden (standard or aggressive mode) because it's a 3rd party ad.
+
+
+
+
+ This element should be not be hidden in standard mode because it contains significant amount of text.
+ It should still be hidden in aggressive mode.
diff --git a/ios/brave-ios/Tests/ClientTests/User Scripts/ScriptExecutionTests.swift b/ios/brave-ios/Tests/ClientTests/User Scripts/ScriptExecutionTests.swift
index a0fab7241dd0..b0c1b0f037e8 100644
--- a/ios/brave-ios/Tests/ClientTests/User Scripts/ScriptExecutionTests.swift
+++ b/ios/brave-ios/Tests/ClientTests/User Scripts/ScriptExecutionTests.swift
@@ -224,7 +224,9 @@ final class ScriptExecutionTests: XCTestCase {
let initialStandardSelectors = Set([".test-ads-primary-standard div"])
let initialAggressiveSelectors = Set([".test-ads-primary-aggressive div"])
let polledAggressiveIds = ["test-ad-aggressive"]
- let polledStandardIds = ["test-ad-1st-party", "test-ad-3rd-party", "test-ad-simple"]
+ let polledStandardIds = [
+ "test-ad-1st-party", "test-ad-3rd-party", "test-ad-3rd-party-sig-text", "test-ad-simple",
+ ]
let nestedIds = [
"test-ad-primary-standard-1st-party", "test-ad-primary-standard-3rd-party",
"test-ad-primary-aggressive-1st-party", "test-ad-primary-aggressive-3rd-party",
@@ -378,7 +380,10 @@ final class ScriptExecutionTests: XCTestCase {
)
XCTAssertEqual(resultsAfterPump?.unhiddenIds.contains("test-ad-1st-party"), true)
XCTAssertEqual(resultsAfterPump?.hiddenIds.contains("test-ad-aggressive"), true)
+ // hidden because of 3rd party src
XCTAssertEqual(resultsAfterPump?.hiddenIds.contains("test-ad-3rd-party"), true)
+ // unhidden because it contains significant amount of text
+ XCTAssertEqual(resultsAfterPump?.unhiddenIds.contains("test-ad-3rd-party-sig-text"), true)
XCTAssertEqual(resultsAfterPump?.hiddenIds.contains("test-ad-simple"), true)
XCTAssertEqual(
resultsAfterPump?.hiddenIds.contains("test-ad-primary-aggressive-1st-party"),