Chromium Code Reviews| Index: telemetry/telemetry/internal/actions/action_runner_unittest.py |
| diff --git a/telemetry/telemetry/internal/actions/action_runner_unittest.py b/telemetry/telemetry/internal/actions/action_runner_unittest.py |
| index 8e89bce7663a0cd33bf1edd15d7470368460e49b..b8d562cc8415b8f84de1e1a255cd0e15920d1274 100644 |
| --- a/telemetry/telemetry/internal/actions/action_runner_unittest.py |
| +++ b/telemetry/telemetry/internal/actions/action_runner_unittest.py |
| @@ -285,6 +285,32 @@ class ActionRunnerTest(tab_test_case.TabTestCase): |
| self.assertTrue(action_runner.EvaluateJavaScript( |
| '(document.scrollingElement || document.body).scrollLeft') > 75) |
| + off_screen_element = 'document.querySelectorAll("#off-screen")[0]' |
|
nednguyen
2016/10/14 00:19:01
Can you move this to a separate test case, s.t lik
charliea (OOO until 10-5)
2016/10/14 03:34:28
+1
rnephew (Reviews Here)
2016/10/14 17:57:18
Done.
|
| + determine_if_on_screen = ''' |
|
charliea (OOO until 10-5)
2016/10/14 03:34:28
I think this variable is a little misleadingly nam
rnephew (Reviews Here)
2016/10/14 17:57:18
Done.
|
| + function getOnScreen(elem) { |
|
charliea (OOO until 10-5)
2016/10/14 03:34:28
nit: similar comment to before, where I think it m
rnephew (Reviews Here)
2016/10/14 17:57:17
Done.
|
| + var rect = elem.getBoundingClientRect(); |
| + |
| + if (rect.bottom < 0) { |
| + // The bottom of the element is above the viewport. |
| + return 2 |
|
charliea (OOO until 10-5)
2016/10/14 03:34:28
nit: all JS lines should end in semicolons
charliea (OOO until 10-5)
2016/10/14 03:34:28
I might go with -1 (above the viewport), 0 (in the
rnephew (Reviews Here)
2016/10/14 17:57:18
Done.
rnephew (Reviews Here)
2016/10/14 17:57:18
Done.
|
| + } |
| + if (rect.top - window.innerHeight > 0) { |
| + // rect.top provides the pixel offset of the element from the |
| + // top of the page. Because that exceeds the viewport's height, |
| + // we know that the element is below the viewport. |
| + return 1 |
|
charliea (OOO until 10-5)
2016/10/14 03:34:28
nit: need semicolon
rnephew (Reviews Here)
2016/10/14 17:57:18
Done.
|
| + } |
| + return 0 |
|
charliea (OOO until 10-5)
2016/10/14 03:34:28
nit: need semicolon
rnephew (Reviews Here)
2016/10/14 17:57:17
Done.
|
| + } |
| + getOnScreen(%s) |
| + ''' % off_screen_element |
| + |
| + self.assertEqual( |
| + action_runner.EvaluateJavaScript(determine_if_on_screen), 1) |
| + action_runner.ScrollPageToElement(selector='#off-screen') |
| + self.assertEqual( |
| + action_runner.EvaluateJavaScript(determine_if_on_screen), 0) |
| + |
| @decorators.Disabled('android', # crbug.com/437065. |
| 'chromeos') # crbug.com/483212. |
| def testSwipe(self): |