Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / tools / telemetry / telemetry / page / actions / action_runner.py
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
3 # found in the LICENSE file.
4 from telemetry.web_perf import timeline_interaction_record as tir_module
5
6
7 class ActionRunner(object):
8   def __init__(self, page, tab, page_test=None):
9     self._page = page
10     self._tab = tab
11     self._page_test = page_test
12
13   #TODO(nednguyen): remove this when crbug.com/361809 is marked fixed
14   def RunAction(self, action):
15     if not action.WillWaitAfterRun():
16       action.WillRunAction(self._page, self._tab)
17     action.RunActionAndMaybeWait(self._page, self._tab)
18
19   def BeginInteraction(self, logical_name, flags):
20     """ Issues the begin of interaction record.
21         flags contains any flags in web_perf.timeline_interaction_record.
22     """
23     assert self._tab
24     self._tab.ExecuteJavaScript('console.time("%s");' %
25       tir_module.TimelineInteractionRecord.GetJavascriptMarker(logical_name,
26                                                                flags))
27
28   def EndInteraction(self, logical_name, flags):
29     """ Issues the begin of interaction record.
30         flags contains any flags in web_perf.timeline_interaction_record.
31     """
32     assert self._tab
33     self._tab.ExecuteJavaScript('console.timeEnd("%s");' %
34       tir_module.TimelineInteractionRecord.GetJavascriptMarker(logical_name,
35                                                                flags))