| Index: telemetry/telemetry/internal/actions/pinch.py
|
| diff --git a/telemetry/telemetry/internal/actions/pinch.py b/telemetry/telemetry/internal/actions/pinch.py
|
| index 3628364f53f66d2b9552820f99d4593564d1f45a..33275a4fc1f7375e085c3bb43392bbb31169e780 100644
|
| --- a/telemetry/telemetry/internal/actions/pinch.py
|
| +++ b/telemetry/telemetry/internal/actions/pinch.py
|
| @@ -10,18 +10,12 @@ from telemetry.util import js_template
|
| class PinchAction(page_action.PageAction):
|
|
|
| def __init__(self,
|
| - selector=None,
|
| - text=None,
|
| - element_function=None,
|
| left_anchor_ratio=0.5,
|
| top_anchor_ratio=0.5,
|
| scale_factor=None,
|
| speed_in_pixels_per_second=800,
|
| synthetic_gesture_source=page_action.GESTURE_SOURCE_DEFAULT):
|
| super(PinchAction, self).__init__()
|
| - self._selector = selector
|
| - self._text = text
|
| - self._element_function = element_function
|
| self._left_anchor_ratio = left_anchor_ratio
|
| self._top_anchor_ratio = top_anchor_ratio
|
| self._scale_factor = scale_factor
|
| @@ -29,10 +23,6 @@ class PinchAction(page_action.PageAction):
|
| self._synthetic_gesture_source = (
|
| 'chrome.gpuBenchmarking.%s_INPUT' % synthetic_gesture_source)
|
|
|
| - if (self._selector is None and self._text is None and
|
| - self._element_function is None):
|
| - self._element_function = 'document.body'
|
| -
|
| def WillRunAction(self, tab):
|
| utils.InjectJavaScript(tab, 'gesture_common.js')
|
| utils.InjectJavaScript(tab, 'pinch.js')
|
| @@ -50,8 +40,10 @@ class PinchAction(page_action.PageAction):
|
|
|
| @staticmethod
|
| def _GetDefaultScaleFactorForPage(tab):
|
| - current_scale_factor = tab.EvaluateJavaScript(
|
| - 'window.outerWidth / window.innerWidth')
|
| + current_scale_factor = tab.EvaluateJavaScript("""
|
| + "visualViewport" in window
|
| + ? visualViewport.scale
|
| + : window.outerWidth / window.innerWidth'""")
|
| return 3.0 / current_scale_factor
|
|
|
| def RunAction(self, tab):
|
| @@ -59,26 +51,15 @@ class PinchAction(page_action.PageAction):
|
| PinchAction._GetDefaultScaleFactorForPage(tab))
|
| code = js_template.Render(
|
| """
|
| - function(element, info) {
|
| - if (!element) {
|
| - throw Error('Cannot find element: ' + info);
|
| - }
|
| - window.__pinchAction.start({
|
| - element: element,
|
| - left_anchor_ratio: {{ left_anchor_ratio }},
|
| - top_anchor_ratio: {{ top_anchor_ratio }},
|
| - scale_factor: {{ scale_factor }},
|
| - speed: {{ speed }}
|
| - });
|
| - }""",
|
| + window.__pinchAction.start({
|
| + left_anchor_ratio: {{ left_anchor_ratio }},
|
| + top_anchor_ratio: {{ top_anchor_ratio }},
|
| + scale_factor: {{ scale_factor }},
|
| + speed: {{ speed }}
|
| + });""",
|
| left_anchor_ratio=self._left_anchor_ratio,
|
| top_anchor_ratio=self._top_anchor_ratio,
|
| scale_factor=scale_factor,
|
| speed=self._speed)
|
| - page_action.EvaluateCallbackWithElement(
|
| - tab,
|
| - code,
|
| - selector=self._selector,
|
| - text=self._text,
|
| - element_function=self._element_function)
|
| + tab.EvaluateJavaScript(code)
|
| tab.WaitForJavaScriptCondition('window.__pinchActionDone', timeout=60)
|
|
|