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

Side by Side 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, 9 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 unified diff | Download patch
OLDNEW
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 11 matching lines...) Expand all
22 test_driver.AddChromeArg('--disable-quic') 22 test_driver.AddChromeArg('--disable-quic')
23 23
24 test_driver.LoadURL('http://check.googlezip.net/static/index.html') 24 test_driver.LoadURL('http://check.googlezip.net/static/index.html')
25 25
26 lofi_responses = 0 26 lofi_responses = 0
27 for response in test_driver.GetHTTPResponses(): 27 for response in test_driver.GetHTTPResponses():
28 if not response.url.endswith('png'): 28 if not response.url.endswith('png'):
29 continue 29 continue
30 if not response.request_headers: 30 if not response.request_headers:
31 continue 31 continue
32 self.assertHasChromeProxyViaHeader(response) 32 if (self.assertLoFiResponse(response, True)):
33 content_length = response.response_headers['content-length']
34 cpat_request = response.request_headers['chrome-proxy-accept-transform']
35 cpct_response = response.response_headers[
36 'chrome-proxy-content-transform']
37 if ('empty-image' in cpct_response):
38 lofi_responses = lofi_responses + 1 33 lofi_responses = lofi_responses + 1
39 self.assertTrue('empty-image' in cpat_request)
40 self.assertTrue(int(content_length) < 100)
41 34
42 # Verify that Lo-Fi responses were seen. 35 # Verify that Lo-Fi responses were seen.
43 self.assertNotEqual(0, lofi_responses) 36 self.assertNotEqual(0, lofi_responses)
44 37
45 # Checks that a Lite Page is served and that the ignore_preview_blacklist 38 # Checks that a Lite Page is served and that the ignore_preview_blacklist
46 # experiment is being used. 39 # experiment is being used.
47 def testLitePage(self): 40 def testLitePage(self):
48 with TestDriver() as test_driver: 41 with TestDriver() as test_driver:
49 test_driver.AddChromeArg('--enable-spdy-proxy-auth') 42 test_driver.AddChromeArg('--enable-spdy-proxy-auth')
50 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=always-on') 43 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=always-on')
(...skipping 15 matching lines...) Expand all
66 'chrome-proxy-content-transform'] 59 'chrome-proxy-content-transform']
67 if ('lite-page' in cpct_response): 60 if ('lite-page' in cpct_response):
68 lite_page_responses = lite_page_responses + 1 61 lite_page_responses = lite_page_responses + 1
69 self.assertTrue('lite-page' in cpat_request) 62 self.assertTrue('lite-page' in cpat_request)
70 self.assertTrue('exp=ignore_preview_blacklist' in 63 self.assertTrue('exp=ignore_preview_blacklist' in
71 chrome_proxy_request) 64 chrome_proxy_request)
72 65
73 # Verify that Lite Page responses were seen. 66 # Verify that Lite Page responses were seen.
74 self.assertNotEqual(0, lite_page_responses) 67 self.assertNotEqual(0, lite_page_responses)
75 68
69 # Checks that Lo-Fi placeholder images are not loaded from cache on page
70 # reloads when Lo-Fi mode is disabled or data reduction proxy is disabled.
71 # First a test page is opened with Lo-Fi and chrome proxy enabled. This allows
72 # Chrome to cache the Lo-Fi placeholder image. The browser is restarted with
73 # chrome proxy disabled and the same test page is loaded. This second page
74 # load should not pick the Lo-Fi placeholder from cache and original image
75 # should be loaded. Finally, the browser is restarted with chrome proxy
76 # enabled and Lo-Fi disabled and the same test page is loaded. This third page
77 # load should not pick the Lo-Fi placeholder from cache and original image
78 # should be loaded.
79 def testLoFiCacheBypass(self):
80 with TestDriver() as test_driver:
81 # First page load, enable Lo-Fi and chrome proxy. Disable server
82 # experiments such as tamper detection. This test should be run with
83 # --profile-type=default command line for the same user profile and cache
84 # to be used across the two page loads.
85 test_driver.AddChromeArg('--enable-spdy-proxy-auth')
86 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=always-on')
87 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
88 test_driver.AddChromeArg('--profile-type=default')
89 test_driver.AddChromeArg('--data-reduction-proxy-server-experiments-'
90 'disabled')
91
92 test_driver.LoadURL('http://check.googlezip.net/cacheable/test.html')
93
94 lofi_responses = 0
95 for response in test_driver.GetHTTPResponses():
96 if not response.url.endswith('png'):
97 continue
98 if not response.request_headers:
99 continue
100 if (self.assertLoFiResponse(response, True)):
101 lofi_responses = lofi_responses + 1
102
103 # Verify that Lo-Fi responses were seen.
104 self.assertNotEqual(0, lofi_responses)
105
106 # Second page load with the chrome proxy off.
107 test_driver._StopDriver()
108 test_driver.RemoveChromeArg('--enable-spdy-proxy-auth')
109 test_driver.LoadURL('http://check.googlezip.net/cacheable/test.html')
110
111 responses = 0
112 for response in test_driver.GetHTTPResponses():
113 if not response.url.endswith('png'):
114 continue
115 if not response.request_headers:
116 continue
117 responses = responses + 1
118 self.assertNotHasChromeProxyViaHeader(response)
119 self.assertLoFiResponse(response, False)
120
121 # Verify that responses were seen.
122 self.assertNotEqual(0, responses)
123
124 # Third page load with the chrome proxy on and Lo-Fi off.
125 test_driver._StopDriver()
126 test_driver.AddChromeArg('--enable-spdy-proxy-auth')
127 test_driver.RemoveChromeArg('--data-reduction-proxy-lo-fi=always-on')
128 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=disabled')
129 test_driver.LoadURL('http://check.googlezip.net/cacheable/test.html')
130
131 responses = 0
132 for response in test_driver.GetHTTPResponses():
133 if not response.url.endswith('png'):
134 continue
135 if not response.request_headers:
136 continue
137 responses = responses + 1
138 self.assertHasChromeProxyViaHeader(response)
139 self.assertLoFiResponse(response, False)
140
141 # Verify that responses were seen.
142 self.assertNotEqual(0, responses)
143
76 if __name__ == '__main__': 144 if __name__ == '__main__':
77 IntegrationTest.RunAllTests() 145 IntegrationTest.RunAllTests()
OLDNEW
« 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