| 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 |
| 11 class LitePage(IntegrationTest): | 11 class LitePage(IntegrationTest): |
| 12 | 12 |
| 13 # Checks that a Lite Page is served and that the ignore_preview_blacklist | 13 # Checks that a Lite Page is served and the force_lite_page experiment |
| 14 # experiment is being used. | 14 # directive is provided when always-on. |
| 15 def testLitePage(self): | 15 def testLitePageForcedExperiment(self): |
| 16 # If it was attempted to run with another experiment, skip this test. | 16 # If it was attempted to run with another experiment, skip this test. |
| 17 if common.ParseFlags().browser_args and ('--data-reduction-proxy-experiment' | 17 if common.ParseFlags().browser_args and ('--data-reduction-proxy-experiment' |
| 18 in common.ParseFlags().browser_args): | 18 in common.ParseFlags().browser_args): |
| 19 self.skipTest('This test cannot be run with other experiments.') | 19 self.skipTest('This test cannot be run with other experiments.') |
| 20 with TestDriver() as test_driver: | 20 with TestDriver() as test_driver: |
| 21 test_driver.AddChromeArg('--enable-spdy-proxy-auth') | 21 test_driver.AddChromeArg('--enable-spdy-proxy-auth') |
| 22 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=always-on') | 22 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=always-on') |
| 23 test_driver.AddChromeArg('--enable-data-reduction-proxy-lite-page') | 23 test_driver.AddChromeArg('--enable-data-reduction-proxy-lite-page') |
| 24 | 24 |
| 25 test_driver.LoadURL('http://check.googlezip.net/test.html') | 25 test_driver.LoadURL('http://check.googlezip.net/test.html') |
| 26 | 26 |
| 27 lite_page_responses = 0 | 27 lite_page_responses = 0 |
| 28 for response in test_driver.GetHTTPResponses(): | 28 for response in test_driver.GetHTTPResponses(): |
| 29 # Skip CSI requests when validating Lite Page headers. CSI requests | 29 # Skip CSI requests when validating Lite Page headers. CSI requests |
| 30 # aren't expected to have LoFi headers. | 30 # aren't expected to have LoFi headers. |
| 31 if '/csi?' in response.url: | 31 if '/csi?' in response.url: |
| 32 continue | 32 continue |
| 33 if response.url.startswith('data:'): | 33 if response.url.startswith('data:'): |
| 34 continue | 34 continue |
| 35 self.assertIn('exp=ignore_preview_blacklist', | 35 # Main resource should force lite page. |
| 36 response.request_headers['chrome-proxy']) | 36 if response.url.endswith('html'): |
| 37 self.assertIn('exp=force_lite_page', |
| 38 response.request_headers['chrome-proxy']) |
| 37 if (self.checkLitePageResponse(response)): | 39 if (self.checkLitePageResponse(response)): |
| 38 lite_page_responses = lite_page_responses + 1 | 40 lite_page_responses = lite_page_responses + 1 |
| 39 | 41 |
| 40 # Verify that a Lite Page response for the main frame was seen. | 42 # Verify that a Lite Page response for the main frame was seen. |
| 41 self.assertEqual(1, lite_page_responses) | 43 self.assertEqual(1, lite_page_responses) |
| 42 | 44 |
| 43 # Checks that a Lite Page does not have an error when scrolling to the bottom | 45 # Checks that a Lite Page does not have an error when scrolling to the bottom |
| 44 # of the page and is able to load all resources. | 46 # of the page and is able to load all resources. |
| 45 def testLitePageBTF(self): | 47 def testLitePageBTF(self): |
| 46 # If it was attempted to run with another experiment, skip this test. | 48 # If it was attempted to run with another experiment, skip this test. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 57 | 59 |
| 58 # Verify that a Lite Page response for the main frame was seen. | 60 # Verify that a Lite Page response for the main frame was seen. |
| 59 lite_page_responses = 0 | 61 lite_page_responses = 0 |
| 60 for response in test_driver.GetHTTPResponses(): | 62 for response in test_driver.GetHTTPResponses(): |
| 61 # Skip CSI requests when validating Lite Page headers. CSI requests | 63 # Skip CSI requests when validating Lite Page headers. CSI requests |
| 62 # aren't expected to have LoFi headers. | 64 # aren't expected to have LoFi headers. |
| 63 if '/csi?' in response.url: | 65 if '/csi?' in response.url: |
| 64 continue | 66 continue |
| 65 if response.url.startswith('data:'): | 67 if response.url.startswith('data:'): |
| 66 continue | 68 continue |
| 67 self.assertIn('exp=ignore_preview_blacklist', | |
| 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 ensure scrollHeight increases. | 73 # Scroll to the bottom of the window and ensure scrollHeight increases. |
| 74 original_scroll_height = test_driver.ExecuteJavascriptStatement( | 74 original_scroll_height = test_driver.ExecuteJavascriptStatement( |
| 75 'document.body.scrollHeight') | 75 'document.body.scrollHeight') |
| 76 test_driver.ExecuteJavascriptStatement( | 76 test_driver.ExecuteJavascriptStatement( |
| 77 'window.scrollTo(0,Math.max(document.body.scrollHeight));') | 77 'window.scrollTo(0,Math.max(document.body.scrollHeight));') |
| 78 # Give some time for loading after scrolling. | 78 # Give some time for loading after scrolling. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 123 |
| 124 # Lo-Fi fallback is not currently supported via the client. Check that | 124 # Lo-Fi fallback is not currently supported via the client. Check that |
| 125 # no Lo-Fi response is received. | 125 # no Lo-Fi response is received. |
| 126 self.checkLoFiResponse(response, False) | 126 self.checkLoFiResponse(response, False) |
| 127 | 127 |
| 128 # Verify that a Lite Page was requested. | 128 # Verify that a Lite Page was requested. |
| 129 self.assertEqual(1, lite_page_requests) | 129 self.assertEqual(1, lite_page_requests) |
| 130 | 130 |
| 131 if __name__ == '__main__': | 131 if __name__ == '__main__': |
| 132 IntegrationTest.RunAllTests() | 132 IntegrationTest.RunAllTests() |
| OLD | NEW |