Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Merge #4249
Browse files Browse the repository at this point in the history
4249: Closes #4213: Use the social strict tracking protection list when the TrackingProtectionPolicy.strict() is set r=csadilek a=Amejia481



Co-authored-by: Arturo Mejia <arturomejiamarmol@gmail.com>
  • Loading branch information
MozLando and Amejia481 committed Sep 3, 2019
2 parents f81060b + 916e4b7 commit b0792c8
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ class GeckoEngine(
override var trackingProtectionPolicy: TrackingProtectionPolicy? = null
set(value) {
value?.let { policy ->
val activateStrictSocialTracking =
policy.trackingCategories.contains(TrackingProtectionPolicy.TrackingCategory.STRICT)
runtime.settings.contentBlocking.setStrictSocialTrackingProtection(
activateStrictSocialTracking
)
runtime.settings.contentBlocking.setAntiTracking(policy.trackingCategories.sumBy { it.id })
runtime.settings.contentBlocking.cookieBehavior = policy.cookiePolicy.id
defaultSettings?.trackingProtectionPolicy = value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import mozilla.components.support.test.argumentCaptor
import mozilla.components.support.test.eq
import mozilla.components.support.test.mock
import mozilla.components.support.test.whenever
import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
Expand Down Expand Up @@ -160,6 +161,32 @@ class GeckoEngineTest {
} catch (e: UnsupportedSettingException) { }
}

@Test
fun `WHEN a strict tracking protection policy is set 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.strict()

verify(mockRuntime.settings.contentBlocking).setStrictSocialTrackingProtection(true)
}

@Test
fun `WHEN a non strict tracking protection policy is set 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.recommended()

verify(mockRuntime.settings.contentBlocking).setStrictSocialTrackingProtection(false)
}

@Test
fun defaultSettings() {
val runtime = mock<GeckoRuntime>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ class GeckoEngine(
override var trackingProtectionPolicy: TrackingProtectionPolicy? = null
set(value) {
value?.let { policy ->
val activateStrictSocialTracking =
policy.trackingCategories.contains(TrackingProtectionPolicy.TrackingCategory.STRICT)
runtime.settings.contentBlocking.setStrictSocialTrackingProtection(
activateStrictSocialTracking
)
runtime.settings.contentBlocking.setAntiTracking(policy.trackingCategories.sumBy { it.id })
runtime.settings.contentBlocking.cookieBehavior = policy.cookiePolicy.id
defaultSettings?.trackingProtectionPolicy = value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import mozilla.components.support.test.any
import mozilla.components.support.test.argumentCaptor
import mozilla.components.support.test.eq
import mozilla.components.support.test.mock
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.whenever
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
Expand Down Expand Up @@ -160,6 +161,32 @@ class GeckoEngineTest {
} catch (e: UnsupportedSettingException) { }
}

@Test
fun `WHEN a strict tracking protection policy is set 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.strict()

verify(mockRuntime.settings.contentBlocking).setStrictSocialTrackingProtection(true)
}

@Test
fun `WHEN a non strict tracking protection policy is set 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.recommended()

verify(mockRuntime.settings.contentBlocking).setStrictSocialTrackingProtection(false)
}

@Test
fun defaultSettings() {
val runtime = mock<GeckoRuntime>()
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ permalink: /changelog/
)
```

* **browser-engine-gecko-nightly** and **browser-engine-gecko-beta**
* The `TrackingProtectionPolicy.strict()` now blocks trackers from the social-tracking-protection-digest256 list, for more details take a look at the [issue #4213](https://github.com/mozilla-mobile/android-components/issues/4213)

# 11.0.0

* [Commits](https://github.com/mozilla-mobile/android-components/compare/v10.0.0...v11.0.0)
Expand Down

0 comments on commit b0792c8

Please sign in to comment.