Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(390)

Side by Side Diff: tools/chrome_proxy/webdriver/lite_page.py

Issue 2910783002: Adds Lo-Fi fallback support for new Data Reduction Proxy protocol. (Closed)
Patch Set: Renamed helper method from Update* to Get* Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/test/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import time 9 import time
10 10
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 'document.body.scrollHeight') 121 'document.body.scrollHeight')
122 self.assertGreater(new_scroll_height, original_scroll_height) 122 self.assertGreater(new_scroll_height, original_scroll_height)
123 123
124 # Make sure there were more requests that were proxied. 124 # Make sure there were more requests that were proxied.
125 responses = test_driver.GetHTTPResponses(override_has_logs=True) 125 responses = test_driver.GetHTTPResponses(override_has_logs=True)
126 self.assertNotEqual(0, len(responses)) 126 self.assertNotEqual(0, len(responses))
127 for response in responses: 127 for response in responses:
128 self.assertHasChromeProxyViaHeader(response) 128 self.assertHasChromeProxyViaHeader(response)
129 self.assertIn(response.status, [200, 204]) 129 self.assertIn(response.status, [200, 204])
130 130
131 # Lo-Fi fallback is not currently supported via the client. Check that 131 # Lo-Fi fallback is not supported without the
132 # no Lo-Fi response is received if a Lite Page is not served. 132 # DataReductionProxyDecidesTransform feature. Check that no Lo-Fi response
133 def testLitePageFallback(self): 133 # is received if a Lite Page is not served.
134 def testLitePageNoFallback(self):
134 with TestDriver() as test_driver: 135 with TestDriver() as test_driver:
135 test_driver.AddChromeArg('--enable-spdy-proxy-auth') 136 test_driver.AddChromeArg('--enable-spdy-proxy-auth')
136 test_driver.AddChromeArg('--force-fieldtrials=' 137 test_driver.AddChromeArg('--force-fieldtrials='
137 'DataCompressionProxyLoFi/Enabled_Preview/') 138 'DataCompressionProxyLoFi/Enabled_Preview/')
138 test_driver.AddChromeArg('--force-fieldtrial-params=' 139 test_driver.AddChromeArg('--force-fieldtrial-params='
139 'DataCompressionProxyLoFi.Enabled_Preview:' 140 'DataCompressionProxyLoFi.Enabled_Preview:'
140 'effective_connection_type/4G') 141 'effective_connection_type/4G')
141 test_driver.AddChromeArg('--force-net-effective-connection-type=2g') 142 test_driver.AddChromeArg('--force-net-effective-connection-type=2g')
142 143
143 test_driver.LoadURL('http://check.googlezip.net/lite-page-fallback') 144 test_driver.LoadURL('http://check.googlezip.net/lite-page-fallback')
(...skipping 14 matching lines...) Expand all
158 if not response.url.endswith('png'): 159 if not response.url.endswith('png'):
159 continue 160 continue
160 161
161 # Lo-Fi fallback is not currently supported via the client. Check that 162 # Lo-Fi fallback is not currently supported via the client. Check that
162 # no Lo-Fi response is received. 163 # no Lo-Fi response is received.
163 self.checkLoFiResponse(response, False) 164 self.checkLoFiResponse(response, False)
164 165
165 # Verify that a Lite Page was requested. 166 # Verify that a Lite Page was requested.
166 self.assertEqual(1, lite_page_requests) 167 self.assertEqual(1, lite_page_requests)
167 168
169 # Verifies Lo-Fi fallback via the page-policies server directive.
170 # Note: this test is for the CPAT protocol change in M-61.
171 def testLitePageFallbackViaPagePolicies(self):
172 with TestDriver() as test_driver:
173 test_driver.AddChromeArg('--enable-spdy-proxy-auth')
174 test_driver.AddChromeArg('--enable-features='
175 'DataReductionProxyDecidesTransform')
176 test_driver.AddChromeArg('--force-fieldtrial-params='
177 'NetworkQualityEstimator.Enabled:'
178 'force_effective_connection_type/Slow2G,'
179 'DataCompressionProxyLoFi.Enabled_Preview:'
180 'effective_connection_type/2G')
181 test_driver.AddChromeArg('--force-fieldtrials='
182 'NetworkQualityEstimator/Enabled/'
183 'DataCompressionProxyLoFi/Enabled_Preview')
184
185 test_driver.LoadURL('http://check.googlezip.net/lite-page-fallback')
186
187 lite_page_responses = 0
188 lofi_resource = 0
189 for response in test_driver.GetHTTPResponses():
190 self.assertEqual('Slow-2G',
191 response.request_headers['chrome-proxy-ect'])
192
193 if response.url.endswith('html'):
194 # Verify that the server provides the fallback directive
195 self.assertIn('page-policies=empty-image',
196 response.response_headers['chrome-proxy'])
197 # Main resource should not accept and transform to lite page.
198 if self.checkLitePageResponse(response):
199 lite_page_responses = lite_page_responses + 1
200 if response.url.endswith('png'):
201 if self.checkLoFiResponse(response, True):
202 lofi_resource = lofi_resource + 1
203
204 self.assertEqual(0, lite_page_responses)
205 self.assertNotEqual(0, lofi_resource)
206 self.assertNotEqual(0, lofi_resource)
207
208 # Checks that the server provides Lite Page for a 2G connection.
209 # Note: this test is for the CPAT protocol change in M-61.
210 def testLitePageProvidedForSlowConnection(self):
211 with TestDriver() as test_driver:
212 test_driver.AddChromeArg('--enable-spdy-proxy-auth')
213 test_driver.AddChromeArg('--enable-features='
214 'DataReductionProxyDecidesTransform')
215 test_driver.AddChromeArg('--force-fieldtrial-params='
216 'NetworkQualityEstimator.Enabled:'
217 'force_effective_connection_type/2G,'
218 'DataCompressionProxyLoFi.Enabled_Preview:'
219 'effective_connection_type/2G')
220 test_driver.AddChromeArg('--force-fieldtrials='
221 'NetworkQualityEstimator/Enabled/'
222 'DataCompressionProxyLoFi/Enabled_Preview')
223
224 test_driver.LoadURL('http://check.googlezip.net/test.html')
225
226 lite_page_responses = 0
227 page_policies_responses = 0
228 for response in test_driver.GetHTTPResponses():
229 self.assertEqual('2G', response.request_headers['chrome-proxy-ect'])
230 if response.url.endswith('html'):
231 if self.checkLitePageResponse(response):
232 lite_page_responses = lite_page_responses + 1
233 elif 'chrome-proxy' in response.response_headers:
234 self.assertIn('page-policies',
235 response.response_headers['chrome-proxy'])
236 page_policies_responses = page_policies_responses + 1
237
238 # TODO(dougarnett): add specific response check if we can control
239 # whether weblite supported or not for the client (b/62444738).
240 self.assertTrue(lite_page_responses == 1 or page_policies_responses == 1)
241
242 # Checks that the server does not provide Lite Page nor fallback
243 # for a fast connection.
244 # Note: this test is for the CPAT protocol change in M-61.
245 def testLitePageNotProvidedForFastConnection(self):
246 with TestDriver() as test_driver:
247 test_driver.AddChromeArg('--enable-spdy-proxy-auth')
248 test_driver.AddChromeArg('--enable-features='
249 'DataReductionProxyDecidesTransform')
250 test_driver.AddChromeArg('--force-fieldtrial-params='
251 'NetworkQualityEstimator.Enabled:'
252 'force_effective_connection_type/4G,'
253 'DataCompressionProxyLoFi.Enabled_Preview:'
254 'effective_connection_type/2G')
255 test_driver.AddChromeArg('--force-fieldtrials='
256 'NetworkQualityEstimator/Enabled/'
257 'DataCompressionProxyLoFi/Enabled_Preview')
258
259 test_driver.LoadURL('http://check.googlezip.net/test.html')
260
261 for response in test_driver.GetHTTPResponses():
262 self.assertEqual('4G', response.request_headers['chrome-proxy-ect'])
263 if response.url.endswith('html'):
264 # Main resource should accept lite page but not be transformed.
265 self.assertEqual('lite-page',
266 response.request_headers['chrome-proxy-accept-transform'])
267 self.assertNotIn('chrome-proxy-content-transform',
268 response.response_headers)
269 # Expect no fallback page policy
270 if 'chrome-proxy' in response.response_headers:
271 self.assertNotIn('page-policies',
272 response.response_headers['chrome-proxy'])
273 else:
274 # No subresources should accept transforms.
275 self.assertNotIn('chrome-proxy-accept-transform',
276 response.request_headers)
277
168 if __name__ == '__main__': 278 if __name__ == '__main__':
169 IntegrationTest.RunAllTests() 279 IntegrationTest.RunAllTests()
OLDNEW
« no previous file with comments | « content/test/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698