Index: tools/chrome_proxy/webdriver/lite_page.py |
diff --git a/tools/chrome_proxy/webdriver/lite_page.py b/tools/chrome_proxy/webdriver/lite_page.py |
index a9219e3525ff602f4a725d3405493557eb990409..0f6f3e3f856ecde7412f1e8c2fd2364b6b3b7a4b 100644 |
--- a/tools/chrome_proxy/webdriver/lite_page.py |
+++ b/tools/chrome_proxy/webdriver/lite_page.py |
@@ -10,9 +10,9 @@ import time |
class LitePage(IntegrationTest): |
- # Checks that a Lite Page is served and that the ignore_preview_blacklist |
- # experiment is being used. |
- def testLitePage(self): |
+ # Checks that a Lite Page is served and the force_lite_page experiment |
+ # provided when always-on. |
bengr
2017/05/01 16:53:15
is provided?
|
+ def testLitePageForcedExperiment(self): |
# If it was attempted to run with another experiment, skip this test. |
if common.ParseFlags().browser_args and ('--data-reduction-proxy-experiment' |
in common.ParseFlags().browser_args): |
@@ -32,8 +32,10 @@ class LitePage(IntegrationTest): |
continue |
if response.url.startswith('data:'): |
continue |
- self.assertIn('exp=ignore_preview_blacklist', |
- response.request_headers['chrome-proxy']) |
+ # Main resource should force lite page. |
+ if response.url.endswith('html'): |
+ self.assertIn('exp=force_lite_page', |
+ response.request_headers['chrome-proxy']) |
if (self.checkLitePageResponse(response)): |
lite_page_responses = lite_page_responses + 1 |
@@ -64,7 +66,7 @@ class LitePage(IntegrationTest): |
continue |
if response.url.startswith('data:'): |
continue |
- self.assertIn('exp=ignore_preview_blacklist', |
+ self.assertIn('exp=force_lite_page', |
response.request_headers['chrome-proxy']) |
if (self.checkLitePageResponse(response)): |
lite_page_responses = lite_page_responses + 1 |
@@ -83,19 +85,91 @@ class LitePage(IntegrationTest): |
for response in responses: |
self.assertHasChromeProxyViaHeader(response) |
+ # Checks that the server provides Lite Page for slow connection. |
+ def testLitePageForSlowConnection(self): |
+ with TestDriver() as test_driver: |
+ test_driver.AddChromeArg('--enable-spdy-proxy-auth') |
+ test_driver.AddChromeArg('--force-fieldtrial-params=' |
+ 'NetworkQualityEstimator.Enabled:' |
+ 'force_effective_connection_type/Slow2G,' |
+ 'DataCompressionProxyLoFi.Enabled_Preview:' |
+ 'effective_connection_type/2G') |
+ test_driver.AddChromeArg('--force-fieldtrials=' |
+ 'NetworkQualityEstimator/Enabled/' |
+ 'DataCompressionProxyLoFi/Enabled_Preview/' |
+ 'DataCompressionProxyLitePageFallback/Enabled') |
+ |
+ test_driver.LoadURL('http://check.googlezip.net/test.html') |
+ |
+ |
+ lite_page_responses = 0 |
+ for response in test_driver.GetHTTPResponses(): |
+ self.assertEqual('Slow-2G', |
+ response.request_headers['chrome-proxy-ect']) |
+ |
+ if response.url.endswith('html'): |
+ # Main resource should accept and transform to lite page. |
+ self.assertTrue(self.checkLitePageResponse(response)); |
+ lite_page_responses = lite_page_responses + 1 |
+ |
+ # Be sure force exp not set. |
+ self.assertNotIn('exp=force_lite_page', |
+ response.request_headers['chrome-proxy']) |
+ else: |
+ # No subresources should accept transforms. |
+ self.assertNotIn('chrome-proxy-accept-transform', |
+ response.request_headers) |
+ |
+ self.assertEqual(1, lite_page_responses) |
+ |
+ # Checks that the server does not provide Lite Page for fast connection. |
bengr
2017/05/01 16:53:15
for -> for a
|
+ def testLitePageNotProvidedForFastConnection(self): |
+ with TestDriver() as test_driver: |
+ test_driver.AddChromeArg('--enable-spdy-proxy-auth') |
+ test_driver.AddChromeArg('--force-fieldtrial-params=' |
+ 'NetworkQualityEstimator.Enabled:' |
+ 'force_effective_connection_type/3G,' |
+ 'DataCompressionProxyLoFi.Enabled_Preview:' |
+ 'effective_connection_type/2G') |
+ test_driver.AddChromeArg('--force-fieldtrials=' |
+ 'NetworkQualityEstimator/Enabled/' |
+ 'DataCompressionProxyLoFi/Enabled_Preview/' |
+ 'DataCompressionProxyLitePageFallback/Enabled') |
+ |
+ test_driver.LoadURL('http://check.googlezip.net/test.html') |
+ |
+ for response in test_driver.GetHTTPResponses(): |
+ self.assertEqual('3G', response.request_headers['chrome-proxy-ect']) |
+ |
+ if response.url.endswith('html'): |
+ # Main resource should accept lite page but not be transformed. |
+ self.assertEqual('lite-page', |
+ response.request_headers['chrome-proxy-accept-transform']) |
+ self.assertNotIn('chrome-proxy-content-transform', |
+ response.response_headers) |
+ self.assertNotIn('chrome-proxy-content-transform', |
+ response.response_headers) |
+ self.assertEqual('3G', response.request_headers['chrome-proxy-ect']) |
+ else: |
+ # No subresources should accept transforms. |
+ self.assertNotIn('chrome-proxy-accept-transform', |
+ response.request_headers) |
+ |
# Checks that Lo-Fi images are used when the user is in the |
# DataCompressionProxyLitePageFallback field trial and a Lite Page is not |
# served. |
def testLitePageFallback(self): |
with TestDriver() as test_driver: |
test_driver.AddChromeArg('--enable-spdy-proxy-auth') |
+ test_driver.AddChromeArg('--force-fieldtrial-params=' |
+ 'NetworkQualityEstimator.Enabled:' |
+ 'force_effective_connection_type/Slow2G,' |
+ 'DataCompressionProxyLoFi.Enabled_Preview:' |
+ 'effective_connection_type/2G') |
test_driver.AddChromeArg('--force-fieldtrials=' |
+ 'NetworkQualityEstimator/Enabled/' |
'DataCompressionProxyLoFi/Enabled_Preview/' |
'DataCompressionProxyLitePageFallback/Enabled') |
- test_driver.AddChromeArg('--force-fieldtrial-params=' |
- 'DataCompressionProxyLoFi.Enabled_Preview:' |
- 'effective_connection_type/4G') |
- test_driver.AddChromeArg('--force-net-effective-connection-type=2g') |
test_driver.LoadURL('http://check.googlezip.net/lite-page-fallback') |
@@ -105,6 +179,9 @@ class LitePage(IntegrationTest): |
if not response.request_headers: |
continue |
+ self.assertEqual("Slow-2G", |
+ response.request_headers['chrome-proxy-ect']) |
+ |
cpat_request = response.request_headers['chrome-proxy-accept-transform'] |
if ('lite-page' in cpat_request): |
lite_page_requests = lite_page_requests + 1 |
@@ -129,12 +206,14 @@ class LitePage(IntegrationTest): |
test_driver.AddChromeArg('--enable-spdy-proxy-auth') |
# Lite Pages must be enabled via the field trial because the Lite Page |
# flag always falls back to Lo-Fi. |
- test_driver.AddChromeArg('--force-fieldtrials=' |
- 'DataCompressionProxyLoFi/Enabled_Preview') |
test_driver.AddChromeArg('--force-fieldtrial-params=' |
+ 'NetworkQualityEstimator.Enabled:' |
+ 'force_effective_connection_type/Slow2G,' |
'DataCompressionProxyLoFi.Enabled_Preview:' |
- 'effective_connection_type/4G') |
- test_driver.AddChromeArg('--force-net-effective-connection-type=2g') |
+ 'effective_connection_type/2G') |
+ test_driver.AddChromeArg('--force-fieldtrials=' |
+ 'NetworkQualityEstimator/Enabled/' |
+ 'DataCompressionProxyLoFi/Enabled_Preview') |
test_driver.LoadURL('http://check.googlezip.net/lite-page-fallback') |
@@ -143,6 +222,9 @@ class LitePage(IntegrationTest): |
if not response.request_headers: |
continue |
+ self.assertEqual("Slow-2G", |
+ response.request_headers['chrome-proxy-ect']) |
+ |
if ('chrome-proxy-accept-transform' in response.request_headers): |
cpat_request = response.request_headers[ |
'chrome-proxy-accept-transform'] |