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

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

Issue 2705413004: Implement the Lo-Fi cache related integration tests with ChromeDriver (Closed)
Patch Set: Created 3 years, 10 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
Index: tools/chrome_proxy/webdriver/lofi.py
diff --git a/tools/chrome_proxy/webdriver/lofi.py b/tools/chrome_proxy/webdriver/lofi.py
index cc388e25ae8391d2d23da39b339b752ef5663125..e6ab14b174c131c93928e80838a217525b415472 100644
--- a/tools/chrome_proxy/webdriver/lofi.py
+++ b/tools/chrome_proxy/webdriver/lofi.py
@@ -29,15 +29,8 @@ class LoFi(IntegrationTest):
continue
if not response.request_headers:
continue
- self.assertHasChromeProxyViaHeader(response)
- content_length = response.response_headers['content-length']
- cpat_request = response.request_headers['chrome-proxy-accept-transform']
- cpct_response = response.response_headers[
- 'chrome-proxy-content-transform']
- if ('empty-image' in cpct_response):
+ if (self.assertLoFiResponse(response, True)):
lofi_responses = lofi_responses + 1
- self.assertTrue('empty-image' in cpat_request)
- self.assertTrue(int(content_length) < 100)
# Verify that Lo-Fi responses were seen.
self.assertNotEqual(0, lofi_responses)
@@ -73,5 +66,80 @@ class LoFi(IntegrationTest):
# Verify that Lite Page responses were seen.
self.assertNotEqual(0, lite_page_responses)
+ # Checks that Lo-Fi placeholder images are not loaded from cache on page
+ # reloads when Lo-Fi mode is disabled or data reduction proxy is disabled.
+ # First a test page is opened with Lo-Fi and chrome proxy enabled. This allows
+ # Chrome to cache the Lo-Fi placeholder image. The browser is restarted with
+ # chrome proxy disabled and the same test page is loaded. This second page
+ # load should not pick the Lo-Fi placeholder from cache and original image
+ # should be loaded. Finally, the browser is restarted with chrome proxy
+ # enabled and Lo-Fi disabled and the same test page is loaded. This third page
+ # load should not pick the Lo-Fi placeholder from cache and original image
+ # should be loaded.
+ def testLoFiCacheBypass(self):
+ with TestDriver() as test_driver:
+ # First page load, enable Lo-Fi and chrome proxy. Disable server
+ # experiments such as tamper detection. This test should be run with
+ # --profile-type=default command line for the same user profile and cache
+ # to be used across the two page loads.
+ test_driver.AddChromeArg('--enable-spdy-proxy-auth')
+ test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=always-on')
+ test_driver.AddChromeArg('--disable-quic')
tbansal1 2017/02/23 23:55:49 rm disable-quic.
megjablon 2017/02/24 00:07:14 If I remove this from either this or testLoFi they
tbansal1 2017/02/24 00:09:30 No, I do not know at the top of my head. Do you kn
megjablon 2017/02/24 00:28:53 It looks like when quic is enabled for Lo-Fi reque
+ test_driver.AddChromeArg('--profile-type=default')
+ test_driver.AddChromeArg('--data-reduction-proxy-server-experiments-'
+ 'disabled')
+
+ test_driver.LoadURL('http://check.googlezip.net/cacheable/test.html')
+
+ lofi_responses = 0
+ for response in test_driver.GetHTTPResponses():
+ if not response.url.endswith('png'):
+ continue
+ if not response.request_headers:
+ continue
+ if (self.assertLoFiResponse(response, True)):
+ lofi_responses = lofi_responses + 1
+
+ # Verify that Lo-Fi responses were seen.
+ self.assertNotEqual(0, lofi_responses)
+
+ # Second page load with the chrome proxy off.
+ test_driver._StopDriver()
+ test_driver.RemoveChromeArg('--enable-spdy-proxy-auth')
+ test_driver.LoadURL('http://check.googlezip.net/cacheable/test.html')
+
+ responses = 0
+ for response in test_driver.GetHTTPResponses():
+ if not response.url.endswith('png'):
+ continue
+ if not response.request_headers:
+ continue
+ responses = responses + 1
+ self.assertNotHasChromeProxyViaHeader(response)
+ self.assertLoFiResponse(response, False)
+
+ # Verify that responses were seen.
+ self.assertNotEqual(0, responses)
+
+ # Third page load with the chrome proxy on and Lo-Fi off.
+ test_driver._StopDriver()
+ test_driver.AddChromeArg('--enable-spdy-proxy-auth')
+ test_driver.RemoveChromeArg('--data-reduction-proxy-lo-fi=always-on')
+ test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=disabled')
+ test_driver.LoadURL('http://check.googlezip.net/cacheable/test.html')
+
+ responses = 0
+ for response in test_driver.GetHTTPResponses():
+ if not response.url.endswith('png'):
+ continue
+ if not response.request_headers:
+ continue
+ responses = responses + 1
+ self.assertHasChromeProxyViaHeader(response)
+ self.assertLoFiResponse(response, False)
+
+ # Verify that responses were seen.
+ self.assertNotEqual(0, responses)
+
if __name__ == '__main__':
IntegrationTest.RunAllTests()
« tools/chrome_proxy/webdriver/common.py ('K') | « tools/chrome_proxy/webdriver/common.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698