OLD | NEW |
---|---|
1 # Copyright 2017 The Chromium Authors. All rights reserved. | 1 # Copyright 2017 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import common | 5 import common |
6 from common import TestDriver | 6 from common import TestDriver |
7 from common import IntegrationTest | 7 from common import IntegrationTest |
8 | 8 |
9 | 9 |
10 class LoFi(IntegrationTest): | 10 class LoFi(IntegrationTest): |
(...skipping 16 matching lines...) Expand all Loading... | |
27 if not response.url.endswith('png'): | 27 if not response.url.endswith('png'): |
28 continue | 28 continue |
29 if not response.request_headers: | 29 if not response.request_headers: |
30 continue | 30 continue |
31 if (self.checkLoFiResponse(response, True)): | 31 if (self.checkLoFiResponse(response, True)): |
32 lofi_responses = lofi_responses + 1 | 32 lofi_responses = lofi_responses + 1 |
33 | 33 |
34 # Verify that Lo-Fi responses were seen. | 34 # Verify that Lo-Fi responses were seen. |
35 self.assertNotEqual(0, lofi_responses) | 35 self.assertNotEqual(0, lofi_responses) |
36 | 36 |
37 # Checks that LoFi images are served when LoFi slow connections are used and | |
38 # the network quality estimator returns Slow2G. | |
39 def testLoFiSlowConnection(self): | |
40 with TestDriver() as test_driver: | |
41 test_driver.AddChromeArg('--enable-spdy-proxy-auth') | |
42 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=slow-connections-' | |
43 'only') | |
44 # Disable server experiments such as tamper detection. | |
bengr
2017/04/27 18:45:49
nit: remove "such as tamper detection"
RyanSturm
2017/04/27 18:50:32
Done.
| |
45 test_driver.AddChromeArg('--data-reduction-proxy-server-experiments-' | |
46 'disabled') | |
47 | |
48 test_driver.AddChromeArg('--force-fieldtrial-params=' | |
49 'NetworkQualityEstimator.Enabled:' | |
50 'force_effective_connection_type/Slow2G') | |
51 test_driver.AddChromeArg('--force-fieldtrials=NetworkQualityEstimator/' | |
52 'Enabled') | |
53 | |
54 test_driver.LoadURL('http://check.googlezip.net/static/index.html') | |
55 | |
56 lofi_responses = 0 | |
57 for response in test_driver.GetHTTPResponses(): | |
58 if not response.url.endswith('png'): | |
59 continue | |
60 if not response.request_headers: | |
61 continue | |
62 if (self.checkLoFiResponse(response, True)): | |
63 lofi_responses = lofi_responses + 1 | |
64 | |
65 # Verify that Lo-Fi responses were seen. | |
66 self.assertNotEqual(0, lofi_responses) | |
67 | |
68 # Checks that LoFi images are not served, but the if-heavy CPAT header is | |
69 # added when LoFi slow connections are used and the network quality estimator | |
70 # returns 4G. | |
71 def testLoFiIfHeavyFastConnection(self): | |
72 with TestDriver() as test_driver: | |
73 test_driver.AddChromeArg('--enable-spdy-proxy-auth') | |
74 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=slow-connections-' | |
75 'only') | |
76 # Disable server experiments such as tamper detection. | |
77 test_driver.AddChromeArg('--data-reduction-proxy-server-experiments-' | |
78 'disabled') | |
79 | |
80 test_driver.AddChromeArg('--force-fieldtrial-params=' | |
81 'NetworkQualityEstimator.Enabled:' | |
82 'force_effective_connection_type/4G') | |
83 test_driver.AddChromeArg('--force-fieldtrials=NetworkQualityEstimator/' | |
84 'Enabled') | |
85 | |
86 test_driver.LoadURL('http://check.googlezip.net/static/index.html') | |
87 | |
88 non_lofi_responses = 0 | |
89 for response in test_driver.GetHTTPResponses(): | |
90 if not response.url.endswith('png'): | |
91 continue | |
92 if not response.request_headers: | |
93 continue | |
94 self.assertIn('chrome-proxy-accept-transform', response.request_headers) | |
95 actual_cpat_headers = \ | |
96 response.request_headers['chrome-proxy-accept-transform'].split(';') | |
97 self.assertIn('empty-image', actual_cpat_headers) | |
98 self.assertIn('if-heavy', actual_cpat_headers) | |
99 if (not self.checkLoFiResponse(response, False)): | |
100 non_lofi_responses = non_lofi_responses + 1 | |
101 | |
102 # Verify that non Lo-Fi image responses were seen. | |
103 self.assertNotEqual(0, non_lofi_responses) | |
104 | |
37 # Checks that Lo-Fi placeholder images are not loaded from cache on page | 105 # Checks that Lo-Fi placeholder images are not loaded from cache on page |
38 # reloads when Lo-Fi mode is disabled or data reduction proxy is disabled. | 106 # reloads when Lo-Fi mode is disabled or data reduction proxy is disabled. |
39 # First a test page is opened with Lo-Fi and chrome proxy enabled. This allows | 107 # First a test page is opened with Lo-Fi and chrome proxy enabled. This allows |
40 # Chrome to cache the Lo-Fi placeholder image. The browser is restarted with | 108 # Chrome to cache the Lo-Fi placeholder image. The browser is restarted with |
41 # chrome proxy disabled and the same test page is loaded. This second page | 109 # chrome proxy disabled and the same test page is loaded. This second page |
42 # load should not pick the Lo-Fi placeholder from cache and original image | 110 # load should not pick the Lo-Fi placeholder from cache and original image |
43 # should be loaded. Finally, the browser is restarted with chrome proxy | 111 # should be loaded. Finally, the browser is restarted with chrome proxy |
44 # enabled and Lo-Fi disabled and the same test page is loaded. This third page | 112 # enabled and Lo-Fi disabled and the same test page is loaded. This third page |
45 # load should not pick the Lo-Fi placeholder from cache and original image | 113 # load should not pick the Lo-Fi placeholder from cache and original image |
46 # should be loaded. | 114 # should be loaded. |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 continue | 175 continue |
108 responses = responses + 1 | 176 responses = responses + 1 |
109 self.assertHasChromeProxyViaHeader(response) | 177 self.assertHasChromeProxyViaHeader(response) |
110 self.checkLoFiResponse(response, False) | 178 self.checkLoFiResponse(response, False) |
111 | 179 |
112 # Verify that responses were seen. | 180 # Verify that responses were seen. |
113 self.assertNotEqual(0, responses) | 181 self.assertNotEqual(0, responses) |
114 | 182 |
115 if __name__ == '__main__': | 183 if __name__ == '__main__': |
116 IntegrationTest.RunAllTests() | 184 IntegrationTest.RunAllTests() |
OLD | NEW |