
from telemetry.internal.actions import page_action


class ClickElementAction(page_action.ElementPageAction):

  def RunAction(self, tab):
    code = '''
        function(element, errorMsg) {
          if (!element) {
            throw Error('Cannot find element: ' + errorMsg);
          }
          element.click();
        }'''
    # Click handler that plays media or requests fullscreen may not take
    # effects without user_gesture set to True.
    self.EvaluateCallback(tab, code)


from telemetry.internal.actions import page_action


class ClickElementAction(page_action.ElementPageAction):

  def RunAction(self, tab):
    code = '''
        function(element, errorMsg) {
          if (!element) {
            throw Error('Cannot find element: ' + errorMsg);
          }
          element.click();
        }'''
    # Click handler that plays media or requests fullscreen may not take
    # effects without user_gesture set to True.
    self.EvaluateCallback(tab, code, user_gesture=True)

Fix a regression where the user_gesture bit isn't set for ClickElement.
Fix a regression where the user_gesture bit isn't set for ClickElement.

The regrssion was introduced in
https://chromium-review.googlesource.com/c/catapult/+/1335627

Once this rolls into Chromium, I'll add a chromium side test to prevent
it from regress again in the future.

Bug: chromium:885912
TEST=manual
R=58bdb6276c01e3ed53e660bf706aa902204feb0d@chromium.org,kbr@chromium.org

Change-Id: Ic1c7e83a3e7d7318baa81531925dab07db9450ca
Reviewed-on: https://chromium-review.googlesource.com/c/1476957
Reviewed-by: Caleb Rouleau <58bdb6276c01e3ed53e660bf706aa902204feb0d@chromium.org>
Commit-Queue: Zhenyao Mo <655bdf1d95ff956cd68886dd9e86ee5e987c9dbb@chromium.org>

  
  from telemetry.internal.actions import page_action
  
  
  class ClickElementAction(page_action.ElementPageAction):
  
    def RunAction(self, tab):
      code = '''
          function(element, errorMsg) {
            if (!element) {
              throw Error('Cannot find element: ' + errorMsg);
            }
            element.click();
          }'''
      # Click handler that plays media or requests fullscreen may not take
      # effects without user_gesture set to True.
-     self.EvaluateCallback(tab, code)
+     self.EvaluateCallback(tab, code, user_gesture=True)
  
Fix a regression where the user_gesture bit isn't set for ClickElement.
## Code Before:

from telemetry.internal.actions import page_action


class ClickElementAction(page_action.ElementPageAction):

  def RunAction(self, tab):
    code = '''
        function(element, errorMsg) {
          if (!element) {
            throw Error('Cannot find element: ' + errorMsg);
          }
          element.click();
        }'''
    # Click handler that plays media or requests fullscreen may not take
    # effects without user_gesture set to True.
    self.EvaluateCallback(tab, code)

## Instruction:
Fix a regression where the user_gesture bit isn't set for ClickElement.
## Code After:

from telemetry.internal.actions import page_action


class ClickElementAction(page_action.ElementPageAction):

  def RunAction(self, tab):
    code = '''
        function(element, errorMsg) {
          if (!element) {
            throw Error('Cannot find element: ' + errorMsg);
          }
          element.click();
        }'''
    # Click handler that plays media or requests fullscreen may not take
    # effects without user_gesture set to True.
    self.EvaluateCallback(tab, code, user_gesture=True)
