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 that the ignore_preview_blacklist |
14 # experiment is being used. | 14 # experiment is being used. |
15 def testLitePage(self): | 15 def testLitePage(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' | |
18 in common.ParseFlags().browser_args): | |
19 self.skipTest('This test cannot be run with other experiments.') | |
20 with TestDriver() as test_driver: | 17 with TestDriver() as test_driver: |
21 test_driver.AddChromeArg('--enable-spdy-proxy-auth') | 18 test_driver.AddChromeArg('--enable-spdy-proxy-auth') |
22 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=always-on') | 19 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=always-on') |
23 test_driver.AddChromeArg('--enable-data-reduction-proxy-lite-page') | 20 test_driver.AddChromeArg('--enable-data-reduction-proxy-lite-page') |
24 | 21 |
25 test_driver.LoadURL('http://check.googlezip.net/test.html') | 22 test_driver.LoadURL('http://check.googlezip.net/test.html') |
26 | 23 |
27 lite_page_responses = 0 | 24 lite_page_responses = 0 |
28 for response in test_driver.GetHTTPResponses(): | 25 for response in test_driver.GetHTTPResponses(): |
29 # Skip CSI requests when validating Lite Page headers. CSI requests | 26 # Skip CSI requests when validating Lite Page headers. CSI requests |
30 # aren't expected to have LoFi headers. | 27 # aren't expected to have LoFi headers. |
31 if '/csi?' in response.url: | 28 if '/csi?' in response.url: |
32 continue | 29 continue |
33 if response.url.startswith('data:'): | 30 if response.url.startswith('data:'): |
34 continue | 31 continue |
35 self.assertIn('exp=ignore_preview_blacklist', | 32 if not common.ParseFlags().browser_args or ( |
36 response.request_headers['chrome-proxy']) | 33 '--data-reduction-proxy-experiment' not in |
tbansal1
2017/05/19 16:27:23
It seems that the test will fail if
--data-reducti
RyanSturm
2017/05/23 22:04:57
All of our tested configurations will pass.
| |
34 common.ParseFlags().browser_args): | |
35 self.assertIn('exp=ignore_preview_blacklist', | |
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): |
46 # If it was attempted to run with another experiment, skip this test. | 46 # If it was attempted to run with another experiment, skip this test. |
47 if common.ParseFlags().browser_args and ('--data-reduction-proxy-experiment' | |
48 in common.ParseFlags().browser_args): | |
49 self.skipTest('This test cannot be run with other experiments.') | |
50 with TestDriver() as test_driver: | 47 with TestDriver() as test_driver: |
51 test_driver.AddChromeArg('--enable-spdy-proxy-auth') | 48 test_driver.AddChromeArg('--enable-spdy-proxy-auth') |
52 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=always-on') | 49 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=always-on') |
53 test_driver.AddChromeArg('--enable-data-reduction-proxy-lite-page') | 50 test_driver.AddChromeArg('--enable-data-reduction-proxy-lite-page') |
54 | 51 |
55 # This page is long and has many media resources. | 52 # This page is long and has many media resources. |
56 test_driver.LoadURL('http://check.googlezip.net/metrics/index.html') | 53 test_driver.LoadURL('http://check.googlezip.net/metrics/index.html') |
57 | 54 |
58 # Verify that a Lite Page response for the main frame was seen. | 55 # Verify that a Lite Page response for the main frame was seen. |
59 lite_page_responses = 0 | 56 lite_page_responses = 0 |
60 for response in test_driver.GetHTTPResponses(): | 57 for response in test_driver.GetHTTPResponses(): |
61 # Skip CSI requests when validating Lite Page headers. CSI requests | 58 # Skip CSI requests when validating Lite Page headers. CSI requests |
62 # aren't expected to have LoFi headers. | 59 # aren't expected to have LoFi headers. |
63 if '/csi?' in response.url: | 60 if '/csi?' in response.url: |
64 continue | 61 continue |
65 if response.url.startswith('data:'): | 62 if response.url.startswith('data:'): |
66 continue | 63 continue |
67 self.assertIn('exp=ignore_preview_blacklist', | 64 if not common.ParseFlags().browser_args or ( |
68 response.request_headers['chrome-proxy']) | 65 '--data-reduction-proxy-experiment' not in |
66 common.ParseFlags().browser_args): | |
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 |