OLD | NEW |
---|---|
(Empty) | |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 from telemetry.page.actions import page_action | |
nduca
2013/11/24 19:22:46
lets put a docstring on this class that explains w
Sami
2013/11/29 19:29:17
Done.
| |
5 | |
6 class SyntheticDelayAction(page_action.PageAction): | |
7 def __init__(self, attributes=None): | |
8 super(SyntheticDelayAction, self).__init__(attributes) | |
9 | |
10 def WillRunAction(self, page, tab): | |
11 # Fail if browser doesn't support synthetic delays. | |
12 if not tab.EvaluateJavaScript(""" | |
13 !!(window.chrome && | |
14 chrome.gpuBenchmarking && | |
15 chrome.gpuBenchmarking.configureSyntheticDelay);"""): | |
16 raise page_action.PageActionNotSupported( | |
17 'Synthetic delays not supported for this browser') | |
18 | |
19 def RunAction(self, page, tab, previous_action): | |
20 done_callback = 'function() { window.__syntheticDelayActionDone = true; }' | |
21 target_duration = float(getattr(self, 'target_duration', '0')) | |
22 mode = getattr(self, 'mode', 'static') | |
23 tab.ExecuteJavaScript(""" | |
24 window.__syntheticDelayActionDone = false; | |
25 chrome.gpuBenchmarking.configureSyntheticDelay("%s", %f, "%s", %s);""" | |
26 % (self.name, target_duration, mode, done_callback)) | |
27 tab.WaitForJavaScriptExpression('window.__syntheticDelayActionDone ', 10) | |
28 | |
29 def CustomizeBrowserOptions(self, options): | |
30 options.AppendExtraBrowserArgs('--enable-gpu-benchmarking') | |
OLD | NEW |