| OLD | NEW |
| 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 Bypass(IntegrationTest): | 10 class Bypass(IntegrationTest): |
| 11 | 11 |
| 12 # Ensure Chrome does not use Data Saver for block=0, which uses the default | 12 # Ensure Chrome does not use Data Saver for block=0, which uses the default |
| 13 # proxy retry delay. | 13 # proxy retry delay. |
| 14 def testBypass(self): | 14 def testBypass(self): |
| 15 with TestDriver() as t: | 15 with TestDriver() as t: |
| 16 t.AddChromeArg('--enable-spdy-proxy-auth') | 16 t.AddChromeArg('--enable-spdy-proxy-auth') |
| 17 t.LoadURL('http://check.googlezip.net/block/') | 17 t.LoadURL('http://check.googlezip.net/block/') |
| 18 for response in t.GetHTTPResponses(): | 18 for response in t.GetHTTPResponses(): |
| 19 self.assertNotHasChromeProxyViaHeader(response) | 19 self.assertNotHasChromeProxyViaHeader(response) |
| 20 | 20 |
| 21 # Load another page and check that Data Saver is not used. | 21 # Load another page and check that Data Saver is not used. |
| 22 t.LoadURL('http://check.googlezip.net/test.html') | 22 t.LoadURL('http://check.googlezip.net/test.html') |
| 23 for response in t.GetHTTPResponses(): | 23 for response in t.GetHTTPResponses(): |
| 24 self.assertNotHasChromeProxyViaHeader(response) | 24 self.assertNotHasChromeProxyViaHeader(response) |
| 25 | 25 |
| 26 # Verify that CORS requests receive a block-once from the data reduction |
| 27 # proxy by checking that those requests are retried without data reduction |
| 28 # proxy. |
| 29 def testCorsBypass(self): |
| 30 with TestDriver() as test_driver: |
| 31 test_driver.AddChromeArg('--enable-spdy-proxy-auth') |
| 32 test_driver.LoadURL('http://www.gstatic.com/chrome/googlezip/cors/') |
| 33 |
| 34 # Navigate to a different page to verify that later requests are not |
| 35 # blocked. |
| 36 test_driver.LoadURL('http://check.googlezip.net/test.html') |
| 37 |
| 38 cors_requests = 0 |
| 39 same_origin_requests = 0 |
| 40 for response in test_driver.GetHTTPResponses(): |
| 41 # The origin header implies that |response| is a CORS request. |
| 42 if ('origin' not in response.request_headers): |
| 43 self.assertHasChromeProxyViaHeader(response) |
| 44 same_origin_requests = same_origin_requests + 1 |
| 45 else: |
| 46 self.assertNotHasChromeProxyViaHeader(response) |
| 47 cors_requests = cors_requests + 1 |
| 48 # Verify that both CORS and same origin requests were seen. |
| 49 self.assertNotEqual(0, same_origin_requests) |
| 50 self.assertNotEqual(0, cors_requests) |
| 51 |
| 26 if __name__ == '__main__': | 52 if __name__ == '__main__': |
| 27 IntegrationTest.RunAllTests() | 53 IntegrationTest.RunAllTests() |
| OLD | NEW |