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

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

Issue 2941103002: Adds lite page integration test (ignoring country blacklist). (Closed)
Patch Set: Renames two triggering tests to be less specific wrt actual previews server selects. 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 | « no previous file | tools/chrome_proxy/webdriver/lofi.py » ('j') | 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 from decorators import ChromeVersionEqualOrAfterM 8 from decorators import ChromeVersionEqualOrAfterM
9 9
10 import time 10 import time
11 11
12 class LitePage(IntegrationTest): 12 class LitePage(IntegrationTest):
13 13
14 # Verifies that a Lite Page is served for slow connection if any copyright
15 # restricted country blacklist is ignored.
16 # Note: this test is for the CPAT protocol change in M-61.
17 @ChromeVersionEqualOrAfterM(61)
18 def testLitePageWithoutCopyrightRestriction(self):
19 # If it was attempted to run with another experiment, skip this test.
20 if common.ParseFlags().browser_args and ('--data-reduction-proxy-experiment'
21 in common.ParseFlags().browser_args):
22 self.skipTest('This test cannot be run with other experiments.')
23 with TestDriver() as test_driver:
24 test_driver.AddChromeArg('--enable-spdy-proxy-auth')
25 test_driver.AddChromeArg('--enable-features='
26 'DataReductionProxyDecidesTransform')
27 test_driver.AddChromeArg(
28 '--force-fieldtrial-params=NetworkQualityEstimator.Enabled:'
29 'force_effective_connection_type/2G,'
30 'DataReductionProxyServerExperiments.IgnoreCountryBlacklist:'
31 'exp/ignore_preview_blacklist')
32 test_driver.AddChromeArg(
33 '--force-fieldtrials=NetworkQualityEstimator/Enabled/'
34 'DataReductionProxyServerExperiments/IgnoreCountryBlacklist')
35
36 test_driver.LoadURL('http://check.googlezip.net/test.html')
37
38 lite_page_responses = 0
39 for response in test_driver.GetHTTPResponses():
40 # Verify client sends ignore directive on every request for session.
41 self.assertIn('exp=ignore_preview_blacklist',
42 response.request_headers['chrome-proxy'])
43 self.assertEqual('2G', response.request_headers['chrome-proxy-ect'])
44 if response.url.endswith('html'):
45 self.assertTrue(self.checkLitePageResponse(response))
46 lite_page_responses = lite_page_responses + 1
47 # Expect no fallback page policy
48 if 'chrome-proxy' in response.response_headers:
49 self.assertNotIn('page-policies',
50 response.response_headers['chrome-proxy'])
51 else:
52 # No subresources should accept transforms.
53 self.assertNotIn('chrome-proxy-accept-transform',
54 response.request_headers)
55
56 # Verify that a Lite Page response for the main frame was seen.
57 self.assertEqual(1, lite_page_responses)
58
14 # Checks that a Lite Page is served and the force_lite_page experiment 59 # Checks that a Lite Page is served and the force_lite_page experiment
15 # directive is provided when always-on. 60 # directive is provided when always-on.
16 def testLitePageForcedExperiment(self): 61 def testLitePageForcedExperiment(self):
17 # If it was attempted to run with another experiment, skip this test. 62 # If it was attempted to run with another experiment, skip this test.
18 if common.ParseFlags().browser_args and ('--data-reduction-proxy-experiment' 63 if common.ParseFlags().browser_args and ('--data-reduction-proxy-experiment'
19 in common.ParseFlags().browser_args): 64 in common.ParseFlags().browser_args):
20 self.skipTest('This test cannot be run with other experiments.') 65 self.skipTest('This test cannot be run with other experiments.')
21 with TestDriver() as test_driver: 66 with TestDriver() as test_driver:
22 test_driver.AddChromeArg('--enable-spdy-proxy-auth') 67 test_driver.AddChromeArg('--enable-spdy-proxy-auth')
23 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=always-on') 68 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=always-on')
(...skipping 20 matching lines...) Expand all
44 if '/csi?' in response.url: 89 if '/csi?' in response.url:
45 continue 90 continue
46 if response.url.startswith('data:'): 91 if response.url.startswith('data:'):
47 continue 92 continue
48 if (self.checkLitePageResponse(response)): 93 if (self.checkLitePageResponse(response)):
49 lite_page_responses = lite_page_responses + 1 94 lite_page_responses = lite_page_responses + 1
50 95
51 # Verify that a Lite Page response for the main frame was seen. 96 # Verify that a Lite Page response for the main frame was seen.
52 self.assertEqual(1, lite_page_responses) 97 self.assertEqual(1, lite_page_responses)
53 98
54
55 # Checks that a Lite Page is not served for the Cellular-Only option but 99 # Checks that a Lite Page is not served for the Cellular-Only option but
56 # not on cellular connection. 100 # not on cellular connection.
57 def testLitePageNotAcceptedForCellularOnlyFlag(self): 101 def testLitePageNotAcceptedForCellularOnlyFlag(self):
58 with TestDriver() as test_driver: 102 with TestDriver() as test_driver:
59 test_driver.AddChromeArg('--enable-spdy-proxy-auth') 103 test_driver.AddChromeArg('--enable-spdy-proxy-auth')
60 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=cellular-only') 104 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=cellular-only')
61 test_driver.AddChromeArg('--enable-data-reduction-proxy-lite-page') 105 test_driver.AddChromeArg('--enable-data-reduction-proxy-lite-page')
62 106
63 test_driver.LoadURL('http://check.googlezip.net/test.html') 107 test_driver.LoadURL('http://check.googlezip.net/test.html')
64 108
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 # Verifies Lo-Fi fallback via the page-policies server directive. 214 # Verifies Lo-Fi fallback via the page-policies server directive.
171 # Note: this test is for the CPAT protocol change in M-61. 215 # Note: this test is for the CPAT protocol change in M-61.
172 @ChromeVersionEqualOrAfterM(61) 216 @ChromeVersionEqualOrAfterM(61)
173 def testLitePageFallbackViaPagePolicies(self): 217 def testLitePageFallbackViaPagePolicies(self):
174 with TestDriver() as test_driver: 218 with TestDriver() as test_driver:
175 test_driver.AddChromeArg('--enable-spdy-proxy-auth') 219 test_driver.AddChromeArg('--enable-spdy-proxy-auth')
176 test_driver.AddChromeArg('--enable-features=' 220 test_driver.AddChromeArg('--enable-features='
177 'DataReductionProxyDecidesTransform') 221 'DataReductionProxyDecidesTransform')
178 test_driver.AddChromeArg('--force-fieldtrial-params=' 222 test_driver.AddChromeArg('--force-fieldtrial-params='
179 'NetworkQualityEstimator.Enabled:' 223 'NetworkQualityEstimator.Enabled:'
180 'force_effective_connection_type/Slow2G,' 224 'force_effective_connection_type/Slow2G')
181 'DataCompressionProxyLoFi.Enabled_Preview:'
182 'effective_connection_type/2G')
183 test_driver.AddChromeArg('--force-fieldtrials=' 225 test_driver.AddChromeArg('--force-fieldtrials='
184 'NetworkQualityEstimator/Enabled/' 226 'NetworkQualityEstimator/Enabled/')
185 'DataCompressionProxyLoFi/Enabled_Preview')
186 227
187 test_driver.LoadURL('http://check.googlezip.net/lite-page-fallback') 228 test_driver.LoadURL('http://check.googlezip.net/lite-page-fallback')
188 229
189 lite_page_responses = 0 230 lite_page_responses = 0
190 lofi_resource = 0 231 lofi_resource = 0
191 for response in test_driver.GetHTTPResponses(): 232 for response in test_driver.GetHTTPResponses():
192 self.assertEqual('Slow-2G', 233 self.assertEqual('Slow-2G',
193 response.request_headers['chrome-proxy-ect']) 234 response.request_headers['chrome-proxy-ect'])
194 235
195 if response.url.endswith('html'): 236 if response.url.endswith('html'):
196 # Verify that the server provides the fallback directive 237 # Verify that the server provides the fallback directive
197 self.assertIn('page-policies=empty-image', 238 self.assertIn('page-policies=empty-image',
198 response.response_headers['chrome-proxy']) 239 response.response_headers['chrome-proxy'])
199 # Main resource should not accept and transform to lite page. 240 # Main resource should not accept and transform to lite page.
200 if self.checkLitePageResponse(response): 241 if self.checkLitePageResponse(response):
201 lite_page_responses = lite_page_responses + 1 242 lite_page_responses = lite_page_responses + 1
202 if response.url.endswith('png'): 243 if response.url.endswith('png'):
203 if self.checkLoFiResponse(response, True): 244 if self.checkLoFiResponse(response, True):
204 lofi_resource = lofi_resource + 1 245 lofi_resource = lofi_resource + 1
205 246
206 self.assertEqual(0, lite_page_responses) 247 self.assertEqual(0, lite_page_responses)
207 self.assertNotEqual(0, lofi_resource) 248 self.assertNotEqual(0, lofi_resource)
208 self.assertNotEqual(0, lofi_resource) 249 self.assertNotEqual(0, lofi_resource)
209 250
210 # Checks that the server provides Lite Page for a 2G connection. 251 # Checks that the server provides a preview (either Lite Page or fallback
252 # to LoFi) for a 2G connection.
211 # Note: this test is for the CPAT protocol change in M-61. 253 # Note: this test is for the CPAT protocol change in M-61.
212 def testLitePageProvidedForSlowConnection(self): 254 @ChromeVersionEqualOrAfterM(61)
255 def testPreviewProvidedForSlowConnection(self):
213 with TestDriver() as test_driver: 256 with TestDriver() as test_driver:
214 test_driver.AddChromeArg('--enable-spdy-proxy-auth') 257 test_driver.AddChromeArg('--enable-spdy-proxy-auth')
215 test_driver.AddChromeArg('--enable-features=' 258 test_driver.AddChromeArg('--enable-features='
216 'DataReductionProxyDecidesTransform') 259 'DataReductionProxyDecidesTransform')
217 test_driver.AddChromeArg('--force-fieldtrial-params=' 260 test_driver.AddChromeArg('--force-fieldtrial-params='
218 'NetworkQualityEstimator.Enabled:' 261 'NetworkQualityEstimator.Enabled:'
219 'force_effective_connection_type/2G,' 262 'force_effective_connection_type/2G')
220 'DataCompressionProxyLoFi.Enabled_Preview:'
221 'effective_connection_type/2G')
222 test_driver.AddChromeArg('--force-fieldtrials=' 263 test_driver.AddChromeArg('--force-fieldtrials='
223 'NetworkQualityEstimator/Enabled/' 264 'NetworkQualityEstimator/Enabled/')
224 'DataCompressionProxyLoFi/Enabled_Preview')
225 265
226 test_driver.LoadURL('http://check.googlezip.net/test.html') 266 test_driver.LoadURL('http://check.googlezip.net/test.html')
227 267
228 lite_page_responses = 0 268 lite_page_responses = 0
229 page_policies_responses = 0 269 page_policies_responses = 0
230 for response in test_driver.GetHTTPResponses(): 270 for response in test_driver.GetHTTPResponses():
231 self.assertEqual('2G', response.request_headers['chrome-proxy-ect']) 271 self.assertEqual('2G', response.request_headers['chrome-proxy-ect'])
232 if response.url.endswith('html'): 272 if response.url.endswith('html'):
233 if self.checkLitePageResponse(response): 273 if self.checkLitePageResponse(response):
234 lite_page_responses = lite_page_responses + 1 274 lite_page_responses = lite_page_responses + 1
235 elif 'chrome-proxy' in response.response_headers: 275 elif 'chrome-proxy' in response.response_headers:
236 self.assertIn('page-policies', 276 self.assertIn('page-policies',
237 response.response_headers['chrome-proxy']) 277 response.response_headers['chrome-proxy'])
238 page_policies_responses = page_policies_responses + 1 278 page_policies_responses = page_policies_responses + 1
239 279
240 # TODO(dougarnett): add specific response check if we can control
241 # whether weblite supported or not for the client (b/62444738).
242 self.assertTrue(lite_page_responses == 1 or page_policies_responses == 1) 280 self.assertTrue(lite_page_responses == 1 or page_policies_responses == 1)
243 281
244 # Checks that the server does not provide Lite Page nor fallback 282 # Checks that the server does not provide a preview (neither Lite Page nor
245 # for a fast connection. 283 # fallback to LoFi) for a fast connection.
246 # Note: this test is for the CPAT protocol change in M-61. 284 # Note: this test is for the CPAT protocol change in M-61.
247 def testLitePageNotProvidedForFastConnection(self): 285 @ChromeVersionEqualOrAfterM(61)
286 def testPreviewNotProvidedForFastConnection(self):
248 with TestDriver() as test_driver: 287 with TestDriver() as test_driver:
249 test_driver.AddChromeArg('--enable-spdy-proxy-auth') 288 test_driver.AddChromeArg('--enable-spdy-proxy-auth')
250 test_driver.AddChromeArg('--enable-features=' 289 test_driver.AddChromeArg('--enable-features='
251 'DataReductionProxyDecidesTransform') 290 'DataReductionProxyDecidesTransform')
252 test_driver.AddChromeArg('--force-fieldtrial-params=' 291 test_driver.AddChromeArg('--force-fieldtrial-params='
253 'NetworkQualityEstimator.Enabled:' 292 'NetworkQualityEstimator.Enabled:'
254 'force_effective_connection_type/4G,' 293 'force_effective_connection_type/4G')
255 'DataCompressionProxyLoFi.Enabled_Preview:'
256 'effective_connection_type/2G')
257 test_driver.AddChromeArg('--force-fieldtrials=' 294 test_driver.AddChromeArg('--force-fieldtrials='
258 'NetworkQualityEstimator/Enabled/' 295 'NetworkQualityEstimator/Enabled/')
259 'DataCompressionProxyLoFi/Enabled_Preview')
260 296
261 test_driver.LoadURL('http://check.googlezip.net/test.html') 297 test_driver.LoadURL('http://check.googlezip.net/test.html')
262 298
263 for response in test_driver.GetHTTPResponses(): 299 for response in test_driver.GetHTTPResponses():
264 self.assertEqual('4G', response.request_headers['chrome-proxy-ect']) 300 self.assertEqual('4G', response.request_headers['chrome-proxy-ect'])
265 if response.url.endswith('html'): 301 if response.url.endswith('html'):
266 # Main resource should accept lite page but not be transformed. 302 # Main resource should accept lite page but not be transformed.
267 self.assertEqual('lite-page', 303 self.assertEqual('lite-page',
268 response.request_headers['chrome-proxy-accept-transform']) 304 response.request_headers['chrome-proxy-accept-transform'])
269 self.assertNotIn('chrome-proxy-content-transform', 305 self.assertNotIn('chrome-proxy-content-transform',
270 response.response_headers) 306 response.response_headers)
271 # Expect no fallback page policy 307 # Expect no fallback page policy
272 if 'chrome-proxy' in response.response_headers: 308 if 'chrome-proxy' in response.response_headers:
273 self.assertNotIn('page-policies', 309 self.assertNotIn('page-policies',
274 response.response_headers['chrome-proxy']) 310 response.response_headers['chrome-proxy'])
275 else: 311 else:
276 # No subresources should accept transforms. 312 # No subresources should accept transforms.
277 self.assertNotIn('chrome-proxy-accept-transform', 313 self.assertNotIn('chrome-proxy-accept-transform',
278 response.request_headers) 314 response.request_headers)
279 315
280 if __name__ == '__main__': 316 if __name__ == '__main__':
281 IntegrationTest.RunAllTests() 317 IntegrationTest.RunAllTests()
OLDNEW
« no previous file with comments | « no previous file | tools/chrome_proxy/webdriver/lofi.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698