| 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 with TestDriver() as test_driver: | 17 with TestDriver() as test_driver: |
| 18 test_driver.AddChromeArg('--enable-spdy-proxy-auth') | 18 test_driver.AddChromeArg('--enable-spdy-proxy-auth') |
| 19 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=always-on') | 19 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=always-on') |
| 20 test_driver.AddChromeArg('--enable-data-reduction-proxy-lite-page') | 20 test_driver.AddChromeArg('--enable-data-reduction-proxy-lite-page') |
| 21 | 21 |
| 22 test_driver.LoadURL('http://check.googlezip.net/test.html') | 22 test_driver.LoadURL('http://check.googlezip.net/test.html') |
| 23 | 23 |
| 24 lite_page_responses = 0 | 24 lite_page_responses = 0 |
| 25 for response in test_driver.GetHTTPResponses(): | 25 for response in test_driver.GetHTTPResponses(): |
| 26 # Skip CSI requests when validating Lite Page headers. CSI requests | 26 # Skip CSI requests when validating Lite Page headers. CSI requests |
| 27 # aren't expected to have LoFi headers. | 27 # aren't expected to have LoFi headers. |
| 28 if '/csi?' in response.url: | 28 if '/csi?' in response.url: |
| 29 continue | 29 continue |
| 30 if response.url.startswith('data:'): | 30 if response.url.startswith('data:'): |
| 31 continue | 31 continue |
| 32 if not common.ParseFlags().browser_args or ( | 32 if not common.ParseFlags().browser_args or ( |
| 33 '--data-reduction-proxy-experiment' not in | 33 '--data-reduction-proxy-experiment' not in |
| 34 common.ParseFlags().browser_args): | 34 common.ParseFlags().browser_args): |
| 35 self.assertIn('exp=ignore_preview_blacklist', | 35 self.assertIn('exp=force_lite_page', |
| 36 response.request_headers['chrome-proxy']) | 36 response.request_headers['chrome-proxy']) |
| 37 if (self.checkLitePageResponse(response)): | 37 if (self.checkLitePageResponse(response)): |
| 38 lite_page_responses = lite_page_responses + 1 | 38 lite_page_responses = lite_page_responses + 1 |
| 39 | 39 |
| 40 # Verify that a Lite Page response for the main frame was seen. | 40 # Verify that a Lite Page response for the main frame was seen. |
| 41 self.assertEqual(1, lite_page_responses) | 41 self.assertEqual(1, lite_page_responses) |
| 42 | 42 |
| 43 # Checks that a Lite Page does not have an error when scrolling to the bottom | 43 # 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. | 44 # of the page and is able to load all resources. |
| 45 def testLitePageBTF(self): | 45 def testLitePageBTF(self): |
| (...skipping 11 matching lines...) Expand all Loading... |
| 57 for response in test_driver.GetHTTPResponses(): | 57 for response in test_driver.GetHTTPResponses(): |
| 58 # Skip CSI requests when validating Lite Page headers. CSI requests | 58 # Skip CSI requests when validating Lite Page headers. CSI requests |
| 59 # aren't expected to have LoFi headers. | 59 # aren't expected to have LoFi headers. |
| 60 if '/csi?' in response.url: | 60 if '/csi?' in response.url: |
| 61 continue | 61 continue |
| 62 if response.url.startswith('data:'): | 62 if response.url.startswith('data:'): |
| 63 continue | 63 continue |
| 64 if not common.ParseFlags().browser_args or ( | 64 if not common.ParseFlags().browser_args or ( |
| 65 '--data-reduction-proxy-experiment' not in | 65 '--data-reduction-proxy-experiment' not in |
| 66 common.ParseFlags().browser_args): | 66 common.ParseFlags().browser_args): |
| 67 self.assertIn('exp=ignore_preview_blacklist', | 67 self.assertIn('exp=force_lite_page', |
| 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 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));') |
| (...skipping 45 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 |