| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 from telemetry.page import page as page_module | 4 from telemetry.page import page as page_module |
| 5 from telemetry.page import shared_page_state | 5 from telemetry.page import shared_page_state |
| 6 from telemetry import story | 6 from telemetry import story |
| 7 | 7 |
| 8 TIME_TO_WAIT_BEFORE_STARTING_IN_SECONDS = 5 | 8 TIME_TO_WAIT_BEFORE_STARTING_IN_SECONDS = 5 |
| 9 | 9 |
| 10 # TODO(ulan): Remove this once crbug.com/541508 is fixed. | 10 # TODO(ulan): Remove this once crbug.com/541508 is fixed. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 with action_runner.CreateInteraction('End'): | 24 with action_runner.CreateInteraction('End'): |
| 25 action_runner.tab.browser.DumpMemory() | 25 action_runner.tab.browser.DumpMemory() |
| 26 | 26 |
| 27 def _WaitAction(action_runner): | 27 def _WaitAction(action_runner): |
| 28 action_runner.WaitForJavaScriptCondition( | 28 action_runner.WaitForJavaScriptCondition( |
| 29 'document.body != null && ' | 29 'document.body != null && ' |
| 30 'document.body.scrollHeight > window.innerHeight && ' | 30 'document.body.scrollHeight > window.innerHeight && ' |
| 31 '!document.body.addEventListener("touchstart", function() {})') | 31 '!document.body.addEventListener("touchstart", function() {})') |
| 32 | 32 |
| 33 def _CreateInfiniteScrollPageClass(base_page_cls): | 33 def _CreateInfiniteScrollPageClass(base_page_cls): |
| 34 class DerivedSmoothPage(base_page_cls): # pylint: disable=W0232 | 34 class DerivedSmoothPage(base_page_cls): # pylint: disable=no-init |
| 35 def RunPageInteractions(self, action_runner): | 35 def RunPageInteractions(self, action_runner): |
| 36 _WaitAction(action_runner) | 36 _WaitAction(action_runner) |
| 37 _ScrollAction(action_runner, self.scroll_amount) | 37 _ScrollAction(action_runner, self.scroll_amount) |
| 38 return DerivedSmoothPage | 38 return DerivedSmoothPage |
| 39 | 39 |
| 40 class InfiniteScrollPage(page_module.Page): | 40 class InfiniteScrollPage(page_module.Page): |
| 41 def __init__(self, url, page_set, name, scroll_amount, credentials=None): | 41 def __init__(self, url, page_set, name, scroll_amount, credentials=None): |
| 42 super(InfiniteScrollPage, self).__init__( | 42 super(InfiniteScrollPage, self).__init__( |
| 43 url=url, page_set=page_set, name=name, | 43 url=url, page_set=page_set, name=name, |
| 44 shared_page_state_class=shared_page_state.SharedPageState, | 44 shared_page_state_class=shared_page_state.SharedPageState, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 61 ('https://www.facebook.com/shakira', 'facebook', SCROLL_FAR), | 61 ('https://www.facebook.com/shakira', 'facebook', SCROLL_FAR), |
| 62 ('https://twitter.com/taylorswift13', 'twitter', SCROLL_FAR), | 62 ('https://twitter.com/taylorswift13', 'twitter', SCROLL_FAR), |
| 63 ('http://espn.go.com/', 'espn', SCROLL_NEAR), | 63 ('http://espn.go.com/', 'espn', SCROLL_NEAR), |
| 64 ('https://www.yahoo.com', 'yahoo', SCROLL_NEAR), | 64 ('https://www.yahoo.com', 'yahoo', SCROLL_NEAR), |
| 65 ('http://techcrunch.tumblr.com/', 'tumblr', SCROLL_FAR), | 65 ('http://techcrunch.tumblr.com/', 'tumblr', SCROLL_FAR), |
| 66 ('https://www.flickr.com/explore', 'flickr', SCROLL_FAR) | 66 ('https://www.flickr.com/explore', 'flickr', SCROLL_FAR) |
| 67 ] | 67 ] |
| 68 for (url, name, scroll_amount) in pages: | 68 for (url, name, scroll_amount) in pages: |
| 69 page_class = _CreateInfiniteScrollPageClass(InfiniteScrollPage) | 69 page_class = _CreateInfiniteScrollPageClass(InfiniteScrollPage) |
| 70 self.AddStory(page_class(url, self, name, scroll_amount)) | 70 self.AddStory(page_class(url, self, name, scroll_amount)) |
| OLD | NEW |