6
6
7
7
import pbtest
8
8
9
- import time
10
-
11
9
class ContentFilteringTest (pbtest .PBSeleniumTest ):
12
10
"""Content filtering tests."""
13
11
@@ -53,17 +51,14 @@ def test_blocking(self):
53
51
self .assert_block ()
54
52
55
53
# TODO sporadic "Cookie fixture should have set a cookie" failures
56
- @pytest .mark .flaky (reruns = 7 )
54
+ @pytest .mark .flaky (reruns = 5 )
57
55
def test_cookieblocking_stops_saving (self ):
58
56
self .load_url (f"https://{ self .COOKIE_DOMAIN } /" )
59
- time .sleep (1 )
60
57
assert not self .driver .get_cookies (), (
61
58
"Visiting the domain directly does not set a cookie" )
62
59
63
60
self .load_url (self .COOKIE_FIXTURE_URL )
64
- time .sleep (1 )
65
61
self .load_url (f"https://{ self .COOKIE_DOMAIN } /" )
66
- time .sleep (1 )
67
62
assert len (self .driver .get_cookies ()) == 1 , (
68
63
"Cookie fixture should have set a cookie" )
69
64
@@ -79,14 +74,12 @@ def test_cookieblocking_stops_saving(self):
79
74
@pytest .mark .flaky (reruns = 7 )
80
75
def test_cookieblocking_stops_sending (self ):
81
76
self .load_url (self .COOKIE_FIXTURE_URL )
82
- time .sleep (1 )
83
77
self .wait_for_and_switch_to_frame ("iframe[src]" , timeout = 1 )
84
78
self .wait_for_any_text ('body' )
85
79
assert self .find_el_by_css ('body' ).text == "cookies=0" , (
86
80
"No cookies should've been sent to start with" )
87
81
88
82
self .load_url (self .COOKIE_FIXTURE_URL )
89
- time .sleep (1 )
90
83
self .wait_for_and_switch_to_frame ("iframe[src]" , timeout = 1 )
91
84
self .wait_for_any_text ('body' )
92
85
assert self .find_el_by_css ('body' ).text == "cookies=1" , (
@@ -95,7 +88,6 @@ def test_cookieblocking_stops_sending(self):
95
88
self .cookieblock_domain (self .COOKIE_DOMAIN )
96
89
97
90
self .load_url (self .COOKIE_FIXTURE_URL )
98
- time .sleep (1 )
99
91
self .wait_for_and_switch_to_frame ("iframe[src]" , timeout = 1 )
100
92
self .wait_for_any_text ('body' )
101
93
assert self .find_el_by_css ('body' ).text == "cookies=0" , (
@@ -116,8 +108,7 @@ def test_cookieblocking_base_overwrites_subdomain_block(self):
116
108
self .load_url (self .FIXTURE_URL + '?alt3p' )
117
109
self .assert_load ()
118
110
119
- # @pytest.mark.flaky(reruns=3, condition=pbtest.shim.browser_type == "edge")
120
- @pytest .mark .flaky (reruns = 7 )
111
+ @pytest .mark .flaky (reruns = 5 )
121
112
def test_blocking_fp_script_served_from_cookieblocked_cdn (self ):
122
113
"""Since we have a surrogate script for FingerprintJS served from
123
114
cdn.jsdelivr.net, we need to test surrogation rather than blocking."""
@@ -138,12 +129,6 @@ def get_visitor_id():
138
129
self .assert_load ()
139
130
visitor_id = get_visitor_id ()
140
131
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
-
147
132
# enable local learning
148
133
self .load_url (self .options_url )
149
134
self .wait_for_script ("return window.OPTIONS_INITIALIZED" )
@@ -376,7 +361,7 @@ def test_reenabling_dnt_policy_checking(self):
376
361
self .load_url (self .FIXTURE_URL )
377
362
self .assert_load ()
378
363
379
- @pytest .mark .flaky (reruns = 5 )
364
+ @pytest .mark .flaky (reruns = 3 )
380
365
def test_removing_dnt (self ):
381
366
self .block_domain (self .THIRD_PARTY_DOMAIN )
382
367
self .set_dnt (self .THIRD_PARTY_DOMAIN )
@@ -387,18 +372,16 @@ def test_removing_dnt(self):
387
372
assert not self .check_dnt (self .THIRD_PARTY_DOMAIN ), (
388
373
"domain should not be DNT-compliant" )
389
374
390
- # DEBUGGING TEST FAILURES
391
375
# 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 )
402
385
403
386
self .load_url (self .FIXTURE_URL )
404
387
self .assert_block ()
0 commit comments