Commit 52de7118 authored by MozLando's avatar MozLando
Browse files

Merge #6080



6080: Closes #6079: Add strictSocialTrackingProtection on SessionTypes PrivateOnly and RegularOnly  r=Amejia481 a=Baron-Severin
Co-authored-by: default avatarSeverin Rudie <srudie@mozilla.com>
parents 8770a166 81b405ca
......@@ -42,6 +42,7 @@ dependencies {
testImplementation Dependencies.androidx_test_junit
testImplementation Dependencies.testing_robolectric
testImplementation Dependencies.testing_mockito
testImplementation Dependencies.kotlin_reflect
testImplementation project(':support-test')
}
......
......@@ -345,7 +345,8 @@ abstract class EngineSession(
trackingCategories = trackingCategories,
useForPrivateSessions = true,
useForRegularSessions = false,
cookiePolicy = cookiePolicy
cookiePolicy = cookiePolicy,
strictSocialTrackingProtection = strictSocialTrackingProtection
)
/**
......@@ -355,7 +356,8 @@ abstract class EngineSession(
trackingCategories = trackingCategories,
useForPrivateSessions = false,
useForRegularSessions = true,
cookiePolicy = cookiePolicy
cookiePolicy = cookiePolicy,
strictSocialTrackingProtection = strictSocialTrackingProtection
)
}
......
......@@ -25,6 +25,7 @@ import org.mockito.Mockito.verifyNoMoreInteractions
import org.mockito.Mockito.verifyZeroInteractions
import mozilla.components.concept.engine.EngineSession.TrackingProtectionPolicy.TrackingCategory
import mozilla.components.concept.engine.EngineSession.TrackingProtectionPolicy.CookiePolicy
import java.lang.reflect.Modifier
class EngineSessionTest {
private val unknownHitResult = HitResult.UNKNOWN("file://foobar")
......@@ -691,6 +692,38 @@ class EngineSessionTest {
assertTrue(strictPolicy.contains(TrackingCategory.CRYPTOMINING))
assertFalse(strictPolicy.contains(TrackingCategory.CONTENT))
}
@Test
fun `TrackingSessionPolicies retain all expected fields during privacy transformations`() {
val strict = TrackingProtectionPolicy.strict()
val default = TrackingProtectionPolicy.recommended()
val custom = TrackingProtectionPolicy.select(
trackingCategories = emptyArray(),
cookiePolicy = CookiePolicy.ACCEPT_ONLY_FIRST_PARTY,
strictSocialTrackingProtection = true
)
val changedFields = listOf("useForPrivateSessions", "useForRegularSessions")
fun checkSavedFields(expect: TrackingProtectionPolicy, actual: TrackingProtectionPolicy) {
TrackingProtectionPolicy::class.java.declaredMethods
.filter { method -> changedFields.all { !method.name.toLowerCase().contains(it.toLowerCase()) } }
.filter { it.parameterCount == 0 } // Only keep getters
.filter { it.modifiers and Modifier.PUBLIC != 0 }
.filter { it.modifiers and Modifier.STATIC == 0 }
.forEach {
assertEquals(it.invoke(expect), it.invoke(actual))
}
}
listOf(
strict,
default,
custom
).forEach {
checkSavedFields(it, it.forPrivateSessionsOnly())
checkSavedFields(it, it.forRegularSessionsOnly())
}
}
}
open class DummyEngineSession : EngineSession() {
......
......@@ -74,6 +74,7 @@ permalink: /changelog/
* **concept-engine**
* ⚠️ **This is a breaking change**: remove deprecated GeckoView setting `allowAutoplayMedia`
* This should now be controlled for individual sites via `SitePermissionsRules`
* Fixed a bug that would cause `TrackingProtectionPolicyForSessionTypes` to lose some information during transformations.
* **feature-downloads**
* ⚠️ **This is a breaking change**: `customTabId` is renamed to `tabId`.
......
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