| 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 import time | 9 import time |
| 10 | 10 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 if '/csi?' in response.url: | 63 if '/csi?' in response.url: |
| 64 continue | 64 continue |
| 65 if response.url.startswith('data:'): | 65 if response.url.startswith('data:'): |
| 66 continue | 66 continue |
| 67 self.assertIn('exp=ignore_preview_blacklist', | 67 self.assertIn('exp=ignore_preview_blacklist', |
| 68 response.request_headers['chrome-proxy']) | 68 response.request_headers['chrome-proxy']) |
| 69 if (self.checkLitePageResponse(response)): | 69 if (self.checkLitePageResponse(response)): |
| 70 lite_page_responses = lite_page_responses + 1 | 70 lite_page_responses = lite_page_responses + 1 |
| 71 self.assertEqual(1, lite_page_responses) | 71 self.assertEqual(1, lite_page_responses) |
| 72 | 72 |
| 73 # Scroll to the bottom of the window and make sure there were more | 73 # Scroll to the bottom of the window and ensure scrollHeight increases. |
| 74 # requests that were proxied. | 74 original_scroll_height = test_driver.ExecuteJavascriptStatement( |
| 75 scroll_js = 'window.scrollTo(0,Math.max(document.body.scrollHeight));' | 75 'document.body.scrollHeight') |
| 76 test_driver.ExecuteJavascriptStatement(scroll_js) | 76 test_driver.ExecuteJavascriptStatement( |
| 77 # Give some time for loading after each scroll. | 77 'window.scrollTo(0,Math.max(document.body.scrollHeight));') |
| 78 # Give some time for loading after scrolling. |
| 78 time.sleep(2) | 79 time.sleep(2) |
| 79 test_driver.ExecuteJavascriptStatement(scroll_js) | 80 new_scroll_height = test_driver.ExecuteJavascriptStatement( |
| 80 time.sleep(2) | 81 'document.body.scrollHeight') |
| 82 self.assertGreater(new_scroll_height, original_scroll_height) |
| 83 |
| 84 # Make sure there were more requests that were proxied. |
| 81 responses = test_driver.GetHTTPResponses(override_has_logs=True) | 85 responses = test_driver.GetHTTPResponses(override_has_logs=True) |
| 82 self.assertNotEqual(0, len(responses)) | 86 self.assertNotEqual(0, len(responses)) |
| 83 for response in responses: | 87 for response in responses: |
| 84 self.assertHasChromeProxyViaHeader(response) | 88 self.assertHasChromeProxyViaHeader(response) |
| 89 self.assertIn(response.status, [200, 204]) |
| 85 | 90 |
| 86 # Checks that Lo-Fi images are used when the user is in the | 91 # Checks that Lo-Fi images are used when the user is in the |
| 87 # DataCompressionProxyLitePageFallback field trial and a Lite Page is not | 92 # DataCompressionProxyLitePageFallback field trial and a Lite Page is not |
| 88 # served. | 93 # served. |
| 89 def testLitePageFallback(self): | 94 def testLitePageFallback(self): |
| 90 with TestDriver() as test_driver: | 95 with TestDriver() as test_driver: |
| 91 test_driver.AddChromeArg('--enable-spdy-proxy-auth') | 96 test_driver.AddChromeArg('--enable-spdy-proxy-auth') |
| 92 test_driver.AddChromeArg('--force-fieldtrials=' | 97 test_driver.AddChromeArg('--force-fieldtrials=' |
| 93 'DataCompressionProxyLoFi/Enabled_Preview/' | 98 'DataCompressionProxyLoFi/Enabled_Preview/' |
| 94 'DataCompressionProxyLitePageFallback/Enabled') | 99 'DataCompressionProxyLitePageFallback/Enabled') |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 continue | 159 continue |
| 155 | 160 |
| 156 self.checkLoFiResponse(response, False) | 161 self.checkLoFiResponse(response, False) |
| 157 | 162 |
| 158 # Verify that a Lite Page was requested and that the page fell back to | 163 # Verify that a Lite Page was requested and that the page fell back to |
| 159 # Lo-Fi images. | 164 # Lo-Fi images. |
| 160 self.assertEqual(1, lite_page_requests) | 165 self.assertEqual(1, lite_page_requests) |
| 161 | 166 |
| 162 if __name__ == '__main__': | 167 if __name__ == '__main__': |
| 163 IntegrationTest.RunAllTests() | 168 IntegrationTest.RunAllTests() |
| OLD | NEW |