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 | 4 |
5 from telemetry.core import exceptions | 5 from telemetry.core import exceptions |
6 from telemetry.page import page as page_module | 6 from telemetry.page import page as page_module |
7 from telemetry.web_perf import timeline_interaction_record | |
7 from telemetry import story | 8 from telemetry import story |
8 | 9 |
9 | 10 |
10 class SwiffyPage(page_module.Page): | 11 class SwiffyPage(page_module.Page): |
11 | 12 |
12 def __init__(self, url, page_set): | 13 def __init__(self, url, page_set): |
13 super(SwiffyPage, self).__init__(url=url, page_set=page_set, | 14 super(SwiffyPage, self).__init__(url=url, page_set=page_set, |
14 make_javascript_deterministic=False) | 15 make_javascript_deterministic=False) |
15 | 16 |
16 def RunNavigateSteps(self, action_runner): | 17 def RunNavigateSteps(self, action_runner): |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 # Give the page one second to become interactive and start scrolling after | 53 # Give the page one second to become interactive and start scrolling after |
53 # the timeout regardless of the document's ready state. | 54 # the timeout regardless of the document's ready state. |
54 try: | 55 try: |
55 action_runner.tab.WaitForDocumentReadyStateToBeInteractiveOrBetter(1) | 56 action_runner.tab.WaitForDocumentReadyStateToBeInteractiveOrBetter(1) |
56 except exceptions.TimeoutException: | 57 except exceptions.TimeoutException: |
57 pass | 58 pass |
58 # Make sure we have a body element to scroll. | 59 # Make sure we have a body element to scroll. |
59 action_runner.WaitForJavaScriptCondition('document.body !== null') | 60 action_runner.WaitForJavaScriptCondition('document.body !== null') |
60 | 61 |
61 def RunPageInteractions(self, action_runner): | 62 def RunPageInteractions(self, action_runner): |
62 for _ in range(10): | 63 # Set up a browser driven repeating scroll. The delay between the scrolls |
63 with action_runner.CreateGestureInteraction('ScrollAction', | 64 # should be unaffected by render thread responsivness (or lack there of). |
64 repeatable=True): | 65 flags = [timeline_interaction_record.REPEATABLE] |
65 action_runner.ScrollPage(distance=500, | 66 scroll_command = { |
66 top_start_ratio=self._top_start_ratio) | 67 'method': 'Input.synthesizeScrollGesture', |
67 action_runner.Wait(.25) | 68 'params': { |
68 | 69 'x': 500, |
Sami
2015/08/17 17:06:44
Can we compute these to always be the middle of sc
alex clarke (OOO till 29th)
2015/08/18 13:40:51
Done.
| |
70 'y': 500, | |
71 'xDistance': 0, | |
72 'yDistance': -300, | |
73 'preventFling': True, | |
74 'repeatCount': 9, | |
Sami
2015/08/17 17:06:44
10 assuming we change repeatCount to mean the tota
alex clarke (OOO till 29th)
2015/08/18 13:40:51
Acknowledged.
| |
75 'repeatDelayMs': 250, | |
76 'interactionMarkerName': | |
77 timeline_interaction_record.GetJavaScriptMarker( | |
78 'Gesture_ScrollAction', flags), | |
79 } | |
80 } | |
81 action_runner.tab.RunInspectorCommand(scroll_command) | |
69 | 82 |
70 class ScrollingForbesPage(ScrollingPage): | 83 class ScrollingForbesPage(ScrollingPage): |
71 | 84 |
72 def __init__(self, url, page_set): | 85 def __init__(self, url, page_set): |
73 # forbes.com uses a strange dynamic transform on the body element, | 86 # forbes.com uses a strange dynamic transform on the body element, |
74 # which occasionally causes us to try scrolling from outside the | 87 # which occasionally causes us to try scrolling from outside the |
75 # screen. Start at the very top of the viewport to avoid this. | 88 # screen. Start at the very top of the viewport to avoid this. |
76 super(ScrollingForbesPage, self).__init__( | 89 super(ScrollingForbesPage, self).__init__( |
77 url=url, page_set=page_set, top_start_ratio=0, | 90 url=url, page_set=page_set, top_start_ratio=0, |
78 make_javascript_deterministic=False) | 91 make_javascript_deterministic=False) |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 self.AddStory(ScrollingPage('http://www.androidauthority.com/' | 147 self.AddStory(ScrollingPage('http://www.androidauthority.com/' |
135 'reduce-data-use-turn-on-data-compression-in-chrome-630064/', self)) | 148 'reduce-data-use-turn-on-data-compression-in-chrome-630064/', self)) |
136 self.AddStory(ScrollingPage('http://www.cnn.com/2015/01/09/politics/' | 149 self.AddStory(ScrollingPage('http://www.cnn.com/2015/01/09/politics/' |
137 'nebraska-keystone-pipeline/index.html', self, top_start_ratio=0)) | 150 'nebraska-keystone-pipeline/index.html', self, top_start_ratio=0)) |
138 self.AddStory(ScrollingPage('http://time.com/3977891/' | 151 self.AddStory(ScrollingPage('http://time.com/3977891/' |
139 'donald-trump-debate-republican/', self)) | 152 'donald-trump-debate-republican/', self)) |
140 self.AddStory(ScrollingPage('http://www.theguardian.com/uk', self)) | 153 self.AddStory(ScrollingPage('http://www.theguardian.com/uk', self)) |
141 self.AddStory(ScrollingPage('http://m.tmz.com', self)) | 154 self.AddStory(ScrollingPage('http://m.tmz.com', self)) |
142 self.AddStory(ScrollingPage('http://androidpolice.com', self, | 155 self.AddStory(ScrollingPage('http://androidpolice.com', self, |
143 top_start_ratio=0)) | 156 top_start_ratio=0)) |
OLD | NEW |