Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: tools/chrome_proxy/integration_tests/chrome_proxy_measurements.py

Issue 2672803002: [Telemetry refactor] Migrate clients to new JavaScript API (batch 3) (Closed)
Patch Set: add comment on tools/android Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 base64 5 import base64
6 import logging 6 import logging
7 import urlparse 7 import urlparse
8 8
9 from common import chrome_proxy_measurements as measurements 9 from common import chrome_proxy_measurements as measurements
10 from common.chrome_proxy_measurements import ChromeProxyValidation 10 from common.chrome_proxy_measurements import ChromeProxyValidation
(...skipping 29 matching lines...) Expand all
40 options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth') 40 options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth')
41 41
42 def WillNavigateToPage(self, page, tab): 42 def WillNavigateToPage(self, page, tab):
43 if self._enable_proxy: 43 if self._enable_proxy:
44 measurements.WaitForViaHeader(tab) 44 measurements.WaitForViaHeader(tab)
45 tab.ClearCache(force=True) 45 tab.ClearCache(force=True)
46 self._metrics.Start(page, tab) 46 self._metrics.Start(page, tab)
47 47
48 def ValidateAndMeasurePage(self, page, tab, results): 48 def ValidateAndMeasurePage(self, page, tab, results):
49 # Wait for the load event. 49 # Wait for the load event.
50 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300) 50 tab.WaitForJavaScriptCondition2(
51 'performance.timing.loadEventStart', timeout=300)
51 self._metrics.Stop(page, tab) 52 self._metrics.Stop(page, tab)
52 self._metrics.AddResultsForDataSaving(tab, results) 53 self._metrics.AddResultsForDataSaving(tab, results)
53 54
54 55
55 class ChromeProxyHeaders(ChromeProxyValidation): 56 class ChromeProxyHeaders(ChromeProxyValidation):
56 """Correctness measurement for response headers.""" 57 """Correctness measurement for response headers."""
57 58
58 def __init__(self): 59 def __init__(self):
59 super(ChromeProxyHeaders, self).__init__( 60 super(ChromeProxyHeaders, self).__init__(
60 restart_after_each_page=True, 61 restart_after_each_page=True,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 """Correctness measurement for bypass responses for CORS requests.""" 117 """Correctness measurement for bypass responses for CORS requests."""
117 118
118 def __init__(self): 119 def __init__(self):
119 super(ChromeProxyCorsBypass, self).__init__( 120 super(ChromeProxyCorsBypass, self).__init__(
120 restart_after_each_page=True, 121 restart_after_each_page=True,
121 metrics=metrics.ChromeProxyMetric()) 122 metrics=metrics.ChromeProxyMetric())
122 123
123 def ValidateAndMeasurePage(self, page, tab, results): 124 def ValidateAndMeasurePage(self, page, tab, results):
124 # The test page sets window.xhrRequestCompleted to true when the XHR fetch 125 # The test page sets window.xhrRequestCompleted to true when the XHR fetch
125 # finishes. 126 # finishes.
126 tab.WaitForJavaScriptExpression('window.xhrRequestCompleted', 300) 127 tab.WaitForJavaScriptCondition2('window.xhrRequestCompleted', timeout=300)
127 super(ChromeProxyCorsBypass, 128 super(ChromeProxyCorsBypass,
128 self).ValidateAndMeasurePage(page, tab, results) 129 self).ValidateAndMeasurePage(page, tab, results)
129 130
130 def AddResults(self, tab, results): 131 def AddResults(self, tab, results):
131 self._metrics.AddResultsForCorsBypass(tab, results) 132 self._metrics.AddResultsForCorsBypass(tab, results)
132 133
133 134
134 class ChromeProxyBlockOnce(ChromeProxyValidation): 135 class ChromeProxyBlockOnce(ChromeProxyValidation):
135 """Correctness measurement for block-once responses.""" 136 """Correctness measurement for block-once responses."""
136 137
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 self._is_lo_fi_enabled = False 359 self._is_lo_fi_enabled = False
359 360
360 def WillNavigateToPage(self, page, tab): 361 def WillNavigateToPage(self, page, tab):
361 super(ChromeProxyCacheLoFiDisabled, self).WillNavigateToPage(page, tab) 362 super(ChromeProxyCacheLoFiDisabled, self).WillNavigateToPage(page, tab)
362 if self._is_lo_fi_enabled: 363 if self._is_lo_fi_enabled:
363 # Clear cache for the first page to pick LoFi image from server. 364 # Clear cache for the first page to pick LoFi image from server.
364 tab.ClearCache(force=True) 365 tab.ClearCache(force=True)
365 366
366 def DidNavigateToPage(self, page, tab): 367 def DidNavigateToPage(self, page, tab):
367 if not self._is_lo_fi_enabled: 368 if not self._is_lo_fi_enabled:
368 tab.ExecuteJavaScript('window.location.reload()') 369 tab.ExecuteJavaScript2('window.location.reload()')
369 util.WaitFor(tab.HasReachedQuiescence, 3) 370 util.WaitFor(tab.HasReachedQuiescence, 3)
370 371
371 class ChromeProxyCacheProxyDisabled(ChromeProxyValidation): 372 class ChromeProxyCacheProxyDisabled(ChromeProxyValidation):
372 """ 373 """
373 Correctness measurement for Lo-Fi placeholder is not loaded from cache when a 374 Correctness measurement for Lo-Fi placeholder is not loaded from cache when a
374 page is reloaded with data reduction proxy disabled. First a test page is 375 page is reloaded with data reduction proxy disabled. First a test page is
375 opened with LoFi and chrome proxy enabled. This allows Chrome to cache the 376 opened with LoFi and chrome proxy enabled. This allows Chrome to cache the
376 LoFi placeholder image. The browser is restarted with chrome proxy disabled 377 LoFi placeholder image. The browser is restarted with chrome proxy disabled
377 and the same test page is loaded. This second page load should not pick the 378 and the same test page is loaded. This second page load should not pick the
378 LoFi placeholder from cache and original image should be loaded. This test 379 LoFi placeholder from cache and original image should be loaded. This test
(...skipping 26 matching lines...) Expand all
405 self.DisableChromeProxy() 406 self.DisableChromeProxy()
406 407
407 def WillNavigateToPage(self, page, tab): 408 def WillNavigateToPage(self, page, tab):
408 super(ChromeProxyCacheProxyDisabled, self).WillNavigateToPage(page, tab) 409 super(ChromeProxyCacheProxyDisabled, self).WillNavigateToPage(page, tab)
409 if self._is_chrome_proxy_enabled: 410 if self._is_chrome_proxy_enabled:
410 # Clear cache for the first page to pick LoFi image from server. 411 # Clear cache for the first page to pick LoFi image from server.
411 tab.ClearCache(force=True) 412 tab.ClearCache(force=True)
412 413
413 def DidNavigateToPage(self, page, tab): 414 def DidNavigateToPage(self, page, tab):
414 if not self._is_chrome_proxy_enabled: 415 if not self._is_chrome_proxy_enabled:
415 tab.ExecuteJavaScript('window.location.reload()') 416 tab.ExecuteJavaScript2('window.location.reload()')
416 util.WaitFor(tab.HasReachedQuiescence, 3) 417 util.WaitFor(tab.HasReachedQuiescence, 3)
417 418
418 class ChromeProxyLitePage(ChromeProxyValidation): 419 class ChromeProxyLitePage(ChromeProxyValidation):
419 """Correctness measurement for lite pages in the Chrome-Proxy header.""" 420 """Correctness measurement for lite pages in the Chrome-Proxy header."""
420 421
421 def __init__(self): 422 def __init__(self):
422 super(ChromeProxyLitePage, self).__init__( 423 super(ChromeProxyLitePage, self).__init__(
423 restart_after_each_page=True, 424 restart_after_each_page=True,
424 metrics=metrics.ChromeProxyMetric()) 425 metrics=metrics.ChromeProxyMetric())
425 426
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 options.AppendExtraBrowserArgs( 495 options.AppendExtraBrowserArgs(
495 '--data-reduction-proxy-http-proxies=' 496 '--data-reduction-proxy-http-proxies='
496 'http://nonexistent.googlezip.net;http://compress.googlezip.net') 497 'http://nonexistent.googlezip.net;http://compress.googlezip.net')
497 498
498 def WillNavigateToPage(self, page, tab): 499 def WillNavigateToPage(self, page, tab):
499 super(ChromeProxyHTTPToDirectFallback, self).WillNavigateToPage(page, tab) 500 super(ChromeProxyHTTPToDirectFallback, self).WillNavigateToPage(page, tab)
500 # Attempt to load a page through the nonexistent primary proxy in order to 501 # Attempt to load a page through the nonexistent primary proxy in order to
501 # cause a proxy fallback, and have this test run starting from the HTTP 502 # cause a proxy fallback, and have this test run starting from the HTTP
502 # fallback proxy. 503 # fallback proxy.
503 tab.Navigate(_TEST_SERVER_DEFAULT_URL) 504 tab.Navigate(_TEST_SERVER_DEFAULT_URL)
504 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300) 505 tab.WaitForJavaScriptCondition2(
506 'performance.timing.loadEventStart', timeout=300)
505 507
506 def AddResults(self, tab, results): 508 def AddResults(self, tab, results):
507 self._metrics.AddResultsForHTTPToDirectFallback(tab, results, _TEST_SERVER) 509 self._metrics.AddResultsForHTTPToDirectFallback(tab, results, _TEST_SERVER)
508 510
509 511
510 class ChromeProxyReenableAfterBypass(ChromeProxyValidation): 512 class ChromeProxyReenableAfterBypass(ChromeProxyValidation):
511 """Correctness measurement for re-enabling proxies after bypasses. 513 """Correctness measurement for re-enabling proxies after bypasses.
512 514
513 This test loads a page that causes all data reduction proxies to be bypassed 515 This test loads a page that causes all data reduction proxies to be bypassed
514 for 1 to 5 minutes, then waits 5 minutes and verifies that the proxy is no 516 for 1 to 5 minutes, then waits 5 minutes and verifies that the proxy is no
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth') 597 options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth')
596 598
597 def WillNavigateToPage(self, page, tab): 599 def WillNavigateToPage(self, page, tab):
598 if self._enable_proxy: 600 if self._enable_proxy:
599 measurements.WaitForViaHeader(tab) 601 measurements.WaitForViaHeader(tab)
600 tab.ClearCache(force=True) 602 tab.ClearCache(force=True)
601 self._metrics.Start(page, tab) 603 self._metrics.Start(page, tab)
602 604
603 def ValidateAndMeasurePage(self, page, tab, results): 605 def ValidateAndMeasurePage(self, page, tab, results):
604 # Wait for the load event. 606 # Wait for the load event.
605 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300) 607 tab.WaitForJavaScriptCondition2(
608 'performance.timing.loadEventStart', timeout=300)
606 self._metrics.Stop(page, tab) 609 self._metrics.Stop(page, tab)
607 page_to_metrics = { 610 page_to_metrics = {
608 'header validation': [self._metrics.AddResultsForHeaderValidation], 611 'header validation': [self._metrics.AddResultsForHeaderValidation],
609 'compression: image': [ 612 'compression: image': [
610 self._metrics.AddResultsForHeaderValidation, 613 self._metrics.AddResultsForHeaderValidation,
611 self._metrics.AddResultsForDataSaving, 614 self._metrics.AddResultsForDataSaving,
612 ], 615 ],
613 'compression: javascript': [ 616 'compression: javascript': [
614 self._metrics.AddResultsForHeaderValidation, 617 self._metrics.AddResultsForHeaderValidation,
615 self._metrics.AddResultsForDataSaving, 618 self._metrics.AddResultsForDataSaving,
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 '--enable-stats-collection-bindings') 796 '--enable-stats-collection-bindings')
794 797
795 def WillNavigateToPage(self, page, tab): 798 def WillNavigateToPage(self, page, tab):
796 if self._enable_proxy: 799 if self._enable_proxy:
797 measurements.WaitForViaHeader(tab) 800 measurements.WaitForViaHeader(tab)
798 tab.ClearCache(force=True) 801 tab.ClearCache(force=True)
799 self._metrics.Start(page, tab) 802 self._metrics.Start(page, tab)
800 803
801 def ValidateAndMeasurePage(self, page, tab, results): 804 def ValidateAndMeasurePage(self, page, tab, results):
802 # Wait for the load event. 805 # Wait for the load event.
803 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300) 806 tab.WaitForJavaScriptCondition2(
807 'performance.timing.loadEventStart', timeout=300)
804 self._metrics.Stop(page, tab) 808 self._metrics.Stop(page, tab)
805 self._metrics.AddResultsForQuicTransaction(tab, results) 809 self._metrics.AddResultsForQuicTransaction(tab, results)
OLDNEW
« no previous file with comments | « tools/chrome_proxy/common/chrome_proxy_measurements.py ('k') | tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698