| 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 from decorators import ChromeVersionBeforeM | 8 from decorators import ChromeVersionBeforeM |
| 9 | 9 from decorators import ChromeVersionEqualOrAfterM |
| 10 | 10 |
| 11 class LoFi(IntegrationTest): | 11 class LoFi(IntegrationTest): |
| 12 | 12 |
| 13 # Checks that the compressed image is below a certain threshold. | 13 # Checks that the compressed image is below a certain threshold. |
| 14 # The test page is uncacheable otherwise a cached page may be served that | 14 # The test page is uncacheable otherwise a cached page may be served that |
| 15 # doesn't have the correct via headers. | 15 # doesn't have the correct via headers. |
| 16 def testLoFi(self): | 16 def testLoFi(self): |
| 17 with TestDriver() as test_driver: | 17 with TestDriver() as test_driver: |
| 18 test_driver.AddChromeArg('--enable-spdy-proxy-auth') | 18 test_driver.AddChromeArg('--enable-spdy-proxy-auth') |
| 19 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=always-on') | 19 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=always-on') |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 continue | 178 continue |
| 179 responses = responses + 1 | 179 responses = responses + 1 |
| 180 self.assertHasChromeProxyViaHeader(response) | 180 self.assertHasChromeProxyViaHeader(response) |
| 181 self.checkLoFiResponse(response, False) | 181 self.checkLoFiResponse(response, False) |
| 182 | 182 |
| 183 # Verify that responses were seen. | 183 # Verify that responses were seen. |
| 184 self.assertNotEqual(0, responses) | 184 self.assertNotEqual(0, responses) |
| 185 | 185 |
| 186 # Checks that LoFi images are served and the force empty image experiment | 186 # Checks that LoFi images are served and the force empty image experiment |
| 187 # directive is provided when LoFi is always-on without Lite Pages enabled. | 187 # directive is provided when LoFi is always-on without Lite Pages enabled. |
| 188 @ChromeVersionEqualOrAfterM(61) |
| 188 def testLoFiForcedExperiment(self): | 189 def testLoFiForcedExperiment(self): |
| 189 # If it was attempted to run with another experiment, skip this test. | 190 # If it was attempted to run with another experiment, skip this test. |
| 190 if common.ParseFlags().browser_args and ('--data-reduction-proxy-experiment' | 191 if common.ParseFlags().browser_args and ('--data-reduction-proxy-experiment' |
| 191 in common.ParseFlags().browser_args): | 192 in common.ParseFlags().browser_args): |
| 192 self.skipTest('This test cannot be run with other experiments.') | 193 self.skipTest('This test cannot be run with other experiments.') |
| 193 with TestDriver() as test_driver: | 194 with TestDriver() as test_driver: |
| 194 test_driver.AddChromeArg('--enable-spdy-proxy-auth') | 195 test_driver.AddChromeArg('--enable-spdy-proxy-auth') |
| 195 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=always-on') | 196 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=always-on') |
| 197 test_driver.AddChromeArg('--enable-features=' |
| 198 'DataReductionProxyDecidesTransform') |
| 199 |
| 200 # Ensure fast network (4G) to ensure force flag ignores ECT. |
| 201 test_driver.AddChromeArg('--force-fieldtrial-params=' |
| 202 'NetworkQualityEstimator.Enabled:' |
| 203 'force_effective_connection_type/4G') |
| 204 test_driver.AddChromeArg('--force-fieldtrials=NetworkQualityEstimator/' |
| 205 'Enabled') |
| 196 | 206 |
| 197 test_driver.LoadURL('http://check.googlezip.net/static/index.html') | 207 test_driver.LoadURL('http://check.googlezip.net/static/index.html') |
| 198 | 208 |
| 199 lofi_responses = 0 | 209 lofi_responses = 0 |
| 200 for response in test_driver.GetHTTPResponses(): | 210 for response in test_driver.GetHTTPResponses(): |
| 201 self.assertIn('exp=force_page_policies_empty_image', | 211 self.assertIn('exp=force_page_policies_empty_image', |
| 202 response.request_headers['chrome-proxy']) | 212 response.request_headers['chrome-proxy']) |
| 203 if response.url.endswith('html'): | 213 if response.url.endswith('html'): |
| 204 # TODO(dougarnett): Check page-policies response when server supports | 214 # Verify that the server provides the fallback directive |
| 215 self.assertIn('chrome-proxy', response.response_headers) |
| 216 self.assertIn('page-policies=empty-image', |
| 217 response.response_headers['chrome-proxy']) |
| 205 continue | 218 continue |
| 206 if response.url.endswith('png'): | 219 if response.url.endswith('png'): |
| 207 # TODO(dougarnett): Set 4G ECT when server supports force empty image | |
| 208 self.checkLoFiResponse(response, True) | 220 self.checkLoFiResponse(response, True) |
| 209 lofi_responses = lofi_responses + 1 | 221 lofi_responses = lofi_responses + 1 |
| 210 | 222 |
| 211 # Verify that Lo-Fi responses were seen. | 223 # Verify that Lo-Fi responses were seen. |
| 212 self.assertNotEqual(0, lofi_responses) | 224 self.assertNotEqual(0, lofi_responses) |
| 213 | 225 |
| 214 # Checks that Client LoFi resource requests have the Intervention header | 226 # Checks that Client LoFi resource requests have the Intervention header |
| 215 # (in case page has https images that may not be fully loaded). | 227 # (in case page has https images that may not be fully loaded). |
| 228 @ChromeVersionEqualOrAfterM(61) |
| 216 def testClientLoFiInterventionHeader(self): | 229 def testClientLoFiInterventionHeader(self): |
| 217 with TestDriver() as test_driver: | 230 with TestDriver() as test_driver: |
| 218 test_driver.AddChromeArg('--enable-spdy-proxy-auth') | 231 test_driver.AddChromeArg('--enable-spdy-proxy-auth') |
| 219 test_driver.AddChromeArg('--force-fieldtrials=' | 232 test_driver.AddChromeArg('--force-fieldtrials=' |
| 220 'PreviewsClientLoFi/Enabled') | 233 'PreviewsClientLoFi/Enabled') |
| 221 test_driver.AddChromeArg('--force-fieldtrial-params=' | 234 test_driver.AddChromeArg('--force-fieldtrial-params=' |
| 222 'PreviewsClientLoFi.Enabled:' | 235 'PreviewsClientLoFi.Enabled:' |
| 223 'max_allowed_effective_connection_type/4G') | 236 'max_allowed_effective_connection_type/4G') |
| 224 | 237 |
| 225 test_driver.LoadURL('http://check.googlezip.net/static/index.html') | 238 test_driver.LoadURL('http://check.googlezip.net/static/index.html') |
| 226 | 239 |
| 227 intervention_headers = 0 | 240 intervention_headers = 0 |
| 228 for response in test_driver.GetHTTPResponses(): | 241 for response in test_driver.GetHTTPResponses(): |
| 229 if not response.url.endswith('html'): | 242 if not response.url.endswith('html'): |
| 230 self.assertIn('intervention', response.request_headers) | 243 self.assertIn('intervention', response.request_headers) |
| 231 intervention_headers = intervention_headers + 1 | 244 intervention_headers = intervention_headers + 1 |
| 232 | 245 |
| 233 self.assertNotEqual(0, intervention_headers) | 246 self.assertNotEqual(0, intervention_headers) |
| 234 | 247 |
| 235 if __name__ == '__main__': | 248 if __name__ == '__main__': |
| 236 IntegrationTest.RunAllTests() | 249 IntegrationTest.RunAllTests() |
| OLD | NEW |