Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 import common | |
| 6 from common import TestDriver | |
| 7 from common import IntegrationTest | |
| 8 | |
| 9 | |
| 10 class LitePage(IntegrationTest): | |
| 11 | |
| 12 # Checks that a Lite Page is served and that the ignore_preview_blacklist | |
| 13 # experiment is being used. | |
| 14 def testLitePage(self): | |
| 15 with TestDriver() as test_driver: | |
| 16 test_driver.AddChromeArg('--enable-spdy-proxy-auth') | |
| 17 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=always-on') | |
| 18 test_driver.AddChromeArg('--enable-data-reduction-proxy-lite-page') | |
| 19 | |
| 20 test_driver.LoadURL('http://check.googlezip.net/test.html') | |
| 21 | |
| 22 lite_page_responses = 0 | |
| 23 for response in test_driver.GetHTTPResponses(): | |
| 24 # Skip CSI requests when validating Lite Page headers. CSI requests | |
| 25 # aren't expected to have LoFi headers. | |
| 26 if '/csi?' in response.url: | |
| 27 continue | |
| 28 if response.url.startswith('data:'): | |
| 29 continue | |
| 30 self.assertIn('exp=ignore_preview_blacklist', | |
| 31 response.request_headers['chrome-proxy']) | |
| 32 if (self.checkLitePageResponse(response)): | |
| 33 lite_page_responses = lite_page_responses + 1 | |
| 34 | |
| 35 # Verify that a Lite Page response for the main frame was seen. | |
| 36 self.assertEqual(1, lite_page_responses) | |
| 37 | |
| 38 # Checks that Lo-Fi images are used when the user is in the | |
| 39 # DataCompressionProxyLitePageFallback field trial and a Lite Page is not | |
| 40 # served. | |
| 41 def testLitePageFallback(self): | |
| 42 with TestDriver() as test_driver: | |
| 43 test_driver.AddChromeArg('--enable-spdy-proxy-auth') | |
| 44 test_driver.AddChromeArg('--force-fieldtrials=' | |
|
tbansal1
2017/03/03 22:40:36
Since we are not using the flags anymore, it means
megjablon
2017/03/03 22:48:51
Yes this won't be set anymore, but we manually "bl
| |
| 45 'DataCompressionProxyLoFi/Enabled_Preview/' | |
| 46 'DataCompressionProxyLitePageFallback/Enabled') | |
| 47 test_driver.AddChromeArg('--force-fieldtrial-params=' | |
| 48 'DataCompressionProxyLoFi.Enabled_Preview:' | |
| 49 'effective_connection_type/4G') | |
| 50 test_driver.AddChromeArg('--force-net-effective-connection-type=2g') | |
| 51 | |
| 52 test_driver.LoadURL('http://check.googlezip.net/lite-page-fallback') | |
| 53 | |
| 54 lite_page_requests = 0 | |
| 55 lo_fi_responses = 0 | |
| 56 for response in test_driver.GetHTTPResponses(): | |
| 57 if not response.request_headers: | |
| 58 continue | |
| 59 | |
| 60 cpat_request = response.request_headers['chrome-proxy-accept-transform'] | |
| 61 if ('lite-page' in cpat_request): | |
| 62 lite_page_requests = lite_page_requests + 1 | |
| 63 self.assertFalse(self.checkLitePageResponse(response)) | |
| 64 | |
| 65 if not response.url.endswith('png'): | |
| 66 continue | |
| 67 | |
| 68 if (self.checkLoFiResponse(response, True)): | |
| 69 lo_fi_responses = lo_fi_responses + 1 | |
| 70 | |
| 71 # Verify that a Lite Page was requested and that the page fell back to | |
| 72 # Lo-Fi images. | |
| 73 self.assertEqual(1, lite_page_requests) | |
| 74 self.assertEqual(1, lo_fi_responses) | |
| 75 | |
| 76 # Checks that Lo-Fi images are not used when the user is not in the | |
| 77 # DataCompressionProxyLitePageFallback field trial and a Lite Page is not | |
| 78 # served. | |
| 79 def testLitePageNoFallback(self): | |
| 80 with TestDriver() as test_driver: | |
| 81 test_driver.AddChromeArg('--enable-spdy-proxy-auth') | |
| 82 # Lite Pages must be enabled via the field trial because the Lite Page | |
| 83 # flag always falls back to Lo-Fi. | |
| 84 test_driver.AddChromeArg('--force-fieldtrials=' | |
| 85 'DataCompressionProxyLoFi/Enabled_Preview') | |
| 86 test_driver.AddChromeArg('--force-fieldtrial-params=' | |
| 87 'DataCompressionProxyLoFi.Enabled_Preview:' | |
| 88 'effective_connection_type/4G') | |
| 89 test_driver.AddChromeArg('--force-net-effective-connection-type=2g') | |
| 90 | |
| 91 test_driver.LoadURL('http://check.googlezip.net/lite-page-fallback') | |
| 92 | |
| 93 lite_page_requests = 0 | |
| 94 for response in test_driver.GetHTTPResponses(): | |
| 95 if not response.request_headers: | |
| 96 continue | |
| 97 | |
| 98 if ('chrome-proxy-accept-transform' in response.request_headers): | |
| 99 cpat_request = response.request_headers[ | |
| 100 'chrome-proxy-accept-transform'] | |
| 101 if ('lite-page' in cpat_request): | |
| 102 lite_page_requests = lite_page_requests + 1 | |
| 103 self.assertFalse(self.checkLitePageResponse(response)) | |
| 104 | |
| 105 if not response.url.endswith('png'): | |
| 106 continue | |
| 107 | |
| 108 self.checkLoFiResponse(response, False) | |
| 109 | |
| 110 # Verify that a Lite Page was requested and that the page fell back to | |
| 111 # Lo-Fi images. | |
| 112 self.assertEqual(1, lite_page_requests) | |
| 113 | |
| 114 if __name__ == '__main__': | |
| 115 IntegrationTest.RunAllTests() | |
| OLD | NEW |