| 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 import time | 6 import time |
| 7 from common import TestDriver | 7 from common import TestDriver |
| 8 from common import IntegrationTest | 8 from common import IntegrationTest |
| 9 from decorators import NotAndroid | 9 from decorators import NotAndroid |
| 10 | 10 |
| 11 | 11 |
| 12 class Smoke(IntegrationTest): | 12 class Smoke(IntegrationTest): |
| 13 | 13 |
| 14 # Ensure Chrome does not use DataSaver in Incognito mode. | 14 # Ensure Chrome does not use DataSaver in Incognito mode. |
| 15 # Clank does not honor the --incognito flag. | 15 # Clank does not honor the --incognito flag. |
| 16 @NotAndroid | 16 @NotAndroid |
| 17 def testCheckPageWithIncognito(self): | 17 def testCheckPageWithIncognito(self): |
| 18 with TestDriver() as t: | 18 with TestDriver() as t: |
| 19 t.AddChromeArg('--enable-spdy-proxy-auth') | 19 t.AddChromeArg('--enable-spdy-proxy-auth') |
| 20 t.AddChromeArg('--incognito') | 20 t.AddChromeArg('--incognito') |
| 21 t.LoadURL('http://check.googlezip.net/test.html') | 21 t.LoadURL('http://check.googlezip.net/test.html') |
| 22 for response in t.GetHTTPResponses(): | 22 responses = t.GetHTTPResponses() |
| 23 self.assertNotEqual(0, len(responses)) |
| 24 for response in responses: |
| 23 self.assertNotHasChromeProxyViaHeader(response) | 25 self.assertNotHasChromeProxyViaHeader(response) |
| 24 | 26 |
| 27 # Ensure Chrome does not use DataSaver when holdback is enabled. |
| 28 def testCheckPageWithHoldback(self): |
| 29 with TestDriver() as t: |
| 30 t.AddChromeArg('--enable-spdy-proxy-auth') |
| 31 t.AddChromeArg('--force-fieldtrials=DataCompressionProxyHoldback/' |
| 32 'Enabled') |
| 33 t.LoadURL('http://check.googlezip.net/test.html') |
| 34 responses = t.GetHTTPResponses() |
| 35 self.assertNotEqual(0, len(responses)) |
| 36 num_chrome_proxy_request_headers = 0 |
| 37 for response in responses: |
| 38 self.assertNotHasChromeProxyViaHeader(response) |
| 39 if ('chrome-proxy' in response.request_headers): |
| 40 num_chrome_proxy_request_headers += 1 |
| 41 # DataSaver histograms must still be logged. |
| 42 t.SleepUntilHistogramHasEntry('PageLoad.Clients.DataReductionProxy.' |
| 43 'ParseTiming.NavigationToParseStart') |
| 44 self.assertEqual(num_chrome_proxy_request_headers, 0) |
| 45 # Ensure that Chrome did not attempt to use DataSaver and got a bypass. |
| 46 histogram = t.GetHistogram('DataReductionProxy.BypassedBytes.' |
| 47 'Status502HttpBadGateway', 5) |
| 48 self.assertEqual(histogram, {}) |
| 49 histogram = t.GetHistogram('DataReductionProxy.BlockTypePrimary', 5) |
| 50 self.assertEqual(histogram, {}) |
| 51 histogram = t.GetHistogram('DataReductionProxy.BypassTypePrimary', 5) |
| 52 self.assertEqual(histogram, {}) |
| 53 |
| 25 # Ensure Chrome uses DataSaver in normal mode. | 54 # Ensure Chrome uses DataSaver in normal mode. |
| 26 def testCheckPageWithNormalMode(self): | 55 def testCheckPageWithNormalMode(self): |
| 27 with TestDriver() as t: | 56 with TestDriver() as t: |
| 28 t.AddChromeArg('--enable-spdy-proxy-auth') | 57 t.AddChromeArg('--enable-spdy-proxy-auth') |
| 29 t.LoadURL('http://check.googlezip.net/test.html') | 58 t.LoadURL('http://check.googlezip.net/test.html') |
| 30 responses = t.GetHTTPResponses() | 59 responses = t.GetHTTPResponses() |
| 31 self.assertNotEqual(0, len(responses)) | 60 self.assertNotEqual(0, len(responses)) |
| 61 num_chrome_proxy_request_headers = 0 |
| 32 for response in responses: | 62 for response in responses: |
| 33 self.assertHasChromeProxyViaHeader(response) | 63 self.assertHasChromeProxyViaHeader(response) |
| 64 if ('chrome-proxy' in response.request_headers): |
| 65 num_chrome_proxy_request_headers += 1 |
| 66 t.SleepUntilHistogramHasEntry('PageLoad.Clients.DataReductionProxy.' |
| 67 'ParseTiming.NavigationToParseStart') |
| 68 self.assertGreater(num_chrome_proxy_request_headers, 0) |
| 34 | 69 |
| 35 # Ensure pageload metric pingback with DataSaver. | 70 # Ensure pageload metric pingback with DataSaver. |
| 36 def testPingback(self): | 71 def testPingback(self): |
| 37 with TestDriver() as t: | 72 with TestDriver() as t: |
| 38 t.AddChromeArg('--enable-spdy-proxy-auth') | 73 t.AddChromeArg('--enable-spdy-proxy-auth') |
| 39 t.AddChromeArg('--enable-data-reduction-proxy-force-pingback') | 74 t.AddChromeArg('--enable-data-reduction-proxy-force-pingback') |
| 40 t.LoadURL('http://check.googlezip.net/test.html') | 75 t.LoadURL('http://check.googlezip.net/test.html') |
| 41 t.LoadURL('http://check.googlezip.net/test.html') | 76 t.LoadURL('http://check.googlezip.net/test.html') |
| 42 t.SleepUntilHistogramHasEntry("DataReductionProxy.Pingback.Succeeded") | 77 t.SleepUntilHistogramHasEntry("DataReductionProxy.Pingback.Succeeded") |
| 43 # Verify one pingback attempt that was successful. | 78 # Verify one pingback attempt that was successful. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 t.LoadURL('http://check.googlezip.net/static') | 144 t.LoadURL('http://check.googlezip.net/static') |
| 110 # http://check.googlezip.net/static is a test page that has | 145 # http://check.googlezip.net/static is a test page that has |
| 111 # image/css/javascript resources. | 146 # image/css/javascript resources. |
| 112 responses = t.GetHTTPResponses() | 147 responses = t.GetHTTPResponses() |
| 113 self.assertNotEqual(0, len(responses)) | 148 self.assertNotEqual(0, len(responses)) |
| 114 for response in responses: | 149 for response in responses: |
| 115 self.assertHasChromeProxyViaHeader(response) | 150 self.assertHasChromeProxyViaHeader(response) |
| 116 | 151 |
| 117 if __name__ == '__main__': | 152 if __name__ == '__main__': |
| 118 IntegrationTest.RunAllTests() | 153 IntegrationTest.RunAllTests() |
| OLD | NEW |