Chromium Code Reviews| Index: tools/telemetry/telemetry/page/actions/scroll_unittest.py |
| diff --git a/tools/telemetry/telemetry/page/actions/scroll_unittest.py b/tools/telemetry/telemetry/page/actions/scroll_unittest.py |
| index 85b35f1c6800194e0d0d03a4d422d7bb5c298f7e..52450cb33024458c89309801d3d11bf1d20b1a26 100644 |
| --- a/tools/telemetry/telemetry/page/actions/scroll_unittest.py |
| +++ b/tools/telemetry/telemetry/page/actions/scroll_unittest.py |
| @@ -10,7 +10,6 @@ from telemetry.unittest_util import tab_test_case |
| class ScrollActionTest(tab_test_case.TabTestCase): |
| - @decorators.Disabled # Disabled due to flakiness: crbug.com/330544 |
|
nednguyen
2015/03/04 05:40:49
Can you make a separate patch for enabling this? T
|
| def testScrollAction(self): |
| self.Navigate('blank.html') |
| @@ -47,6 +46,65 @@ class ScrollActionTest(tab_test_case.TabTestCase): |
| msg='scroll_position=%d; scroll_height=%d' % |
| (scroll_position, scroll_height)) |
| + def testDiagonalScrollAction(self): |
| + self.Navigate('blank.html') |
| + |
| + # Make page bigger than window so it's scrollable. |
| + self._tab.ExecuteJavaScript("""document.body.style.height = |
| + (2 * window.innerHeight + 1) + 'px';""") |
| + self._tab.ExecuteJavaScript("""document.body.style.width = |
| + (2 * window.innerWidth + 1) + 'px';""") |
| + |
| + self.assertEquals( |
| + self._tab.EvaluateJavaScript("""document.documentElement.scrollTop |
| + || document.body.scrollTop"""), 0) |
| + self.assertEquals( |
| + self._tab.EvaluateJavaScript("""document.documentElement.scrollLeft |
| + || document.body.scrollLeft"""), 0) |
| + |
| + i = scroll.ScrollAction(direction='downright') |
| + i.WillRunAction(self._tab) |
| + |
| + self._tab.ExecuteJavaScript(""" |
| + window.__scrollAction.beginMeasuringHook = function() { |
| + window.__didBeginMeasuring = true; |
| + }; |
| + window.__scrollAction.endMeasuringHook = function() { |
| + window.__didEndMeasuring = true; |
| + };""") |
| + i.RunAction(self._tab) |
| + |
| + self.assertTrue(self._tab.EvaluateJavaScript('window.__didBeginMeasuring')) |
| + self.assertTrue(self._tab.EvaluateJavaScript('window.__didEndMeasuring')) |
| + |
| + # Allow for roundoff error in scaled viewport. |
| + viewport_bottom = self._tab.EvaluateJavaScript( |
| + """(document.documentElement.scrollTop || document.body.scrollTop) |
| + + window.innerHeight""") |
| + page_height = self._tab.EvaluateJavaScript('document.body.scrollHeight') |
| + viewport_right = self._tab.EvaluateJavaScript( |
| + """(document.documentElement.scrollLeft || document.body.scrollLeft) |
| + + window.innerWidth""") |
| + page_width = self._tab.EvaluateJavaScript('document.body.scrollWidth') |
| + |
| + # The diagonal scrolling behaves like a square. |
| + # It will not continue scrolling down if it cannot also scroll right. |
| + # So determine which axis scrolled all the way to its end. |
| + vertical_difference = abs(viewport_bottom - page_height) |
| + horizontal_difference = abs(viewport_right - page_width) |
| + scroll_distance = min(vertical_difference, horizontal_difference) |
| + self.assertTrue(scroll_distance <= 1, |
| + msg=('vertical_difference=%d; ' |
| + 'horizontal_difference=%d; ' |
| + 'scroll_distance=%d ' |
| + 'page_height=%d ' |
| + 'page_width=%d') % |
| + (vertical_difference, |
| + horizontal_difference, |
| + scroll_distance, |
| + page_height, |
| + page_width)) |
| + |
| def testBoundingClientRect(self): |
| self.Navigate('blank.html') |