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

Unified Diff: tools/chrome_proxy/webdriver/lite_page.py

Issue 2910783002: Adds Lo-Fi fallback support for new Data Reduction Proxy protocol. (Closed)
Patch Set: Added Lite Page integration tests for slow connection and fast connection 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 side-by-side diff with in-line comments
Download patch
« content/renderer/previews_state_helper.cc ('K') | « content/test/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 39b6d43e5b7722152b238d39b096899266a5d094..a6ebe4c1da74fea5e57367d51cb2fb607350c19b 100644
--- a/tools/chrome_proxy/webdriver/lite_page.py
+++ b/tools/chrome_proxy/webdriver/lite_page.py
@@ -97,9 +97,10 @@ class LitePage(IntegrationTest):
self.assertHasChromeProxyViaHeader(response)
self.assertIn(response.status, [200, 204])
- # Lo-Fi fallback is not currently supported via the client. Check that
- # no Lo-Fi response is received if a Lite Page is not served.
- def testLitePageFallback(self):
+ # Lo-Fi fallback is not supported without the
+ # DataReductionProxyDecidesTransform feature. Check that no Lo-Fi response
+ # is received if a Lite Page is not served.
+ def testLitePageNoFallback(self):
with TestDriver() as test_driver:
test_driver.AddChromeArg('--enable-spdy-proxy-auth')
test_driver.AddChromeArg('--force-fieldtrials='
@@ -134,5 +135,152 @@ class LitePage(IntegrationTest):
# Verify that a Lite Page was requested.
self.assertEqual(1, lite_page_requests)
+ # Verifies Lo-Fi fallback via the page-policies server directive.
+ # Note: this test is for the CPAT protocol change in M-61.
+ def testLitePageFallbackViaPagePolicies(self):
+ with TestDriver() as test_driver:
+ test_driver.AddChromeArg('--enable-spdy-proxy-auth')
+ test_driver.AddChromeArg('--enable-features='
+ 'DataReductionProxyDecidesTransform')
+ 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')
+
+ test_driver.LoadURL('http://check.googlezip.net/lite-page-fallback')
+
+ lite_page_responses = 0
+ lofi_resource = 0
+ for response in test_driver.GetHTTPResponses():
+ self.assertEqual('Slow-2G',
+ response.request_headers['chrome-proxy-ect'])
+
+ if response.url.endswith('html'):
+ # Verify that the server provides the fallback directive
+ self.assertIn('page-policies=empty-image',
+ response.response_headers['chrome-proxy'])
+ # Main resource should not accept and transform to lite page.
+ if self.checkLitePageResponse(response):
+ lite_page_responses = lite_page_responses + 1
+ if response.url.endswith('png'):
+ if self.checkLoFiResponse(response, True):
+ lofi_resource = lofi_resource + 1
+
+ self.assertEqual(0, lite_page_responses)
+ self.assertNotEqual(0, lofi_resource)
+ self.assertNotEqual(0, lofi_resource)
+
+ # Checks that the server provides Lite Page for a 2G connection.
+ # Note: this test is for the CPAT protocol change in M-61.
+ def testLitePageProvidedForSlowConnection(self):
+ with TestDriver() as test_driver:
+ test_driver.AddChromeArg('--enable-spdy-proxy-auth')
+ test_driver.AddChromeArg('--enable-features='
+ 'DataReductionProxyDecidesTransform')
+ test_driver.AddChromeArg('--force-fieldtrial-params='
+ 'NetworkQualityEstimator.Enabled:'
+ 'force_effective_connection_type/2G,'
+ 'DataCompressionProxyLoFi.Enabled_Preview:'
+ 'effective_connection_type/2G')
+ test_driver.AddChromeArg('--force-fieldtrials='
+ 'NetworkQualityEstimator/Enabled/'
+ 'DataCompressionProxyLoFi/Enabled_Preview')
+
+ test_driver.LoadURL('http://check.googlezip.net/test.html')
+
+ lite_page_responses = 0
+ for response in test_driver.GetHTTPResponses():
+ self.assertEqual('2G', response.request_headers['chrome-proxy-ect'])
+ if response.url.endswith('html'):
+ if self.checkLitePageResponse(response):
+ lite_page_responses = lite_page_responses + 1
+ # Expect no fallback page policy
+ if 'chrome-proxy' in response.response_headers:
+ self.assertNotIn('page-policies',
+ response.response_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 nor fallback
+ # for a fast connection.
+ # Note: this test is for the CPAT protocol change in M-61.
+ def testLitePageNotProvidedForFastConnection(self):
+ with TestDriver() as test_driver:
+ test_driver.AddChromeArg('--enable-spdy-proxy-auth')
+ test_driver.AddChromeArg('--enable-features='
+ 'DataReductionProxyDecidesTransform')
+ test_driver.AddChromeArg('--force-fieldtrial-params='
+ 'NetworkQualityEstimator.Enabled:'
+ 'force_effective_connection_type/4G,'
+ 'DataCompressionProxyLoFi.Enabled_Preview:'
+ 'effective_connection_type/2G')
+ test_driver.AddChromeArg('--force-fieldtrials='
+ 'NetworkQualityEstimator/Enabled/'
+ 'DataCompressionProxyLoFi/Enabled_Preview')
+
+ test_driver.LoadURL('http://check.googlezip.net/test.html')
+
+ for response in test_driver.GetHTTPResponses():
+ self.assertEqual('4G', 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)
+ # Expect no fallback page policy
+ if 'chrome-proxy' in response.response_headers:
+ self.assertNotIn('page-policies',
+ response.response_headers['chrome-proxy'])
+ else:
+ # No subresources should accept transforms.
+ self.assertNotIn('chrome-proxy-accept-transform',
+ response.request_headers)
+
+ # Verifies Lo-Fi fallback via the page-policies server directive.
+ # Note: this test is for the CPAT protocol change in M-61.
+ def testLitePageFallbackViaPagePolicies(self):
+ with TestDriver() as test_driver:
+ test_driver.AddChromeArg('--enable-spdy-proxy-auth')
+ test_driver.AddChromeArg('--enable-features='
+ 'DataReductionProxyDecidesTransform')
+ 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')
+
+ test_driver.LoadURL('http://check.googlezip.net/lite-page-fallback')
+
+ lite_page_responses = 0
+ lofi_resource = 0
+ for response in test_driver.GetHTTPResponses():
+ self.assertEqual('Slow-2G',
+ response.request_headers['chrome-proxy-ect'])
+
+ if response.url.endswith('html'):
+ # Verify that the server provides the fallback directive
+ self.assertIn('page-policies=empty-image',
+ response.response_headers['chrome-proxy'])
+ # Main resource should not accept and transform to lite page.
+ if self.checkLitePageResponse(response):
+ lite_page_responses = lite_page_responses + 1
+ if response.url.endswith('png'):
+ if self.checkLoFiResponse(response, True):
+ lofi_resource = lofi_resource + 1
+
+ self.assertEqual(0, lite_page_responses)
+
if __name__ == '__main__':
IntegrationTest.RunAllTests()
« content/renderer/previews_state_helper.cc ('K') | « content/test/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698