Skip to content

Commit 9e17110

Browse files
committed
Remove sleep statements and test failure debug attempts
1 parent f24bc82 commit 9e17110

File tree

6 files changed

+16
-40
lines changed

6 files changed

+16
-40
lines changed

.github/workflows/test.yml

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
echo "Linting errors"
2828
exit 1
2929
fi
30+
3031
test:
3132
runs-on: ubuntu-22.04
3233
continue-on-error: true

tests/selenium/content_filtering_test.py

+12-29
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
import pbtest
88

9-
import time
10-
119
class ContentFilteringTest(pbtest.PBSeleniumTest):
1210
"""Content filtering tests."""
1311

@@ -53,17 +51,14 @@ def test_blocking(self):
5351
self.assert_block()
5452

5553
# TODO sporadic "Cookie fixture should have set a cookie" failures
56-
@pytest.mark.flaky(reruns=7)
54+
@pytest.mark.flaky(reruns=5)
5755
def test_cookieblocking_stops_saving(self):
5856
self.load_url(f"https://{self.COOKIE_DOMAIN}/")
59-
time.sleep(1)
6057
assert not self.driver.get_cookies(), (
6158
"Visiting the domain directly does not set a cookie")
6259

6360
self.load_url(self.COOKIE_FIXTURE_URL)
64-
time.sleep(1)
6561
self.load_url(f"https://{self.COOKIE_DOMAIN}/")
66-
time.sleep(1)
6762
assert len(self.driver.get_cookies()) == 1, (
6863
"Cookie fixture should have set a cookie")
6964

@@ -79,14 +74,12 @@ def test_cookieblocking_stops_saving(self):
7974
@pytest.mark.flaky(reruns=7)
8075
def test_cookieblocking_stops_sending(self):
8176
self.load_url(self.COOKIE_FIXTURE_URL)
82-
time.sleep(1)
8377
self.wait_for_and_switch_to_frame("iframe[src]", timeout=1)
8478
self.wait_for_any_text('body')
8579
assert self.find_el_by_css('body').text == "cookies=0", (
8680
"No cookies should've been sent to start with")
8781

8882
self.load_url(self.COOKIE_FIXTURE_URL)
89-
time.sleep(1)
9083
self.wait_for_and_switch_to_frame("iframe[src]", timeout=1)
9184
self.wait_for_any_text('body')
9285
assert self.find_el_by_css('body').text == "cookies=1", (
@@ -95,7 +88,6 @@ def test_cookieblocking_stops_sending(self):
9588
self.cookieblock_domain(self.COOKIE_DOMAIN)
9689

9790
self.load_url(self.COOKIE_FIXTURE_URL)
98-
time.sleep(1)
9991
self.wait_for_and_switch_to_frame("iframe[src]", timeout=1)
10092
self.wait_for_any_text('body')
10193
assert self.find_el_by_css('body').text == "cookies=0", (
@@ -116,8 +108,7 @@ def test_cookieblocking_base_overwrites_subdomain_block(self):
116108
self.load_url(self.FIXTURE_URL + '?alt3p')
117109
self.assert_load()
118110

119-
# @pytest.mark.flaky(reruns=3, condition=pbtest.shim.browser_type == "edge")
120-
@pytest.mark.flaky(reruns=7)
111+
@pytest.mark.flaky(reruns=5)
121112
def test_blocking_fp_script_served_from_cookieblocked_cdn(self):
122113
"""Since we have a surrogate script for FingerprintJS served from
123114
cdn.jsdelivr.net, we need to test surrogation rather than blocking."""
@@ -138,12 +129,6 @@ def get_visitor_id():
138129
self.assert_load()
139130
visitor_id = get_visitor_id()
140131

141-
self.load_url(self.FIXTURE_URL + '?fingerprintjs')
142-
self.assert_load()
143-
visitor_id_2 = get_visitor_id()
144-
145-
print(f"=== Visitor ID 1: {visitor_id}, Visitor ID 2: {visitor_id_2} ====")
146-
147132
# enable local learning
148133
self.load_url(self.options_url)
149134
self.wait_for_script("return window.OPTIONS_INITIALIZED")
@@ -376,7 +361,7 @@ def test_reenabling_dnt_policy_checking(self):
376361
self.load_url(self.FIXTURE_URL)
377362
self.assert_load()
378363

379-
@pytest.mark.flaky(reruns=5)
364+
@pytest.mark.flaky(reruns=3)
380365
def test_removing_dnt(self):
381366
self.block_domain(self.THIRD_PARTY_DOMAIN)
382367
self.set_dnt(self.THIRD_PARTY_DOMAIN)
@@ -387,18 +372,16 @@ def test_removing_dnt(self):
387372
assert not self.check_dnt(self.THIRD_PARTY_DOMAIN), (
388373
"domain should not be DNT-compliant")
389374

390-
# DEBUGGING TEST FAILURES
391375
# poll for DNR to get updated
392-
# self.wait_for_script(
393-
# "let done = arguments[arguments.length - 1];"
394-
# "(async function () {"
395-
# " let { default: constants } = await import('../js/constants.js');"
396-
# " let rules = await chrome.declarativeNetRequest.getDynamicRules();"
397-
# " done(!rules.some(r => {"
398-
# " return (r.action.type == 'allow' && r.priority == constants.DNR_DNT_ALLOW);"
399-
# " }));"
400-
# "}());", execute_async=True)
401-
time.sleep(2.5)
376+
self.wait_for_script(
377+
"let done = arguments[arguments.length - 1];"
378+
"(async function () {"
379+
" let { default: constants } = await import('../js/constants.js');"
380+
" let rules = await chrome.declarativeNetRequest.getDynamicRules();"
381+
" done(!rules.some(r => {"
382+
" return (r.action.type == 'allow' && r.priority == constants.DNR_DNT_ALLOW);"
383+
" }));"
384+
"}());", execute_async=True)
402385

403386
self.load_url(self.FIXTURE_URL)
404387
self.assert_block()

tests/selenium/dnt_test.py

-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import json
44
import unittest
5-
import time
65

76
import pytest
87

@@ -183,7 +182,6 @@ def test_should_not_record_nontracking_domains(self):
183182
except NoSuchElementException:
184183
self.fail("Unable to find the non-tracking domain on the page")
185184

186-
time.sleep(2)
187185
action_map = self.get_badger_storage('action_map')
188186

189187
# verify that the cookie-tracking domain was recorded

tests/selenium/options_test.py

-3
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ def test_removing_domain(self):
123123
domains = []
124124
assert len(domains) == 0, "No domains should be displayed after removal"
125125

126-
@pytest.mark.flaky(reruns=3)
127126
def test_reset_data(self):
128127
self.load_options_page()
129128
self.select_domain_list_tab()
@@ -135,8 +134,6 @@ def test_reset_data(self):
135134

136135
# get the number of trackers in the seed data
137136
default_summary_text = self.driver.find_element(By.ID, "options_domain_list_trackers").text
138-
print("=========== default_summary_text: ===========")
139-
print(default_summary_text)
140137

141138
# Click on the "remove all data" button to empty the tracker lists, and
142139
# click "OK" in the popup that ensues

tests/selenium/pbtest.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ def fix_chrome_extension_id(self):
147147
def wants_xvfb(self):
148148
if self.on_github_actions or bool(int(os.environ.get('ENABLE_XVFB', 0))):
149149
try:
150-
print("========== wants_xvfb property set to true ==========")
151150
Xvfb
152151
except NameError:
153152
print("\nHeadless mode not supported: install xvfbwrapper first")
@@ -165,7 +164,6 @@ def on_github_actions(self):
165164
def chrome_manager(self):
166165
opts = ChromeOptions()
167166
opts.add_argument("--load-extension=" + self.extension_path)
168-
# opts.add_argument("--headless")
169167
opts.binary_location = self.browser_path
170168

171169
# work around https://issues.chromium.org/issues/409441960
@@ -193,7 +191,6 @@ def chrome_manager(self):
193191
@contextmanager
194192
def edge_manager(self):
195193
opts = EdgeOptions()
196-
# opts.add_argument("--headless")
197194
opts.add_argument("--load-extension=" + self.extension_path)
198195
opts.binary_location = self.browser_path
199196

@@ -217,7 +214,7 @@ def firefox_manager(self):
217214
for i in range(5):
218215
try:
219216
opts = FirefoxOptions()
220-
# opts.add_argument("--headless")
217+
221218
opts.binary_location = self.browser_path
222219

223220
# make extension ID constant across runs

tests/selenium/popup_test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_welcome_page_reminder_overlay(self):
4444
self.driver.find_element(By.ID, "intro-reminder-btn").click()
4545

4646
# switch to the welcome page or fail
47-
self.switch_to_window_with_url(self.first_run_url, max_tries=4)
47+
self.switch_to_window_with_url(self.first_run_url)
4848

4949
def test_help_button(self):
5050
"""Ensure FAQ website is opened when help button is clicked."""
@@ -76,7 +76,7 @@ def test_options_button(self):
7676
pass
7777
self.open_popup()
7878
self.driver.find_element(By.ID, "options").click()
79-
self.switch_to_window_with_url(self.options_url, max_tries=4)
79+
self.switch_to_window_with_url(self.options_url)
8080

8181
def test_trackers_link(self):
8282
"""Ensure trackers link opens EFF website."""

0 commit comments

Comments
 (0)