| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 """ | 5 """ |
| 6 Cache temperature specifies how the browser cache should be configured before | 6 Cache temperature specifies how the browser cache should be configured before |
| 7 the page run. | 7 the page run. |
| 8 | 8 |
| 9 See design doc for details: | 9 See design doc for details: |
| 10 https://docs.google.com/document/u/1/d/12D7tkhZi887g9d0U2askU9JypU_wYiEI7Lw0bfwx
UgA | 10 https://docs.google.com/document/u/1/d/12D7tkhZi887g9d0U2askU9JypU_wYiEI7Lw0bfwx
UgA |
| 11 """ | 11 """ |
| 12 | 12 |
| 13 import logging | 13 import logging |
| 14 | 14 |
| 15 # Default Cache Temperature. The page doesn't care which browser cache state | 15 # Default Cache Temperature. The page doesn't care which browser cache state |
| 16 # it is run on. | 16 # it is run on. |
| 17 ANY = 'any' | 17 ANY = 'any' |
| 18 # Emulates cold runs. Clears various caches and data with using tab.ClearCache() | 18 # Emulates cold runs. Clears various caches and data with using tab.ClearCache() |
| 19 # and tab.ClearDataForOrigin(). | 19 # and tab.ClearDataForOrigin(). |
| 20 COLD = 'cold' | 20 COLD = 'cold' |
| 21 # Emulates warm runs. Ensures that the page was visited once before the run. | 21 # Emulates warm runs. Ensures that the page was visited once before the run. |
| 22 WARM = 'warm' | 22 WARM = 'warm' |
| 23 # Emulates hot runs. Ensures that the page was visited at least twice before | 23 # Emulates hot runs. Ensures that the page was visited at least twice before |
| 24 # the run. | 24 # the run. |
| 25 HOT = 'hot' | 25 HOT = 'hot' |
| 26 | 26 |
| 27 # These regacy states will be removed after chromium test scripts are adapted | |
| 28 # to new states. | |
| 29 PCV1_COLD = COLD | |
| 30 PCV1_WARM = WARM | |
| 31 | |
| 32 class MarkTelemetryInternal(object): | 27 class MarkTelemetryInternal(object): |
| 33 | 28 |
| 34 def __init__(self, browser, identifier): | 29 def __init__(self, browser, identifier): |
| 35 self.browser = browser | 30 self.browser = browser |
| 36 self.identifier = identifier | 31 self.identifier = identifier |
| 37 | 32 |
| 38 def __enter__(self): | 33 def __enter__(self): |
| 39 marker = 'telemetry.internal.%s.start' % self.identifier | 34 marker = 'telemetry.internal.%s.start' % self.identifier |
| 40 self.browser.tabs[0].ExecuteJavaScript( | 35 self.browser.tabs[0].ExecuteJavaScript( |
| 41 "console.time({{ marker }});", marker=marker) | 36 "console.time({{ marker }});", marker=marker) |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 tab = browser.tabs[0] | 119 tab = browser.tabs[0] |
| 125 tab.Navigate("http://does.not.exist") | 120 tab.Navigate("http://does.not.exist") |
| 126 tab.WaitForDocumentReadyStateToBeComplete() | 121 tab.WaitForDocumentReadyStateToBeComplete() |
| 127 # Stop all service workers before running tests to measure the starting | 122 # Stop all service workers before running tests to measure the starting |
| 128 # time of service worker too. | 123 # time of service worker too. |
| 129 browser.tabs[0].StopAllServiceWorkers() | 124 browser.tabs[0].StopAllServiceWorkers() |
| 130 else: | 125 else: |
| 131 ClearCacheAndData(browser, page.url) | 126 ClearCacheAndData(browser, page.url) |
| 132 WarmCache(page, browser, WARM) | 127 WarmCache(page, browser, WARM) |
| 133 WarmCache(page, browser, HOT) | 128 WarmCache(page, browser, HOT) |
| OLD | NEW |