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 24 matching lines...) Expand all Loading... |
35 cpct_response = response.response_headers[ | 35 cpct_response = response.response_headers[ |
36 'chrome-proxy-content-transform'] | 36 'chrome-proxy-content-transform'] |
37 if ('empty-image' in cpct_response): | 37 if ('empty-image' in cpct_response): |
38 lofi_responses = lofi_responses + 1 | 38 lofi_responses = lofi_responses + 1 |
39 self.assertTrue('empty-image' in cpat_request) | 39 self.assertTrue('empty-image' in cpat_request) |
40 self.assertTrue(int(content_length) < 100) | 40 self.assertTrue(int(content_length) < 100) |
41 | 41 |
42 # Verify that Lo-Fi responses were seen. | 42 # Verify that Lo-Fi responses were seen. |
43 self.assertNotEqual(0, lofi_responses) | 43 self.assertNotEqual(0, lofi_responses) |
44 | 44 |
| 45 # Checks that a Lite Page is served and that the ignore_preview_blacklist |
| 46 # experiment is being used. |
| 47 def testLitePage(self): |
| 48 with TestDriver() as test_driver: |
| 49 test_driver.AddChromeArg('--enable-spdy-proxy-auth') |
| 50 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=always-on') |
| 51 test_driver.AddChromeArg('--enable-data-reduction-proxy-lite-page') |
| 52 |
| 53 test_driver.LoadURL('http://check.googlezip.net/test.html') |
| 54 |
| 55 lite_page_responses = 0 |
| 56 for response in test_driver.GetHTTPResponses(): |
| 57 # Skip CSI requests when validating Lite Page headers. CSI requests |
| 58 # aren't expected to have LoFi headers. |
| 59 if '/csi?' in response.url: |
| 60 continue |
| 61 if response.url.startswith('data:'): |
| 62 continue |
| 63 chrome_proxy_request = response.request_headers['chrome-proxy'] |
| 64 cpat_request = response.request_headers['chrome-proxy-accept-transform'] |
| 65 cpct_response = response.response_headers[ |
| 66 'chrome-proxy-content-transform'] |
| 67 self.assertHasChromeProxyViaHeader(response) |
| 68 self.assertIn('exp=ignore_preview_blacklist', |
| 69 chrome_proxy_request) |
| 70 if ('lite-page' in cpct_response): |
| 71 lite_page_responses = lite_page_responses + 1 |
| 72 self.assertIn('lite-page', cpat_request) |
| 73 |
| 74 # Verify that a Lite Page response for the main frame was seen. |
| 75 self.assertEqual(1, lite_page_responses) |
| 76 |
45 if __name__ == '__main__': | 77 if __name__ == '__main__': |
46 IntegrationTest.RunAllTests() | 78 IntegrationTest.RunAllTests() |
OLD | NEW |