Skip to content

Commit 8034aeb

Browse files
committed
add wait for blocked tracking
1 parent b7c01d2 commit 8034aeb

File tree

5 files changed

+64
-8
lines changed

5 files changed

+64
-8
lines changed

modules/browser_object.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010
from modules.browser_object_search_bar_context_menu import *
1111
from modules.browser_object_tab_context_menu import *
1212
from modules.browser_object_tabbar import *
13+
from modules.browser_object_tracker_panel import *
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from modules.browser_object_navigation import Navigation
2+
from modules.page_base import BasePage
3+
4+
5+
class TrackerPanel(BasePage):
6+
"""
7+
BOM for the panel that shows up after clicking the shield
8+
"""
9+
10+
URL_TEMPLATE = ""
11+
NAV = None
12+
13+
def wait_for_blocked_tracking_icon(self, nav: Navigation, page: BasePage):
14+
"""
15+
Waits for the shield icon to indicate that cookies/trackers are being blocked by continuously refresing the page
16+
"""
17+
self.driver.set_context(self.driver.CONTEXT_CHROME)
18+
19+
while 1:
20+
nav.get_element("refresh-button").click()
21+
22+
self.driver.set_context(self.driver.CONTEXT_CONTENT)
23+
page.wait_for_page_to_load()
24+
25+
self.driver.set_context(self.driver.CONTEXT_CHROME)
26+
shield_icon = nav.get_element("shield-icon")
27+
28+
if (
29+
shield_icon.get_attribute("data-l10n-id")
30+
== "tracking-protection-icon-active-container"
31+
):
32+
return

modules/data/navigation.components.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@
189189
"shield-icon": {
190190
"selectorData": "tracking-protection-icon-container",
191191
"strategy": "id",
192-
"groups": []
192+
"groups": [
193+
"doNotCache"
194+
]
193195
},
194196

195197
"cryptominers": {
@@ -256,5 +258,19 @@
256258
"selectorData": "protections-popup-category-cryptominers",
257259
"strategy": "id",
258260
"groups": []
261+
},
262+
263+
"tracking-cross-site-tracking-items": {
264+
"selectorData": "protections-popup-cookiesView-list-section",
265+
"strategy": "class",
266+
"groups": []
267+
},
268+
269+
"refresh-button": {
270+
"selectorData": "reload-button",
271+
"strategy": "id",
272+
"groups": [
273+
"doNotCache"
274+
]
259275
}
260276
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
3+
}

tests/security_and_privacy/test_third_party_content_blocked_private_browsing.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
import pytest
55
from selenium.webdriver import Firefox
66

7-
from modules.browser_object import Navigation, PanelUi, TabBar
7+
from modules.browser_object import Navigation, PanelUi, TabBar, TrackerPanel
88
from modules.page_object import GenericPage
99

10-
11-
@pytest.fixture()
12-
def add_prefs():
13-
return [("browser.contentblocking.category", "standard")]
10+
# @pytest.fixture()
11+
# def add_prefs():
12+
# return [("browser.contentblocking.category", "standard")]
1413

1514

1615
def test_third_party_content_blocked_private_browsing(driver: Firefox):
@@ -19,6 +18,7 @@ def test_third_party_content_blocked_private_browsing(driver: Firefox):
1918
"""
2019
panel_ui = PanelUi(driver).open()
2120
nav = Navigation(driver)
21+
tracker_panel = TrackerPanel(driver)
2222
first_tracker_website = GenericPage(
2323
driver,
2424
url="https://senglehardt.com/test/trackingprotection/test_pages/tracking_protection.html",
@@ -31,14 +31,18 @@ def test_third_party_content_blocked_private_browsing(driver: Firefox):
3131
nav.switch_to_new_window()
3232

3333
first_tracker_website.open()
34+
35+
tracker_panel.wait_for_blocked_tracking_icon(nav, first_tracker_website)
36+
37+
# first_tracker_website.open()
3438
driver.set_context(driver.CONTEXT_CHROME)
3539

3640
shield_icon = nav.get_element("shield-icon")
3741

38-
# this could be labelled differently in different versions
42+
# # this could be labelled differently in different versions
3943
assert (
4044
shield_icon.get_attribute("data-l10n-id")
41-
== "tracking-protection-icon-no-trackers-detected-container"
45+
== "tracking-protection-icon-active-container"
4246
), "The label detected did not correspond to the expected one: tracking-protection-icon-no-trackers-detected-container"
4347
nav.open_tracker_panel()
4448

0 commit comments

Comments
 (0)