Commit a11355ce authored by Arturo Mejia's avatar Arturo Mejia
Browse files

Closes #6917: Remove unused manual disabling of tracking protection

parent 6355e734
Loading
Loading
Loading
Loading
+2 −15
Original line number Diff line number Diff line
@@ -196,10 +196,7 @@ class GeckoEngineSession(
        val shouldBlockContent =
            policy.contains(TrackingProtectionPolicy.TrackingCategory.SCRIPTS_AND_SUB_RESOURCES)

        geckoSession.settings.useTrackingProtection = shouldBlockContent
        if (!enabled) {
            disableTrackingProtectionOnGecko()
        }
        geckoSession.settings.useTrackingProtection = shouldBlockContent && enabled
        notifyAtLeastOneObserver { onTrackerBlockingEnabledChange(enabled) }
    }

@@ -207,7 +204,7 @@ class GeckoEngineSession(
     * See [EngineSession.disableTrackingProtection]
     */
    override fun disableTrackingProtection() {
        disableTrackingProtectionOnGecko()
        geckoSession.settings.useTrackingProtection = false
        notifyObservers { onTrackerBlockingEnabledChange(false) }
    }

@@ -226,16 +223,6 @@ class GeckoEngineSession(
        }
    }

    // To fully disable tracking protection we need to change the different tracking protection
    // variables to none.
    private fun disableTrackingProtectionOnGecko() {
        geckoSession.settings.useTrackingProtection = false
        runtime.settings.contentBlocking.setAntiTracking(ContentBlocking.AntiTracking.NONE)
        runtime.settings.contentBlocking.cookieBehavior = ContentBlocking.CookieBehavior.ACCEPT_ALL
        runtime.settings.contentBlocking.setStrictSocialTrackingProtection(false)
        runtime.settings.contentBlocking.setEnhancedTrackingProtectionLevel(ContentBlocking.EtpLevel.NONE)
    }

    /**
     * See [EngineSession.settings]
     */
+0 −22
Original line number Diff line number Diff line
@@ -1050,10 +1050,6 @@ class GeckoEngineSessionTest {
        engineSession.disableTrackingProtection()
        assertTrue(trackerBlockingDisabledObserved)
        assertFalse(engineSession.geckoSession.settings.useTrackingProtection)
        verify(runtime.settings.contentBlocking).setAntiTracking(ContentBlocking.AntiTracking.NONE)
        verify(runtime.settings.contentBlocking).setCookieBehavior(GeckoCookieBehavior.ACCEPT_ALL)
        verify(runtime.settings.contentBlocking).setStrictSocialTrackingProtection(false)
        verify(runtime.settings.contentBlocking).setEnhancedTrackingProtectionLevel(ContentBlocking.EtpLevel.NONE)
    }

    @Test
@@ -1533,24 +1529,6 @@ class GeckoEngineSessionTest {
        verify(geckoSession.settings).useTrackingProtection = false
    }

    @Test
    fun `WHEN disabling tracking protection THEN CookieBehavior and AntiTracking category must be set to ACCEPT_ALL and NONE`() {
        whenever(runtime.settings.contentBlocking).thenReturn(mock())

        val defaultSettings =
            DefaultSettings(trackingProtectionPolicy = TrackingProtectionPolicy.recommended())

        val session = GeckoEngineSession(
            runtime, geckoSessionProvider = geckoSessionProvider,
            privateMode = false, defaultSettings = defaultSettings
        )

        session.disableTrackingProtection()
        verify(geckoSession.settings, times(2)).useTrackingProtection = false
        verify(runtime.settings.contentBlocking).setAntiTracking(ContentBlocking.AntiTracking.NONE)
        verify(runtime.settings.contentBlocking).setCookieBehavior(ContentBlocking.CookieBehavior.ACCEPT_ALL)
    }

    @Test
    fun contentDelegate() {
        val engineSession = GeckoEngineSession(mock(),
+2 −15
Original line number Diff line number Diff line
@@ -197,10 +197,7 @@ class GeckoEngineSession(
        val shouldBlockContent =
            policy.contains(TrackingProtectionPolicy.TrackingCategory.SCRIPTS_AND_SUB_RESOURCES)

        geckoSession.settings.useTrackingProtection = shouldBlockContent
        if (!enabled) {
            disableTrackingProtectionOnGecko()
        }
        geckoSession.settings.useTrackingProtection = shouldBlockContent && enabled
        notifyAtLeastOneObserver { onTrackerBlockingEnabledChange(enabled) }
    }

@@ -208,7 +205,7 @@ class GeckoEngineSession(
     * See [EngineSession.disableTrackingProtection]
     */
    override fun disableTrackingProtection() {
        disableTrackingProtectionOnGecko()
        geckoSession.settings.useTrackingProtection = false
        notifyObservers { onTrackerBlockingEnabledChange(false) }
    }

@@ -227,16 +224,6 @@ class GeckoEngineSession(
        }
    }

    // To fully disable tracking protection we need to change the different tracking protection
    // variables to none.
    private fun disableTrackingProtectionOnGecko() {
        geckoSession.settings.useTrackingProtection = false
        runtime.settings.contentBlocking.setAntiTracking(ContentBlocking.AntiTracking.NONE)
        runtime.settings.contentBlocking.cookieBehavior = ContentBlocking.CookieBehavior.ACCEPT_ALL
        runtime.settings.contentBlocking.setStrictSocialTrackingProtection(false)
        runtime.settings.contentBlocking.setEnhancedTrackingProtectionLevel(ContentBlocking.EtpLevel.NONE)
    }

    /**
     * See [EngineSession.settings]
     */
+0 −22
Original line number Diff line number Diff line
@@ -1081,10 +1081,6 @@ class GeckoEngineSessionTest {
        engineSession.disableTrackingProtection()
        assertTrue(trackerBlockingDisabledObserved)
        assertFalse(engineSession.geckoSession.settings.useTrackingProtection)
        verify(runtime.settings.contentBlocking).setAntiTracking(ContentBlocking.AntiTracking.NONE)
        verify(runtime.settings.contentBlocking).setCookieBehavior(GeckoCookieBehavior.ACCEPT_ALL)
        verify(runtime.settings.contentBlocking).setStrictSocialTrackingProtection(false)
        verify(runtime.settings.contentBlocking).setEnhancedTrackingProtectionLevel(ContentBlocking.EtpLevel.NONE)
    }

    @Test
@@ -1564,24 +1560,6 @@ class GeckoEngineSessionTest {
        verify(geckoSession.settings).useTrackingProtection = false
    }

    @Test
    fun `WHEN disabling tracking protection THEN CookieBehavior and AntiTracking category must be set to ACCEPT_ALL and NONE`() {
        whenever(runtime.settings.contentBlocking).thenReturn(mock())

        val defaultSettings =
            DefaultSettings(trackingProtectionPolicy = TrackingProtectionPolicy.recommended())

        val session = GeckoEngineSession(
            runtime, geckoSessionProvider = geckoSessionProvider,
            privateMode = false, defaultSettings = defaultSettings
        )

        session.disableTrackingProtection()
        verify(geckoSession.settings, times(2)).useTrackingProtection = false
        verify(runtime.settings.contentBlocking).setAntiTracking(ContentBlocking.AntiTracking.NONE)
        verify(runtime.settings.contentBlocking).setCookieBehavior(ContentBlocking.CookieBehavior.ACCEPT_ALL)
    }

    @Test
    fun contentDelegate() {
        val engineSession = GeckoEngineSession(mock(),
+2 −15
Original line number Diff line number Diff line
@@ -194,10 +194,7 @@ class GeckoEngineSession(
        val shouldBlockContent =
            policy.contains(TrackingProtectionPolicy.TrackingCategory.SCRIPTS_AND_SUB_RESOURCES)

        geckoSession.settings.useTrackingProtection = shouldBlockContent
        if (!enabled) {
            disableTrackingProtectionOnGecko()
        }
        geckoSession.settings.useTrackingProtection = shouldBlockContent && enabled
        notifyAtLeastOneObserver { onTrackerBlockingEnabledChange(enabled) }
    }

@@ -205,7 +202,7 @@ class GeckoEngineSession(
     * See [EngineSession.disableTrackingProtection]
     */
    override fun disableTrackingProtection() {
        disableTrackingProtectionOnGecko()
        geckoSession.settings.useTrackingProtection = false
        notifyObservers { onTrackerBlockingEnabledChange(false) }
    }

@@ -224,16 +221,6 @@ class GeckoEngineSession(
        }
    }

    // To fully disable tracking protection we need to change the different tracking protection
    // variables to none.
    private fun disableTrackingProtectionOnGecko() {
        geckoSession.settings.useTrackingProtection = false
        runtime.settings.contentBlocking.setAntiTracking(ContentBlocking.AntiTracking.NONE)
        runtime.settings.contentBlocking.cookieBehavior = ContentBlocking.CookieBehavior.ACCEPT_ALL
        runtime.settings.contentBlocking.setStrictSocialTrackingProtection(false)
        runtime.settings.contentBlocking.setEnhancedTrackingProtectionLevel(ContentBlocking.EtpLevel.NONE)
    }

    /**
     * See [EngineSession.settings]
     */
Loading