mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-03 23:15:31 +00:00
Bug 1823929 - New ETP UI tests
This commit is contained in:
parent
0938c42e41
commit
10b7763333
@ -1,4 +1,11 @@
|
||||
<html>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
<!-- This asset is using the code behind
|
||||
- https://www.mozilla-anti-tracking.com/test/dfpi/storage_access_api.html
|
||||
- test page.
|
||||
- Source repository: https://github.com/mozilla/anti-tracking-test-pages -->
|
||||
<body>
|
||||
<h2>Cross-site cookies storage access test</h2>
|
||||
<h3>anti-tracker-test.com</h3>
|
||||
|
@ -2,14 +2,16 @@
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
<!-- This asset is using the code behind
|
||||
- https://www.mozilla-anti-tracking.com/test/trackingprotection/test_pages/tracking_protection.html
|
||||
- test page.
|
||||
- Source repository: https://github.com/mozilla/anti-tracking-test-pages -->
|
||||
<html dir="ltr" xml:lang="en-US" lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf8">
|
||||
<script src="../resources/trackingAPI.js" type="text/javascript"></script>
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="http://trackertest.org/"></iframe>
|
||||
|
||||
<h3>Level 1 (Basic) List</h3>
|
||||
<p>social-track-digest256:</p>
|
||||
<img
|
||||
@ -18,19 +20,19 @@
|
||||
<br/>
|
||||
<p>ads-track-digest256:</p>
|
||||
<img
|
||||
src="https://ads-track-digest256.dummytracker.org/test_not_blocked.png"
|
||||
src="https://ads-track-digest256.dummytracker.org/test_not_blocked.png" alt="ads not blocked"
|
||||
onerror="this.onerror=null;this.src='https://not-a-tracker.dummytracker.org/test_blocked.png';this.alt='ads blocked'">
|
||||
<br/>
|
||||
<p>analytics-track-digest256:</p>
|
||||
<img
|
||||
src="https://analytics-track-digest256.dummytracker.org/test_not_blocked.png"
|
||||
src="https://analytics-track-digest256.dummytracker.org/test_not_blocked.png" alt="analytics not blocked"
|
||||
onerror="this.onerror=null;this.src='https://not-a-tracker.dummytracker.org/test_blocked.png';this.alt='analytics blocked'">
|
||||
<br/>
|
||||
<p>Fingerprinting:
|
||||
<pre id="result">test not run</pre>
|
||||
<script src="https://base-fingerprinting-track-digest256.dummytracker.org/tracker.js"
|
||||
onerror="this.onerror=null;var result=document.getElementById('result');result.innerHTML='Fingerprinting blocked';"
|
||||
onload="this.onload=null;var result=document.getElementById('result');result.innerHTML='Fingerprinting NOT blocked';"
|
||||
onload="this.onload=null;var result=document.getElementById('result');result.innerHTML='Fingerprinting not blocked';"
|
||||
></script>
|
||||
</p>
|
||||
<br/>
|
||||
|
@ -5,6 +5,7 @@
|
||||
package org.mozilla.fenix.ui
|
||||
|
||||
import androidx.core.net.toUri
|
||||
import androidx.test.espresso.Espresso.pressBack
|
||||
import okhttp3.mockwebserver.MockWebServer
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
@ -13,14 +14,18 @@ import org.junit.Test
|
||||
import org.mozilla.fenix.customannotations.SmokeTest
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
|
||||
import org.mozilla.fenix.helpers.HomeActivityTestRule
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper
|
||||
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper.getEnhancedTrackingProtectionAsset
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper.getGenericAsset
|
||||
import org.mozilla.fenix.helpers.TestHelper.appContext
|
||||
import org.mozilla.fenix.helpers.TestHelper.exitMenu
|
||||
import org.mozilla.fenix.helpers.TestHelper.mDevice
|
||||
import org.mozilla.fenix.helpers.TestHelper.restartApp
|
||||
import org.mozilla.fenix.helpers.TestHelper.scrollToElementByText
|
||||
import org.mozilla.fenix.ui.robots.browserScreen
|
||||
import org.mozilla.fenix.ui.robots.enhancedTrackingProtection
|
||||
import org.mozilla.fenix.ui.robots.homeScreen
|
||||
import org.mozilla.fenix.ui.robots.navigationToolbar
|
||||
import org.mozilla.fenix.ui.robots.settingsSubMenuEnhancedTrackingProtection
|
||||
|
||||
/**
|
||||
* Tests for verifying basic UI functionality of Enhanced Tracking Protection
|
||||
@ -32,6 +37,7 @@ import org.mozilla.fenix.ui.robots.settingsSubMenuEnhancedTrackingProtection
|
||||
* - Verifying Enhanced Tracking Protection content sheet
|
||||
* - Verifying Enhanced Tracking Protection content sheet details
|
||||
* - Verifying Enhanced Tracking Protection toggle
|
||||
* - Verifying Enhanced Tracking Protection options and functionality
|
||||
* - Verifying Enhanced Tracking Protection site exceptions
|
||||
*/
|
||||
|
||||
@ -39,7 +45,7 @@ class EnhancedTrackingProtectionTest {
|
||||
private lateinit var mockWebServer: MockWebServer
|
||||
|
||||
@get:Rule
|
||||
val activityTestRule = HomeActivityTestRule(
|
||||
val activityTestRule = HomeActivityIntentTestRule(
|
||||
isJumpBackInCFREnabled = false,
|
||||
isTCPCFREnabled = false,
|
||||
isWallpaperOnboardingEnabled = false,
|
||||
@ -59,7 +65,7 @@ class EnhancedTrackingProtectionTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSettingsDefaults() {
|
||||
fun testETPSettingsItemsAndSubMenus() {
|
||||
homeScreen {
|
||||
}.openThreeDotMenu {
|
||||
}.openSettings {
|
||||
@ -67,17 +73,57 @@ class EnhancedTrackingProtectionTest {
|
||||
verifySettingsOptionSummary("Enhanced Tracking Protection", "Standard")
|
||||
}.openEnhancedTrackingProtectionSubMenu {
|
||||
verifyEnhancedTrackingProtectionHeader()
|
||||
verifyEnhancedTrackingProtectionOptionsEnabled()
|
||||
verifyEnhancedTrackingProtectionHeaderDescription()
|
||||
verifyLearnMoreText()
|
||||
verifyEnhancedTrackingProtectionTextWithSwitchWidget()
|
||||
verifyTrackingProtectionSwitchEnabled()
|
||||
verifyEnhancedTrackingProtectionOptionsEnabled()
|
||||
verifyEnhancedTrackingProtectionLevelSelected("Standard (default)", true)
|
||||
verifyStandardOptionDescription()
|
||||
verifyStrictOptionDescription()
|
||||
selectTrackingProtectionOption("Custom")
|
||||
verifyCustomTrackingProtectionSettings()
|
||||
scrollToElementByText("Standard (default)")
|
||||
verifyWhatsBlockedByStandardETPInfo()
|
||||
pressBack()
|
||||
verifyWhatsBlockedByStrictETPInfo()
|
||||
pressBack()
|
||||
verifyWhatsBlockedByCustomETPInfo()
|
||||
pressBack()
|
||||
}.openExceptions {
|
||||
verifyDefault()
|
||||
verifyTPExceptionsDefaultView()
|
||||
openExceptionsLearnMoreLink()
|
||||
}
|
||||
browserScreen {
|
||||
verifyUrl("support.mozilla.org/en-US/kb/enhanced-tracking-protection-firefox-android")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testETPSettingsSummaryChange() {
|
||||
homeScreen {
|
||||
}.openThreeDotMenu {
|
||||
}.openSettings {
|
||||
verifyEnhancedTrackingProtectionButton()
|
||||
verifySettingsOptionSummary("Enhanced Tracking Protection", "Standard")
|
||||
}.openEnhancedTrackingProtectionSubMenu {
|
||||
selectTrackingProtectionOption("Strict")
|
||||
}.goBack {
|
||||
verifySettingsOptionSummary("Enhanced Tracking Protection", "Strict")
|
||||
}.openEnhancedTrackingProtectionSubMenu {
|
||||
selectTrackingProtectionOption("Custom")
|
||||
}.goBack {
|
||||
verifySettingsOptionSummary("Enhanced Tracking Protection", "Custom")
|
||||
}.openEnhancedTrackingProtectionSubMenu {
|
||||
switchEnhancedTrackingProtectionToggle()
|
||||
}.goBack {
|
||||
verifySettingsOptionSummary("Enhanced Tracking Protection", "Off")
|
||||
}
|
||||
}
|
||||
|
||||
@SmokeTest
|
||||
@Test
|
||||
fun testETPOffGlobally() {
|
||||
val genericPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
||||
val genericPage = getGenericAsset(mockWebServer, 1)
|
||||
|
||||
homeScreen {
|
||||
}.openThreeDotMenu {
|
||||
@ -107,22 +153,98 @@ class EnhancedTrackingProtectionTest {
|
||||
}
|
||||
}
|
||||
|
||||
// Tests adding ETP exceptions to websites and keeping that preference after restart
|
||||
@SmokeTest
|
||||
@Test
|
||||
fun testStrictVisitProtectionSheet() {
|
||||
appContext.settings().setStrictETP()
|
||||
val genericPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
||||
val trackingProtectionTest =
|
||||
TestAssetHelper.getEnhancedTrackingProtectionAsset(mockWebServer)
|
||||
fun testDisableETPExceptionToggle() {
|
||||
val firstPage = getGenericAsset(mockWebServer, 1)
|
||||
val secondPage = "example.com"
|
||||
|
||||
// browsing a generic page to allow GV to load on a fresh run
|
||||
navigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(genericPage.url) {
|
||||
}.openTabDrawer {
|
||||
closeTab()
|
||||
}.enterURLAndEnterToBrowser(firstPage.url) {}
|
||||
enhancedTrackingProtection {
|
||||
}.openEnhancedTrackingProtectionSheet {
|
||||
}.toggleEnhancedTrackingProtectionFromSheet {
|
||||
verifyEnhancedTrackingProtectionSheetStatus("OFF", false)
|
||||
}.closeEnhancedTrackingProtectionSheet {
|
||||
}.openNavigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(secondPage.toUri()) {
|
||||
verifyPageContent("Example Domain")
|
||||
}
|
||||
enhancedTrackingProtection {
|
||||
}.openEnhancedTrackingProtectionSheet {
|
||||
verifyEnhancedTrackingProtectionSheetStatus("ON", true)
|
||||
}.toggleEnhancedTrackingProtectionFromSheet {
|
||||
verifyEnhancedTrackingProtectionSheetStatus("OFF", false)
|
||||
}
|
||||
restartApp(activityTestRule)
|
||||
enhancedTrackingProtection {
|
||||
}.openEnhancedTrackingProtectionSheet {
|
||||
verifyEnhancedTrackingProtectionSheetStatus("OFF", false)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun trackingProtectionSwitchEnabledRemovesExceptionTest() {
|
||||
val trackingPage = getEnhancedTrackingProtectionAsset(mockWebServer)
|
||||
|
||||
navigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(trackingProtectionTest.url) {}
|
||||
}.enterURLAndEnterToBrowser(trackingPage.url) {
|
||||
waitForPageToLoad()
|
||||
}
|
||||
enhancedTrackingProtection {
|
||||
}.openEnhancedTrackingProtectionSheet {
|
||||
}.toggleEnhancedTrackingProtectionFromSheet {
|
||||
verifyEnhancedTrackingProtectionSheetStatus("OFF", false)
|
||||
}.closeEnhancedTrackingProtectionSheet {
|
||||
}.openThreeDotMenu {
|
||||
}.openSettings {
|
||||
}.openEnhancedTrackingProtectionSubMenu {
|
||||
}.openExceptions {
|
||||
verifySiteExceptionExists(trackingPage.url.host.toString(), true)
|
||||
exitMenu()
|
||||
}
|
||||
enhancedTrackingProtection {
|
||||
}.openEnhancedTrackingProtectionSheet {
|
||||
}.toggleEnhancedTrackingProtectionFromSheet {
|
||||
verifyEnhancedTrackingProtectionSheetStatus("ON", true)
|
||||
}.openProtectionSettings {
|
||||
}.openExceptions {
|
||||
verifySiteExceptionExists(trackingPage.url.host.toString(), false)
|
||||
}
|
||||
}
|
||||
|
||||
// Tests removing TP exceptions individually or all at once
|
||||
@Test
|
||||
fun clearTrackingProtectionExceptionsTest() {
|
||||
val firstPage = getGenericAsset(mockWebServer, 1)
|
||||
val secondPage = "example.com"
|
||||
|
||||
navigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(firstPage.url) {}
|
||||
enhancedTrackingProtection {
|
||||
}.openEnhancedTrackingProtectionSheet {
|
||||
}.toggleEnhancedTrackingProtectionFromSheet {
|
||||
verifyEnhancedTrackingProtectionSheetStatus("OFF", false)
|
||||
}.closeEnhancedTrackingProtectionSheet {
|
||||
}.openNavigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(secondPage.toUri()) {
|
||||
verifyPageContent("Example Domain")
|
||||
}
|
||||
enhancedTrackingProtection {
|
||||
}.openEnhancedTrackingProtectionSheet {
|
||||
}.toggleEnhancedTrackingProtectionFromSheet {
|
||||
verifyEnhancedTrackingProtectionSheetStatus("OFF", false)
|
||||
}.closeEnhancedTrackingProtectionSheet {
|
||||
}.openThreeDotMenu {
|
||||
}.openSettings {
|
||||
}.openEnhancedTrackingProtectionSubMenu {
|
||||
}.openExceptions {
|
||||
removeOneSiteException(secondPage)
|
||||
}.disableExceptions {
|
||||
verifyTPExceptionsDefaultView()
|
||||
exitMenu()
|
||||
}
|
||||
enhancedTrackingProtection {
|
||||
}.openEnhancedTrackingProtectionSheet {
|
||||
verifyEnhancedTrackingProtectionSheetStatus("ON", true)
|
||||
@ -130,46 +252,41 @@ class EnhancedTrackingProtectionTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testStrictVisitDisableExceptionToggle() {
|
||||
appContext.settings().setStrictETP()
|
||||
val genericPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
||||
val trackingProtectionTest =
|
||||
TestAssetHelper.getEnhancedTrackingProtectionAsset(mockWebServer)
|
||||
fun testStandardETPVisitSheetDetails() {
|
||||
val genericPage = getGenericAsset(mockWebServer, 1)
|
||||
val trackingProtectionTest = getEnhancedTrackingProtectionAsset(mockWebServer).url
|
||||
|
||||
// browsing a generic page to allow GV to load on a fresh run
|
||||
navigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(genericPage.url) {
|
||||
}.openTabDrawer {
|
||||
closeTab()
|
||||
verifyPageContent(genericPage.content)
|
||||
}.openNavigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(trackingProtectionTest) {
|
||||
verifyTrackingProtectionWebContent("social not blocked")
|
||||
verifyTrackingProtectionWebContent("ads not blocked")
|
||||
verifyTrackingProtectionWebContent("analytics not blocked")
|
||||
verifyTrackingProtectionWebContent("Fingerprinting blocked")
|
||||
verifyTrackingProtectionWebContent("Cryptomining blocked")
|
||||
}
|
||||
|
||||
navigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(trackingProtectionTest.url) {}
|
||||
enhancedTrackingProtection {
|
||||
}.openEnhancedTrackingProtectionSheet {
|
||||
verifyEnhancedTrackingProtectionSheetStatus("ON", true)
|
||||
}.disableEnhancedTrackingProtectionFromSheet {
|
||||
verifyEnhancedTrackingProtectionSheetStatus("OFF", false)
|
||||
}.openProtectionSettings {
|
||||
verifyEnhancedTrackingProtectionHeader()
|
||||
verifyEnhancedTrackingProtectionOptionsEnabled()
|
||||
verifyTrackingProtectionSwitchEnabled()
|
||||
}
|
||||
|
||||
settingsSubMenuEnhancedTrackingProtection {
|
||||
}.openExceptions {
|
||||
verifyListedURL(trackingProtectionTest.url.host.toString())
|
||||
}.disableExceptions {
|
||||
verifyDefault()
|
||||
}
|
||||
}.openDetails {
|
||||
verifyCrossSiteCookiesBlocked(true)
|
||||
navigateBackToDetails()
|
||||
verifyCryptominersBlocked(true)
|
||||
navigateBackToDetails()
|
||||
verifyFingerprintersBlocked(true)
|
||||
navigateBackToDetails()
|
||||
verifyTrackingContentBlocked(false)
|
||||
}.closeEnhancedTrackingProtectionSheet {}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testStrictVisitSheetDetails() {
|
||||
appContext.settings().setStrictETP()
|
||||
val genericPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
||||
val trackingProtectionTest =
|
||||
TestAssetHelper.getEnhancedTrackingProtectionAsset(mockWebServer)
|
||||
val genericPage = getGenericAsset(mockWebServer, 1)
|
||||
val trackingProtectionTest = getEnhancedTrackingProtectionAsset(mockWebServer).url
|
||||
|
||||
// browsing a generic page to allow GV to load on a fresh run
|
||||
navigationToolbar {
|
||||
@ -179,7 +296,7 @@ class EnhancedTrackingProtectionTest {
|
||||
}
|
||||
|
||||
navigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(trackingProtectionTest.url) {
|
||||
}.enterURLAndEnterToBrowser(trackingProtectionTest) {
|
||||
verifyTrackingProtectionWebContent("social blocked")
|
||||
verifyTrackingProtectionWebContent("ads blocked")
|
||||
verifyTrackingProtectionWebContent("analytics blocked")
|
||||
@ -190,31 +307,31 @@ class EnhancedTrackingProtectionTest {
|
||||
}.openEnhancedTrackingProtectionSheet {
|
||||
verifyEnhancedTrackingProtectionSheetStatus("ON", true)
|
||||
}.openDetails {
|
||||
verifyEnhancedTrackingProtectionDetailsStatus("Blocked")
|
||||
verifyTrackingCookiesBlocked()
|
||||
verifyCryptominersBlocked()
|
||||
verifyFingerprintersBlocked()
|
||||
verifyTrackingContentBlocked()
|
||||
verifySocialMediaTrackersBlocked(true)
|
||||
navigateBackToDetails()
|
||||
verifyCryptominersBlocked(true)
|
||||
navigateBackToDetails()
|
||||
verifyFingerprintersBlocked(true)
|
||||
navigateBackToDetails()
|
||||
verifyTrackingContentBlocked(true)
|
||||
viewTrackingContentBlockList()
|
||||
}
|
||||
}
|
||||
|
||||
@SmokeTest
|
||||
@Test
|
||||
fun customTrackingProtectionSettingsTest() {
|
||||
val genericWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
||||
val trackingPage = TestAssetHelper.getEnhancedTrackingProtectionAsset(mockWebServer)
|
||||
fun defaultCustomTrackingProtectionSettingsTest() {
|
||||
val genericWebPage = getGenericAsset(mockWebServer, 1)
|
||||
val trackingPage = getEnhancedTrackingProtectionAsset(mockWebServer)
|
||||
|
||||
homeScreen {
|
||||
}.openThreeDotMenu {
|
||||
}.openSettings {
|
||||
}.openEnhancedTrackingProtectionSubMenu {
|
||||
verifyEnhancedTrackingProtectionOptionsEnabled()
|
||||
selectTrackingProtectionOption("Custom")
|
||||
verifyCustomTrackingProtectionSettings()
|
||||
}.goBackToHomeScreen {}
|
||||
|
||||
navigationToolbar {
|
||||
}.goBackToHomeScreen {
|
||||
}.openNavigationToolbar {
|
||||
// browsing a basic page to allow GV to load on a fresh run
|
||||
}.enterURLAndEnterToBrowser(genericWebPage.url) {
|
||||
}.openNavigationToolbar {
|
||||
@ -229,10 +346,138 @@ class EnhancedTrackingProtectionTest {
|
||||
enhancedTrackingProtection {
|
||||
}.openEnhancedTrackingProtectionSheet {
|
||||
}.openDetails {
|
||||
verifyTrackingCookiesBlocked()
|
||||
verifyCryptominersBlocked()
|
||||
verifyFingerprintersBlocked()
|
||||
verifyTrackingContentBlocked()
|
||||
verifyCrossSiteCookiesBlocked(true)
|
||||
navigateBackToDetails()
|
||||
verifyCryptominersBlocked(true)
|
||||
navigateBackToDetails()
|
||||
verifyFingerprintersBlocked(true)
|
||||
navigateBackToDetails()
|
||||
verifyTrackingContentBlocked(true)
|
||||
viewTrackingContentBlockList()
|
||||
}
|
||||
}
|
||||
|
||||
// Tests the trackers blocked with the following Custom TP set up:
|
||||
// - Cookies set to "All cookies"
|
||||
// - Tracking content option OFF
|
||||
// - Fingerprinters, cryptominers and redirect trackers checked
|
||||
@Test
|
||||
fun customizedTrackingProtectionOptionsTest() {
|
||||
val genericWebPage = getGenericAsset(mockWebServer, 1)
|
||||
val trackingPage = getEnhancedTrackingProtectionAsset(mockWebServer)
|
||||
|
||||
homeScreen {
|
||||
}.openThreeDotMenu {
|
||||
}.openSettings {
|
||||
}.openEnhancedTrackingProtectionSubMenu {
|
||||
selectTrackingProtectionOption("Custom")
|
||||
verifyCustomTrackingProtectionSettings()
|
||||
selectTrackingProtectionOption("Isolate cross-site cookies")
|
||||
selectTrackingProtectionOption("All cookies (will cause websites to break)")
|
||||
selectTrackingProtectionOption("Tracking content")
|
||||
}.goBackToHomeScreen {
|
||||
mDevice.waitForIdle()
|
||||
}.openNavigationToolbar {
|
||||
// browsing a basic page to allow GV to load on a fresh run
|
||||
}.enterURLAndEnterToBrowser(genericWebPage.url) {
|
||||
waitForPageToLoad()
|
||||
}.openNavigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(trackingPage.url) {
|
||||
verifyTrackingProtectionWebContent("social not blocked")
|
||||
verifyTrackingProtectionWebContent("ads not blocked")
|
||||
verifyTrackingProtectionWebContent("analytics not blocked")
|
||||
}
|
||||
enhancedTrackingProtection {
|
||||
}.openEnhancedTrackingProtectionSheet {
|
||||
}.openDetails {
|
||||
verifyCrossSiteCookiesBlocked(true)
|
||||
navigateBackToDetails()
|
||||
verifyCryptominersBlocked(true)
|
||||
navigateBackToDetails()
|
||||
verifyFingerprintersBlocked(true)
|
||||
navigateBackToDetails()
|
||||
verifyTrackingContentBlocked(false)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun disableCustomTrackingProtectionOptionsTest() {
|
||||
val genericWebPage = getGenericAsset(mockWebServer, 1)
|
||||
val trackingPage = getEnhancedTrackingProtectionAsset(mockWebServer)
|
||||
|
||||
homeScreen {
|
||||
}.openThreeDotMenu {
|
||||
}.openSettings {
|
||||
}.openEnhancedTrackingProtectionSubMenu {
|
||||
selectTrackingProtectionOption("Custom")
|
||||
verifyCustomTrackingProtectionSettings()
|
||||
selectTrackingProtectionOption("Cookies")
|
||||
selectTrackingProtectionOption("Tracking content")
|
||||
selectTrackingProtectionOption("Cryptominers")
|
||||
selectTrackingProtectionOption("Fingerprinters")
|
||||
selectTrackingProtectionOption("Redirect Trackers")
|
||||
}.goBackToHomeScreen {
|
||||
mDevice.waitForIdle()
|
||||
}.openNavigationToolbar {
|
||||
// browsing a basic page to allow GV to load on a fresh run
|
||||
}.enterURLAndEnterToBrowser(genericWebPage.url) {
|
||||
waitForPageToLoad()
|
||||
}.openNavigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(trackingPage.url) {
|
||||
verifyTrackingProtectionWebContent("social not blocked")
|
||||
verifyTrackingProtectionWebContent("ads not blocked")
|
||||
verifyTrackingProtectionWebContent("analytics not blocked")
|
||||
verifyTrackingProtectionWebContent("Fingerprinting not blocked")
|
||||
verifyTrackingProtectionWebContent("Cryptomining not blocked")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testTrackingContentBlockedOnlyInPrivateTabs() {
|
||||
val genericWebPage = getGenericAsset(mockWebServer, 1)
|
||||
val trackingPage = getEnhancedTrackingProtectionAsset(mockWebServer)
|
||||
|
||||
homeScreen {
|
||||
}.openThreeDotMenu {
|
||||
}.openSettings {
|
||||
}.openEnhancedTrackingProtectionSubMenu {
|
||||
verifyEnhancedTrackingProtectionOptionsEnabled()
|
||||
selectTrackingProtectionOption("Custom")
|
||||
verifyCustomTrackingProtectionSettings()
|
||||
selectTrackingProtectionOption("In all tabs")
|
||||
selectTrackingProtectionOption("Only in Private tabs")
|
||||
}.goBackToHomeScreen {
|
||||
}.openNavigationToolbar {
|
||||
// browsing a basic page to allow GV to load on a fresh run
|
||||
}.enterURLAndEnterToBrowser(genericWebPage.url) {
|
||||
waitForPageToLoad()
|
||||
}.openNavigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(trackingPage.url) {
|
||||
verifyTrackingProtectionWebContent("social not blocked")
|
||||
verifyTrackingProtectionWebContent("ads not blocked")
|
||||
verifyTrackingProtectionWebContent("analytics not blocked")
|
||||
verifyTrackingProtectionWebContent("Fingerprinting blocked")
|
||||
verifyTrackingProtectionWebContent("Cryptomining blocked")
|
||||
}.goToHomescreen {
|
||||
}.togglePrivateBrowsingMode()
|
||||
navigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(trackingPage.url) {
|
||||
verifyTrackingProtectionWebContent("social blocked")
|
||||
verifyTrackingProtectionWebContent("ads blocked")
|
||||
verifyTrackingProtectionWebContent("analytics blocked")
|
||||
verifyTrackingProtectionWebContent("Fingerprinting blocked")
|
||||
verifyTrackingProtectionWebContent("Cryptomining blocked")
|
||||
}
|
||||
enhancedTrackingProtection {
|
||||
}.openEnhancedTrackingProtectionSheet {
|
||||
}.openDetails {
|
||||
verifyCrossSiteCookiesBlocked(true)
|
||||
navigateBackToDetails()
|
||||
verifyCryptominersBlocked(true)
|
||||
navigateBackToDetails()
|
||||
verifyFingerprintersBlocked(true)
|
||||
navigateBackToDetails()
|
||||
verifyTrackingContentBlocked(true)
|
||||
viewTrackingContentBlockList()
|
||||
}
|
||||
}
|
||||
@ -241,12 +486,17 @@ class EnhancedTrackingProtectionTest {
|
||||
@Test
|
||||
fun blockCookiesStorageAccessTest() {
|
||||
// With Standard TrackingProtection settings
|
||||
val page = mockWebServer.url("pages/cross-site-cookies.html").toString().toUri()
|
||||
val genericWebPage = getGenericAsset(mockWebServer, 1)
|
||||
val testPage = mockWebServer.url("pages/cross-site-cookies.html").toString().toUri()
|
||||
val originSite = "https://mozilla-mobile.github.io"
|
||||
val currentSite = "http://localhost:${mockWebServer.port}"
|
||||
|
||||
navigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(page) {
|
||||
}.enterURLAndEnterToBrowser(genericWebPage.url) {
|
||||
waitForPageToLoad()
|
||||
}.openNavigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(testPage) {
|
||||
waitForPageToLoad()
|
||||
}.clickRequestStorageAccessButton {
|
||||
verifyCrossOriginCookiesPermissionPrompt(originSite, currentSite)
|
||||
}.clickPagePermissionButton(allow = false) {
|
||||
@ -258,12 +508,17 @@ class EnhancedTrackingProtectionTest {
|
||||
@Test
|
||||
fun allowCookiesStorageAccessTest() {
|
||||
// With Standard TrackingProtection settings
|
||||
val page = mockWebServer.url("pages/cross-site-cookies.html").toString().toUri()
|
||||
val genericWebPage = getGenericAsset(mockWebServer, 1)
|
||||
val testPage = mockWebServer.url("pages/cross-site-cookies.html").toString().toUri()
|
||||
val originSite = "https://mozilla-mobile.github.io"
|
||||
val currentSite = "http://localhost:${mockWebServer.port}"
|
||||
|
||||
navigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(page) {
|
||||
}.enterURLAndEnterToBrowser(genericWebPage.url) {
|
||||
waitForPageToLoad()
|
||||
}.openNavigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(testPage) {
|
||||
waitForPageToLoad()
|
||||
}.clickRequestStorageAccessButton {
|
||||
verifyCrossOriginCookiesPermissionPrompt(originSite, currentSite)
|
||||
}.clickPagePermissionButton(allow = true) {
|
||||
|
@ -67,12 +67,12 @@ class SettingsTest {
|
||||
verifySettingsOptionSummary("Enhanced Tracking Protection", "Standard")
|
||||
}.openEnhancedTrackingProtectionSubMenu {
|
||||
verifyNavigationToolBarHeader()
|
||||
verifyEnhancedTrackingProtectionProtectionSubMenuItems()
|
||||
verifyEnhancedTrackingProtectionOptionsEnabled()
|
||||
|
||||
// ENHANCED TRACKING PROTECTION EXCEPTION
|
||||
}.openExceptions {
|
||||
verifyNavigationToolBarHeader()
|
||||
verifyEnhancedTrackingProtectionProtectionExceptionsSubMenuItems()
|
||||
verifyTPExceptionsDefaultView()
|
||||
}.goBack {
|
||||
}.goBack {
|
||||
// SITE PERMISSIONS
|
||||
|
@ -1237,6 +1237,7 @@ class BrowserRobot {
|
||||
}
|
||||
|
||||
fun clickRequestStorageAccessButton(interact: SitePermissionsRobot.() -> Unit): SitePermissionsRobot.Transition {
|
||||
webPageItemContainingText("requestStorageAccess()").waitForExists(waitingTime)
|
||||
clickPageObject(webPageItemContainingText("requestStorageAccess()"))
|
||||
|
||||
SitePermissionsRobot().interact()
|
||||
|
@ -11,12 +11,14 @@ import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.RootMatchers
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import androidx.test.uiautomator.By
|
||||
import androidx.test.uiautomator.UiSelector
|
||||
import androidx.test.uiautomator.Until
|
||||
import junit.framework.TestCase.assertTrue
|
||||
import org.hamcrest.Matchers.allOf
|
||||
import org.hamcrest.Matchers.containsString
|
||||
import org.hamcrest.Matchers.not
|
||||
import org.mozilla.fenix.R
|
||||
@ -35,23 +37,118 @@ class EnhancedTrackingProtectionRobot {
|
||||
fun verifyEnhancedTrackingProtectionSheetStatus(status: String, state: Boolean) =
|
||||
assertEnhancedTrackingProtectionSheetStatus(status, state)
|
||||
|
||||
fun verifyEnhancedTrackingProtectionDetailsStatus(status: String) =
|
||||
assertEnhancedTrackingProtectionDetailsStatus(status)
|
||||
|
||||
fun verifyETPSwitchVisibility(visible: Boolean) = assertETPSwitchVisibility(visible)
|
||||
|
||||
fun verifyTrackingCookiesBlocked() = assertTrackingCookiesBlocked()
|
||||
fun verifyCrossSiteCookiesBlocked(isBlocked: Boolean) {
|
||||
assertTrue(
|
||||
mDevice.findObject(UiSelector().resourceId("$packageName:id/cross_site_tracking"))
|
||||
.waitForExists(waitingTime),
|
||||
)
|
||||
crossSiteCookiesBlockListButton.click()
|
||||
// Verifies the trackers block/allow list
|
||||
onView(withId(R.id.details_blocking_header))
|
||||
.check(
|
||||
matches(
|
||||
withText(
|
||||
if (isBlocked) {
|
||||
("Blocked")
|
||||
} else {
|
||||
("Allowed")
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
fun verifyFingerprintersBlocked() = assertFingerprintersBlocked()
|
||||
fun verifySocialMediaTrackersBlocked(isBlocked: Boolean) {
|
||||
assertTrue(
|
||||
mDevice.findObject(UiSelector().resourceId("$packageName:id/social_media_trackers"))
|
||||
.waitForExists(waitingTime),
|
||||
)
|
||||
socialTrackersBlockListButton.click()
|
||||
// Verifies the trackers block/allow list
|
||||
onView(withId(R.id.details_blocking_header))
|
||||
.check(
|
||||
matches(
|
||||
withText(
|
||||
if (isBlocked) {
|
||||
("Blocked")
|
||||
} else {
|
||||
("Allowed")
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
onView(withId(R.id.blocking_text_list)).check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
fun verifyCryptominersBlocked() = assertCryptominersBlocked()
|
||||
fun verifyFingerprintersBlocked(isBlocked: Boolean) {
|
||||
assertTrue(
|
||||
mDevice.findObject(UiSelector().resourceId("$packageName:id/fingerprinters"))
|
||||
.waitForExists(waitingTime),
|
||||
)
|
||||
fingerprintersBlockListButton.click()
|
||||
// Verifies the trackers block/allow list
|
||||
onView(withId(R.id.details_blocking_header))
|
||||
.check(
|
||||
matches(
|
||||
withText(
|
||||
if (isBlocked) {
|
||||
("Blocked")
|
||||
} else {
|
||||
("Allowed")
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
onView(withId(R.id.blocking_text_list)).check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
fun verifyTrackingContentBlocked() = assertTrackingContentBlocked()
|
||||
fun verifyCryptominersBlocked(isBlocked: Boolean) {
|
||||
assertTrue(
|
||||
mDevice.findObject(UiSelector().resourceId("$packageName:id/cryptominers"))
|
||||
.waitForExists(waitingTime),
|
||||
)
|
||||
cryptominersBlockListButton.click()
|
||||
// Verifies the trackers block/allow list
|
||||
onView(withId(R.id.details_blocking_header))
|
||||
.check(
|
||||
matches(
|
||||
withText(
|
||||
if (isBlocked) {
|
||||
("Blocked")
|
||||
} else {
|
||||
("Allowed")
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
onView(withId(R.id.blocking_text_list)).check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
fun verifyTrackingContentBlocked(isBlocked: Boolean) {
|
||||
assertTrue(
|
||||
mDevice.findObject(UiSelector().text("Tracking Content"))
|
||||
.waitForExists(waitingTime),
|
||||
)
|
||||
trackingContentBlockListButton.click()
|
||||
// Verifies the trackers block/allow list
|
||||
onView(withId(R.id.details_blocking_header))
|
||||
.check(
|
||||
matches(
|
||||
withText(
|
||||
if (isBlocked) {
|
||||
("Blocked")
|
||||
} else {
|
||||
("Allowed")
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
onView(withId(R.id.blocking_text_list)).check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
fun viewTrackingContentBlockList() {
|
||||
trackingContentBlockListButton()
|
||||
.check(matches(isDisplayed()))
|
||||
.click()
|
||||
onView(withId(R.id.blocking_text_list))
|
||||
.check(
|
||||
matches(
|
||||
@ -66,10 +163,14 @@ class EnhancedTrackingProtectionRobot {
|
||||
)
|
||||
}
|
||||
|
||||
fun navigateBackToDetails() {
|
||||
onView(withId(R.id.details_back)).click()
|
||||
}
|
||||
|
||||
class Transition {
|
||||
fun openEnhancedTrackingProtectionSheet(interact: EnhancedTrackingProtectionRobot.() -> Unit): Transition {
|
||||
openEnhancedTrackingProtectionSheet().waitForExists(waitingTime)
|
||||
openEnhancedTrackingProtectionSheet().click()
|
||||
pageSecurityIndicator().waitForExists(waitingTime)
|
||||
pageSecurityIndicator().click()
|
||||
assertSecuritySheetIsCompletelyDisplayed()
|
||||
|
||||
EnhancedTrackingProtectionRobot().interact()
|
||||
@ -84,20 +185,20 @@ class EnhancedTrackingProtectionRobot {
|
||||
return BrowserRobot.Transition()
|
||||
}
|
||||
|
||||
fun disableEnhancedTrackingProtectionFromSheet(interact: EnhancedTrackingProtectionRobot.() -> Unit): Transition {
|
||||
fun toggleEnhancedTrackingProtectionFromSheet(interact: EnhancedTrackingProtectionRobot.() -> Unit): Transition {
|
||||
enhancedTrackingProtectionSwitch().click()
|
||||
|
||||
EnhancedTrackingProtectionRobot().interact()
|
||||
return Transition()
|
||||
}
|
||||
|
||||
fun openProtectionSettings(interact: SettingsSubMenuEnhancedTrackingProtectionRobot.() -> Unit): Transition {
|
||||
fun openProtectionSettings(interact: SettingsSubMenuEnhancedTrackingProtectionRobot.() -> Unit): SettingsSubMenuEnhancedTrackingProtectionRobot.Transition {
|
||||
openEnhancedTrackingProtectionDetails().waitForExists(waitingTime)
|
||||
openEnhancedTrackingProtectionDetails().click()
|
||||
trackingProtectionSettingsButton().click()
|
||||
|
||||
SettingsSubMenuEnhancedTrackingProtectionRobot().interact()
|
||||
return Transition()
|
||||
return SettingsSubMenuEnhancedTrackingProtectionRobot.Transition()
|
||||
}
|
||||
|
||||
fun openDetails(interact: EnhancedTrackingProtectionRobot.() -> Unit): Transition {
|
||||
@ -126,7 +227,7 @@ private fun assertETPSwitchVisibility(visible: Boolean) {
|
||||
}
|
||||
|
||||
private fun assertEnhancedTrackingProtectionSheetStatus(status: String, state: Boolean) {
|
||||
mDevice.waitNotNull(Until.findObjects(By.textContains(status)))
|
||||
mDevice.waitNotNull(Until.findObjects(By.text("Protections are $status for this site")))
|
||||
onView(ViewMatchers.withResourceName("switch_widget")).check(
|
||||
matches(
|
||||
isChecked(
|
||||
@ -136,11 +237,7 @@ private fun assertEnhancedTrackingProtectionSheetStatus(status: String, state: B
|
||||
)
|
||||
}
|
||||
|
||||
private fun assertEnhancedTrackingProtectionDetailsStatus(status: String) {
|
||||
mDevice.waitNotNull(Until.findObjects(By.textContains(status)))
|
||||
}
|
||||
|
||||
private fun openEnhancedTrackingProtectionSheet() =
|
||||
private fun pageSecurityIndicator() =
|
||||
mDevice.findObject(UiSelector().resourceId("$packageName:id/mozac_browser_toolbar_security_indicator"))
|
||||
|
||||
private fun enhancedTrackingProtectionSwitch() =
|
||||
@ -156,35 +253,45 @@ private fun trackingProtectionSettingsButton() =
|
||||
private fun openEnhancedTrackingProtectionDetails() =
|
||||
mDevice.findObject(UiSelector().resourceId("$packageName:id/trackingProtectionDetails"))
|
||||
|
||||
private fun assertTrackingCookiesBlocked() {
|
||||
mDevice.findObject(UiSelector().resourceId("$packageName:id/cross_site_tracking"))
|
||||
.waitForExists(waitingTime)
|
||||
onView(withId(R.id.blocking_header)).check(matches(isDisplayed()))
|
||||
onView(withId(R.id.tracking_content)).check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
private fun assertFingerprintersBlocked() {
|
||||
mDevice.findObject(UiSelector().resourceId("$packageName:id/fingerprinters"))
|
||||
.waitForExists(waitingTime)
|
||||
onView(withId(R.id.blocking_header)).check(matches(isDisplayed()))
|
||||
onView(withId(R.id.fingerprinters)).check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
private fun assertCryptominersBlocked() {
|
||||
mDevice.findObject(UiSelector().resourceId("$packageName:id/cryptominers"))
|
||||
.waitForExists(waitingTime)
|
||||
onView(withId(R.id.blocking_header)).check(matches(isDisplayed()))
|
||||
onView(withId(R.id.cryptominers)).check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
private fun assertTrackingContentBlocked() {
|
||||
assertTrue(
|
||||
mDevice.findObject(UiSelector().resourceId("$packageName:id/tracking_content"))
|
||||
.waitForExists(waitingTime),
|
||||
private val trackingContentBlockListButton =
|
||||
onView(
|
||||
allOf(
|
||||
withText("Tracking Content"),
|
||||
withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
private fun trackingContentBlockListButton() = onView(withId(R.id.tracking_content))
|
||||
private val socialTrackersBlockListButton =
|
||||
onView(
|
||||
allOf(
|
||||
withId(R.id.social_media_trackers),
|
||||
withText("Social Media Trackers"),
|
||||
),
|
||||
)
|
||||
|
||||
private val crossSiteCookiesBlockListButton =
|
||||
onView(
|
||||
allOf(
|
||||
withId(R.id.cross_site_tracking),
|
||||
withText("Cross-Site Cookies"),
|
||||
),
|
||||
)
|
||||
|
||||
private val cryptominersBlockListButton =
|
||||
onView(
|
||||
allOf(
|
||||
withId(R.id.cryptominers),
|
||||
withText("Cryptominers"),
|
||||
),
|
||||
)
|
||||
|
||||
private val fingerprintersBlockListButton =
|
||||
onView(
|
||||
allOf(
|
||||
withId(R.id.fingerprinters),
|
||||
withText("Fingerprinters"),
|
||||
),
|
||||
)
|
||||
|
||||
private fun assertSecuritySheetIsCompletelyDisplayed() {
|
||||
mDevice.findObject(UiSelector().description(getStringResource(R.string.quick_settings_sheet)))
|
||||
|
@ -192,7 +192,6 @@ class SettingsRobot {
|
||||
|
||||
fun verifySettingsOptionSummary(setting: String, summary: String) {
|
||||
scrollToElementByText(setting)
|
||||
|
||||
onView(
|
||||
allOf(
|
||||
withText(setting),
|
||||
|
@ -7,6 +7,8 @@ package org.mozilla.fenix.ui.robots
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.Visibility
|
||||
import androidx.test.espresso.matcher.ViewMatchers.hasSibling
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
@ -14,9 +16,14 @@ import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import androidx.test.uiautomator.UiSelector
|
||||
import junit.framework.TestCase.assertTrue
|
||||
import org.hamcrest.CoreMatchers.allOf
|
||||
import org.hamcrest.CoreMatchers.containsString
|
||||
import org.hamcrest.CoreMatchers.not
|
||||
import org.hamcrest.Matchers.contains
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
|
||||
import org.mozilla.fenix.helpers.TestHelper.mDevice
|
||||
import org.mozilla.fenix.helpers.TestHelper.packageName
|
||||
import org.mozilla.fenix.helpers.click
|
||||
|
||||
/**
|
||||
@ -26,15 +33,35 @@ class SettingsSubMenuEnhancedTrackingProtectionExceptionsRobot {
|
||||
|
||||
fun verifyNavigationToolBarHeader() = assertNavigationToolBarHeader()
|
||||
|
||||
fun verifyDefault() = assertExceptionDefault()
|
||||
fun verifyTPExceptionsDefaultView() {
|
||||
assertTrue(
|
||||
mDevice.findObject(
|
||||
UiSelector().text("Exceptions let you disable tracking protection for selected sites."),
|
||||
).waitForExists(waitingTime),
|
||||
)
|
||||
learnMoreLink.check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
fun verifyExceptionLearnMoreText() = assertExceptionLearnMoreText()
|
||||
fun openExceptionsLearnMoreLink() = learnMoreLink.click()
|
||||
|
||||
fun verifyListedURL(url: String) = assertExceptionURL(url)
|
||||
fun removeOneSiteException(siteHost: String) {
|
||||
exceptionsList.waitForExists(waitingTime)
|
||||
removeSiteExceptionButton(siteHost).click()
|
||||
}
|
||||
|
||||
fun verifyEnhancedTrackingProtectionProtectionExceptionsSubMenuItems() {
|
||||
verifyDefault()
|
||||
verifyExceptionLearnMoreText()
|
||||
fun verifySiteExceptionExists(siteUrl: String, shouldExist: Boolean) {
|
||||
exceptionsList.waitForExists(waitingTime)
|
||||
if (shouldExist) {
|
||||
assertTrue(
|
||||
mDevice.findObject(UiSelector().textContains(siteUrl))
|
||||
.waitForExists(waitingTime),
|
||||
)
|
||||
} else {
|
||||
assertFalse(
|
||||
mDevice.findObject(UiSelector().textContains(siteUrl))
|
||||
.waitForExists(waitingTime),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class Transition {
|
||||
@ -46,7 +73,7 @@ class SettingsSubMenuEnhancedTrackingProtectionExceptionsRobot {
|
||||
}
|
||||
|
||||
fun disableExceptions(interact: SettingsSubMenuEnhancedTrackingProtectionExceptionsRobot.() -> Unit): Transition {
|
||||
disableExceptionsButton().click()
|
||||
disableAllExceptionsButton().click()
|
||||
|
||||
SettingsSubMenuEnhancedTrackingProtectionExceptionsRobot().interact()
|
||||
return Transition()
|
||||
@ -62,26 +89,18 @@ private fun assertNavigationToolBarHeader() {
|
||||
.check((matches(withEffectiveVisibility(Visibility.VISIBLE))))
|
||||
}
|
||||
|
||||
private fun assertExceptionDefault() =
|
||||
assertTrue(
|
||||
mDevice.findObject(
|
||||
UiSelector().text("Exceptions let you disable tracking protection for selected sites."),
|
||||
).waitForExists(waitingTime),
|
||||
)
|
||||
private val learnMoreLink = onView(withText("Learn more"))
|
||||
|
||||
private fun assertExceptionLearnMoreText() =
|
||||
assertTrue(
|
||||
mDevice.findObject(
|
||||
UiSelector().text("Learn more"),
|
||||
).waitForExists(waitingTime),
|
||||
)
|
||||
|
||||
private fun assertExceptionURL(url: String) =
|
||||
assertTrue(
|
||||
mDevice.findObject(
|
||||
UiSelector().textContains(url.replace("http://", "https://")),
|
||||
).waitForExists(waitingTime),
|
||||
)
|
||||
|
||||
private fun disableExceptionsButton() =
|
||||
private fun disableAllExceptionsButton() =
|
||||
onView(withId(R.id.removeAllExceptions)).click()
|
||||
|
||||
private fun removeSiteExceptionButton(siteHost: String) =
|
||||
onView(
|
||||
allOf(
|
||||
withContentDescription("Delete"),
|
||||
hasSibling(withText(containsString(siteHost))),
|
||||
),
|
||||
)
|
||||
|
||||
private val exceptionsList =
|
||||
mDevice.findObject(UiSelector().resourceId("$packageName:id/exceptions_list"))
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
package org.mozilla.fenix.ui.robots
|
||||
|
||||
import androidx.preference.R
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.Espresso.pressBack
|
||||
@ -22,10 +21,14 @@ import androidx.test.espresso.matcher.ViewMatchers.withParent
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withParentIndex
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withResourceName
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import androidx.test.uiautomator.By
|
||||
import androidx.test.uiautomator.Until
|
||||
import org.hamcrest.CoreMatchers.allOf
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
|
||||
import org.mozilla.fenix.helpers.TestHelper.appName
|
||||
import org.mozilla.fenix.helpers.TestHelper.mDevice
|
||||
import org.mozilla.fenix.helpers.TestHelper.scrollToElementByText
|
||||
import org.mozilla.fenix.helpers.assertIsChecked
|
||||
import org.mozilla.fenix.helpers.click
|
||||
import org.mozilla.fenix.helpers.isChecked
|
||||
import org.mozilla.fenix.helpers.isEnabled
|
||||
@ -45,28 +48,91 @@ class SettingsSubMenuEnhancedTrackingProtectionRobot {
|
||||
|
||||
fun verifyEnhancedTrackingProtectionTextWithSwitchWidget() = assertEnhancedTrackingProtectionTextWithSwitchWidget()
|
||||
|
||||
fun verifyEnhancedTrackingProtectionOptionsEnabled(enabled: Boolean = true) = assertEnhancedTrackingProtectionOptionsState(enabled)
|
||||
fun verifyEnhancedTrackingProtectionOptionsEnabled(enabled: Boolean = true) {
|
||||
onView(withText("Standard (default)"))
|
||||
.check(matches(isEnabled(enabled)))
|
||||
|
||||
onView(withText("Strict"))
|
||||
.check(matches(isEnabled(enabled)))
|
||||
|
||||
onView(withText("Custom"))
|
||||
.check(matches(isEnabled(enabled)))
|
||||
}
|
||||
|
||||
fun verifyTrackingProtectionSwitchEnabled() = assertTrackingProtectionSwitchEnabled()
|
||||
|
||||
fun switchEnhancedTrackingProtectionToggle() = onView(withResourceName("switch_widget")).click()
|
||||
|
||||
fun verifyRadioButtonDefaults() = assertRadioButtonDefaults()
|
||||
|
||||
fun verifyEnhancedTrackingProtectionProtectionSubMenuItems() {
|
||||
verifyEnhancedTrackingProtectionHeader()
|
||||
verifyEnhancedTrackingProtectionHeaderDescription()
|
||||
verifyLearnMoreText()
|
||||
verifyEnhancedTrackingProtectionTextWithSwitchWidget()
|
||||
verifyTrackingProtectionSwitchEnabled()
|
||||
verifyRadioButtonDefaults()
|
||||
verifyEnhancedTrackingProtectionOptionsEnabled()
|
||||
fun verifyStandardOptionDescription() {
|
||||
onView(withText(R.string.preference_enhanced_tracking_protection_standard_description_4))
|
||||
.check(matches(isDisplayed()))
|
||||
onView(withContentDescription(R.string.preference_enhanced_tracking_protection_standard_info_button))
|
||||
.check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
fun verifyCustomTrackingProtectionSettings() = assertCustomTrackingProtectionSettings()
|
||||
fun verifyStrictOptionDescription() {
|
||||
onView(withText(org.mozilla.fenix.R.string.preference_enhanced_tracking_protection_strict_description_3))
|
||||
.check(matches(isDisplayed()))
|
||||
onView(withContentDescription(R.string.preference_enhanced_tracking_protection_strict_info_button))
|
||||
.check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
fun verifyCustomTrackingProtectionSettings() {
|
||||
scrollToElementByText("Redirect Trackers")
|
||||
onView(withText(org.mozilla.fenix.R.string.preference_enhanced_tracking_protection_custom_description_2))
|
||||
.check(matches(isDisplayed()))
|
||||
onView(withContentDescription(R.string.preference_enhanced_tracking_protection_custom_info_button))
|
||||
.check(matches(isDisplayed()))
|
||||
cookiesCheckbox().check(matches(isDisplayed()))
|
||||
cookiesDropDownMenuDefault().check(matches(isDisplayed()))
|
||||
trackingContentCheckbox().check(matches(isDisplayed()))
|
||||
trackingcontentDropDownDefault().check(matches(isDisplayed()))
|
||||
cryptominersCheckbox().check(matches(isDisplayed()))
|
||||
fingerprintersCheckbox().check(matches(isDisplayed()))
|
||||
redirectTrackersCheckbox().check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
fun verifyWhatsBlockedByStandardETPInfo() {
|
||||
onView(withContentDescription(R.string.preference_enhanced_tracking_protection_standard_info_button)).click()
|
||||
blockedByStandardETPInfo()
|
||||
}
|
||||
|
||||
fun verifyWhatsBlockedByStrictETPInfo() {
|
||||
onView(withContentDescription(R.string.preference_enhanced_tracking_protection_strict_info_button)).click()
|
||||
// Repeating the info as in the standard option, with one extra point.
|
||||
blockedByStandardETPInfo()
|
||||
onView(withText("Tracking Content")).check(matches(isDisplayed()))
|
||||
onView(withText("Stops outside ads, videos, and other content from loading that contains tracking code. May affect some website functionality.")).check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
fun verifyWhatsBlockedByCustomETPInfo() {
|
||||
onView(withContentDescription(R.string.preference_enhanced_tracking_protection_custom_info_button)).click()
|
||||
// Repeating the info as in the standard option, with one extra point.
|
||||
blockedByStandardETPInfo()
|
||||
onView(withText("Tracking Content")).check(matches(isDisplayed()))
|
||||
onView(withText("Stops outside ads, videos, and other content from loading that contains tracking code. May affect some website functionality.")).check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
fun selectTrackingProtectionOption(option: String) = onView(withText(option)).click()
|
||||
|
||||
fun verifyEnhancedTrackingProtectionLevelSelected(option: String, checked: Boolean) {
|
||||
mDevice.wait(
|
||||
Until.findObject(By.text("Enhanced Tracking Protection")),
|
||||
waitingTime,
|
||||
)
|
||||
onView(withText(option))
|
||||
.check(
|
||||
matches(
|
||||
hasSibling(
|
||||
allOf(
|
||||
withId(R.id.radio_button),
|
||||
isChecked(checked),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
class Transition {
|
||||
fun goBackToHomeScreen(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
|
||||
// To settings
|
||||
@ -119,22 +185,14 @@ private fun assertEnhancedTrackingProtectionHeader() {
|
||||
|
||||
private fun assertEnhancedTrackingProtectionHeaderDescription() {
|
||||
onView(
|
||||
allOf(
|
||||
withParent(withParentIndex(0)),
|
||||
withText("Keep your data to yourself. $appName protects you from many of the most common trackers that follow what you do online."),
|
||||
),
|
||||
withText("Keep your data to yourself. $appName protects you from many of the most common trackers that follow what you do online."),
|
||||
)
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
}
|
||||
|
||||
private fun assertLearnMoreText() {
|
||||
onView(
|
||||
allOf(
|
||||
withParent(withParentIndex(0)),
|
||||
withText("Learn more"),
|
||||
),
|
||||
)
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
onView(withText("Learn more"))
|
||||
.check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
private fun assertEnhancedTrackingProtectionTextWithSwitchWidget() {
|
||||
@ -147,26 +205,6 @@ private fun assertEnhancedTrackingProtectionTextWithSwitchWidget() {
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
}
|
||||
|
||||
private fun assertEnhancedTrackingProtectionOptionsState(enabled: Boolean) {
|
||||
onView(withText("Standard (default)"))
|
||||
.check(matches(isEnabled(enabled)))
|
||||
|
||||
onView(withText(org.mozilla.fenix.R.string.preference_enhanced_tracking_protection_standard_description_4))
|
||||
.check(matches(isEnabled(enabled)))
|
||||
|
||||
onView(withText("Strict"))
|
||||
.check(matches(isEnabled(enabled)))
|
||||
|
||||
onView(withText(org.mozilla.fenix.R.string.preference_enhanced_tracking_protection_strict_description_3))
|
||||
.check(matches(isEnabled(enabled)))
|
||||
|
||||
onView(withText("Custom"))
|
||||
.check(matches(isEnabled(enabled)))
|
||||
|
||||
onView(withText(org.mozilla.fenix.R.string.preference_enhanced_tracking_protection_custom_description_2))
|
||||
.check(matches(isEnabled(enabled)))
|
||||
}
|
||||
|
||||
private fun assertTrackingProtectionSwitchEnabled() {
|
||||
onView(withResourceName("switch_widget")).check(
|
||||
matches(
|
||||
@ -177,23 +215,6 @@ private fun assertTrackingProtectionSwitchEnabled() {
|
||||
)
|
||||
}
|
||||
|
||||
private fun assertRadioButtonDefaults() {
|
||||
onView(
|
||||
withText("Strict"),
|
||||
).assertIsChecked(false)
|
||||
|
||||
onView(
|
||||
allOf(
|
||||
withId(org.mozilla.fenix.R.id.radio_button),
|
||||
hasSibling(withText("Standard (default)")),
|
||||
),
|
||||
).assertIsChecked(true)
|
||||
|
||||
onView(
|
||||
withText("Custom"),
|
||||
).assertIsChecked(false)
|
||||
}
|
||||
|
||||
fun settingsSubMenuEnhancedTrackingProtection(interact: SettingsSubMenuEnhancedTrackingProtectionRobot.() -> Unit): SettingsSubMenuEnhancedTrackingProtectionRobot.Transition {
|
||||
SettingsSubMenuEnhancedTrackingProtectionRobot().interact()
|
||||
return SettingsSubMenuEnhancedTrackingProtectionRobot.Transition()
|
||||
@ -205,17 +226,6 @@ private fun goBackButton() =
|
||||
private fun openExceptions() =
|
||||
onView(allOf(withText("Exceptions")))
|
||||
|
||||
private fun assertCustomTrackingProtectionSettings() {
|
||||
scrollToElementByText("Redirect Trackers")
|
||||
cookiesCheckbox().check(matches(isDisplayed()))
|
||||
cookiesDropDownMenuDefault().check(matches(isDisplayed()))
|
||||
trackingContentCheckbox().check(matches(isDisplayed()))
|
||||
trackingcontentDropDownDefault().check(matches(isDisplayed()))
|
||||
cryptominersCheckbox().check(matches(isDisplayed()))
|
||||
fingerprintersCheckbox().check(matches(isDisplayed()))
|
||||
redirectTrackersCheckbox().check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
private fun cookiesCheckbox() = onView(withText("Cookies"))
|
||||
|
||||
private fun cookiesDropDownMenuDefault() = onView(withText("Isolate cross-site cookies"))
|
||||
@ -229,3 +239,16 @@ private fun cryptominersCheckbox() = onView(withText("Cryptominers"))
|
||||
private fun fingerprintersCheckbox() = onView(withText("Fingerprinters"))
|
||||
|
||||
private fun redirectTrackersCheckbox() = onView(withText("Redirect Trackers"))
|
||||
|
||||
private fun blockedByStandardETPInfo() {
|
||||
onView(withText("Social Media Trackers")).check(matches(isDisplayed()))
|
||||
onView(withText("Limits the ability of social networks to track your browsing activity around the web.")).check(matches(isDisplayed()))
|
||||
onView(withText("Cross-Site Cookies")).check(matches(isDisplayed()))
|
||||
onView(withText("Total Cookie Protection isolates cookies to the site you’re on so trackers like ad networks can’t use them to follow you across sites.")).check(matches(isDisplayed()))
|
||||
onView(withText("Cryptominers")).check(matches(isDisplayed()))
|
||||
onView(withText("Prevents malicious scripts gaining access to your device to mine digital currency.")).check(matches(isDisplayed()))
|
||||
onView(withText("Fingerprinters")).check(matches(isDisplayed()))
|
||||
onView(withText("Stops uniquely identifiable data from being collected about your device that can be used for tracking purposes.")).check(matches(isDisplayed()))
|
||||
onView(withText("Redirect Trackers")).check(matches(isDisplayed()))
|
||||
onView(withText("Clears cookies set by redirects to known tracking websites.")).check(matches(isDisplayed()))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user