blob: da4c8a95c80c03677c6ca311512067ce316d7af8 [file] [log] [blame]
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from telemetry.internal.actions import page_action
from telemetry.internal.actions import utils
class MouseClickAction(page_action.ElementPageAction):
def WillRunAction(self, tab):
"""Load the mouse click JS code prior to running the action."""
super(MouseClickAction, self).WillRunAction(tab)
utils.InjectJavaScript(tab, 'mouse_click.js')
window.__mouseClickActionDone = false;
window.__mouseClickAction = new __MouseClickAction(function() {
window.__mouseClickActionDone = true;
def RunAction(self, tab):
code = '''
function(element, info) {
if (!element) {
throw Error('Cannot find element: ' + info);
element: element
self.EvaluateCallback(tab, code)
'window.__mouseClickActionDone', timeout=self.timeout)