diff --git a/tests/security_and_privacy/test_blocking_cryptominers.py b/tests/security_and_privacy/test_blocking_cryptominers.py index 3e14dc1f..74029bb7 100644 --- a/tests/security_and_privacy/test_blocking_cryptominers.py +++ b/tests/security_and_privacy/test_blocking_cryptominers.py @@ -1,9 +1,7 @@ -from time import sleep - from selenium.webdriver import Firefox -from modules.browser_object_navigation import Navigation -from modules.page_object_about_prefs import AboutPrefs +from modules.browser_object import Navigation, TrackerPanel +from modules.page_object import AboutPrefs, GenericPage CRYPTOMINERS_URL = "https://senglehardt.com/test/trackingprotection/test_pages/fingerprinting_and_cryptomining.html" @@ -12,6 +10,8 @@ def test_blocking_cryptominers(driver: Firefox): # instantiate objects nav = Navigation(driver).open() about_prefs = AboutPrefs(driver, category="privacy").open() + tracker_panel = TrackerPanel(driver) + tracking_page = GenericPage(driver, url=CRYPTOMINERS_URL) # Select custom option and keep just cryptominers checked about_prefs.get_element("custom-radio").click() @@ -19,10 +19,10 @@ def test_blocking_cryptominers(driver: Firefox): about_prefs.get_element("tracking-checkbox").click() about_prefs.get_element("known-fingerprints-checkbox").click() about_prefs.get_element("suspected-fingerprints-checkbox").click() - sleep(2) # Access url and click on the shield icon and verify that cryptominers are blocked - driver.get(CRYPTOMINERS_URL) + tracking_page.open() + tracker_panel.wait_for_blocked_tracking_icon(nav, tracking_page) with driver.context(driver.CONTEXT_CHROME): nav.get_element("shield-icon").click() assert nav.get_element("cryptominers").is_displayed() diff --git a/tests/security_and_privacy/test_cryptominers_blocked_and_shown_in_info_panel.py b/tests/security_and_privacy/test_cryptominers_blocked_and_shown_in_info_panel.py index 0f8a23a9..138b1a5f 100644 --- a/tests/security_and_privacy/test_cryptominers_blocked_and_shown_in_info_panel.py +++ b/tests/security_and_privacy/test_cryptominers_blocked_and_shown_in_info_panel.py @@ -1,8 +1,7 @@ -from time import sleep - from selenium.webdriver import Firefox -from modules.browser_object_navigation import Navigation +from modules.browser_object import Navigation, TrackerPanel +from modules.page_object import GenericPage CRYPTOMINERS_URL = "https://senglehardt.com/test/trackingprotection/test_pages/fingerprinting_and_cryptomining.html" @@ -13,8 +12,11 @@ def test_cryptominers_blocked_and_shown_in_info_panel(driver: Firefox): """ # Access URL, needed sleep otherwise cryptomining will be displayed as unblocked nav = Navigation(driver) - sleep(4) - driver.get(CRYPTOMINERS_URL) + tracking_page = GenericPage(driver, url=CRYPTOMINERS_URL) + tracker_panel = TrackerPanel(driver) + + tracking_page.open() + tracker_panel.wait_for_blocked_tracking_icon(nav, tracking_page) # Click on the shield icon and verify that cryptominers are blocked with driver.context(driver.CONTEXT_CHROME): diff --git a/tests/security_and_privacy/test_trackers_crypto_fingerprint_blocked.py b/tests/security_and_privacy/test_trackers_crypto_fingerprint_blocked.py new file mode 100644 index 00000000..3d554169 --- /dev/null +++ b/tests/security_and_privacy/test_trackers_crypto_fingerprint_blocked.py @@ -0,0 +1,69 @@ +from time import sleep + +from selenium.webdriver import Firefox + +from modules.browser_object import Navigation, TrackerPanel +from modules.page_object import GenericPage + +TRACKER_URL = "https://senglehardt.com/test/trackingprotection/test_pages/fingerprinting_and_cryptomining_and_cookies.html" + + +def test_cross_site_trackrs_crypto_fingerprinter_blocked(driver: Firefox): + """ + C446393: Ensures that some trackers are blocked on certain website + """ + # instantiate objs + tracker_page = GenericPage(driver, url=TRACKER_URL) + tracker_panel = TrackerPanel(driver) + nav = Navigation(driver).open() + + # hard wait for fingerprinter blocker + sleep(4) + + # wait for the shield icon + tracker_page.open() + tracker_panel.wait_for_blocked_tracking_icon(nav, tracker_page) + nav.open_tracker_panel() + + # get children + driver.set_context(driver.CONTEXT_CHROME) + tracker_item_container = tracker_panel.get_element("tracking-item-container") + all_tracking_items = tracker_panel.get_all_children(tracker_item_container) + + # instantiate test specific objs + blocked = set(["Cross-Site Tracking Cookies", "Fingerprinters", "Cryptominers"]) + allowed = set(["Tracking Content"]) + rm_blocked = False + rm_allowed = False + + for item in all_tracking_items: + # encounter a header (everything after it is blocked/allowed in the list) + inner_html = item.get_attribute("innerHTML") + if "Blocked" in inner_html: + rm_blocked = True + continue + elif "Allowed" in inner_html: + rm_allowed = True + rm_blocked = False + continue + + # assign a temp memory location, assign the set to it depending on the header seen earlier + rm_set = set() + to_rm_item = "" + if rm_blocked: + rm_set = blocked + elif rm_allowed: + rm_set = allowed + + # go through the possible strings to look for, remove it if appropriate + for item in rm_set: + if item in inner_html: + to_rm_item = item + break + if to_rm_item != "": + rm_set.remove(to_rm_item) + + # ensure that we have seen all of the expected items in each section + assert ( + len(blocked) == 0 and len(allowed) == 0 + ), "Not all of the expected items were found in each of the Blocked/Allowed sections."