Commit 427f0450 authored by Arturo Mejia's avatar Arturo Mejia
Browse files

Closes #4320: Add api to indicate if strict social tracking protection

should be activated.
parent 5e27953c
......@@ -169,7 +169,10 @@ class GeckoEngine(
set(value) {
value?.let { policy ->
val activateStrictSocialTracking =
policy.trackingCategories.contains(TrackingProtectionPolicy.TrackingCategory.STRICT)
policy.strictSocialTrackingProtection ?: policy.trackingCategories.contains(
TrackingProtectionPolicy.TrackingCategory.STRICT
)
runtime.settings.contentBlocking.setStrictSocialTrackingProtection(
activateStrictSocialTracking
)
......
......@@ -187,6 +187,36 @@ class GeckoEngineTest {
verify(mockRuntime.settings.contentBlocking).setStrictSocialTrackingProtection(false)
}
@Test
fun `WHEN strict social tracking protection is set to true THEN the strict social list must be activated`() {
val mockRuntime = mock<GeckoRuntime>()
whenever(mockRuntime.settings).thenReturn(mock())
whenever(mockRuntime.settings.contentBlocking).thenReturn(mock())
val engine = GeckoEngine(testContext, runtime = mockRuntime)
engine.settings.trackingProtectionPolicy = TrackingProtectionPolicy.select(
strictSocialTrackingProtection = true
)
verify(mockRuntime.settings.contentBlocking).setStrictSocialTrackingProtection(true)
}
@Test
fun `WHEN strict social tracking protection is set to false THEN the strict social list must be disabled`() {
val mockRuntime = mock<GeckoRuntime>()
whenever(mockRuntime.settings).thenReturn(mock())
whenever(mockRuntime.settings.contentBlocking).thenReturn(mock())
val engine = GeckoEngine(testContext, runtime = mockRuntime)
engine.settings.trackingProtectionPolicy = TrackingProtectionPolicy.select(
strictSocialTrackingProtection = false
)
verify(mockRuntime.settings.contentBlocking).setStrictSocialTrackingProtection(false)
}
@Test
fun defaultSettings() {
val runtime = mock<GeckoRuntime>()
......
......@@ -169,7 +169,10 @@ class GeckoEngine(
set(value) {
value?.let { policy ->
val activateStrictSocialTracking =
policy.trackingCategories.contains(TrackingProtectionPolicy.TrackingCategory.STRICT)
policy.strictSocialTrackingProtection ?: policy.trackingCategories.contains(
TrackingProtectionPolicy.TrackingCategory.STRICT
)
runtime.settings.contentBlocking.setStrictSocialTrackingProtection(
activateStrictSocialTracking
)
......
......@@ -187,6 +187,36 @@ class GeckoEngineTest {
verify(mockRuntime.settings.contentBlocking).setStrictSocialTrackingProtection(false)
}
@Test
fun `WHEN strict social tracking protection is set to true THEN the strict social list must be activated`() {
val mockRuntime = mock<GeckoRuntime>()
whenever(mockRuntime.settings).thenReturn(mock())
whenever(mockRuntime.settings.contentBlocking).thenReturn(mock())
val engine = GeckoEngine(testContext, runtime = mockRuntime)
engine.settings.trackingProtectionPolicy = TrackingProtectionPolicy.select(
strictSocialTrackingProtection = true
)
verify(mockRuntime.settings.contentBlocking).setStrictSocialTrackingProtection(true)
}
@Test
fun `WHEN strict social tracking protection is set to false THEN the strict social list must be disabled`() {
val mockRuntime = mock<GeckoRuntime>()
whenever(mockRuntime.settings).thenReturn(mock())
whenever(mockRuntime.settings.contentBlocking).thenReturn(mock())
val engine = GeckoEngine(testContext, runtime = mockRuntime)
engine.settings.trackingProtectionPolicy = TrackingProtectionPolicy.select(
strictSocialTrackingProtection = false
)
verify(mockRuntime.settings.contentBlocking).setStrictSocialTrackingProtection(false)
}
@Test
fun defaultSettings() {
val runtime = mock<GeckoRuntime>()
......
......@@ -130,7 +130,8 @@ abstract class EngineSession(
val trackingCategories: Array<TrackingCategory> = arrayOf(TrackingCategory.RECOMMENDED),
val useForPrivateSessions: Boolean = true,
val useForRegularSessions: Boolean = true,
val cookiePolicy: CookiePolicy = ACCEPT_NON_TRACKERS
val cookiePolicy: CookiePolicy = ACCEPT_NON_TRACKERS,
val strictSocialTrackingProtection: Boolean? = null
) {
/**
......@@ -248,10 +249,12 @@ abstract class EngineSession(
fun select(
trackingCategories: Array<TrackingCategory> = arrayOf(TrackingCategory.RECOMMENDED),
cookiePolicy: CookiePolicy = ACCEPT_NON_TRACKERS
cookiePolicy: CookiePolicy = ACCEPT_NON_TRACKERS,
strictSocialTrackingProtection: Boolean? = null
) = TrackingProtectionPolicyForSessionTypes(
trackingCategories,
cookiePolicy
cookiePolicy,
strictSocialTrackingProtection
)
}
......@@ -276,10 +279,12 @@ abstract class EngineSession(
*/
class TrackingProtectionPolicyForSessionTypes internal constructor(
trackingCategory: Array<TrackingCategory> = arrayOf(TrackingCategory.RECOMMENDED),
cookiePolicy: CookiePolicy = ACCEPT_NON_TRACKERS
cookiePolicy: CookiePolicy = ACCEPT_NON_TRACKERS,
strictSocialTrackingProtection: Boolean? = null
) : TrackingProtectionPolicy(
trackingCategories = trackingCategory,
cookiePolicy = cookiePolicy
cookiePolicy = cookiePolicy,
strictSocialTrackingProtection = strictSocialTrackingProtection
) {
/**
* Marks this policy to be used for private sessions only.
......
......@@ -12,6 +12,14 @@ permalink: /changelog/
* [Gecko](https://github.com/mozilla-mobile/android-components/blob/master/buildSrc/src/main/java/Gecko.kt)
* [Configuration](https://github.com/mozilla-mobile/android-components/blob/master/buildSrc/src/main/java/Config.kt)
* **browser-engine-gecko-nightly** and **browser-engine-gecko-beta**
* The `TrackingProtectionPolicy.select` function now allows you to indicate if `strictSocialTrackingProtection` should be activated or not. When it is active blocks trackers from the social-tracking-protection-digest256 list, for more details take a look at the [issue #4320](https://github.com/mozilla-mobile/android-components/issues/4320)
```kotlin
val policy = TrackingProtectionPolicy.select(
strictSocialTrackingProtection = true
)
```
* **browser-engine-gecko**, **browser-engine-gecko-beta**, **browser-engine-gecko-nightly**
* **Merge day!**
* `browser-engine-gecko-release`: GeckoView 69.0
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment