| 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 page_sets import repeatable_synthesize_scroll_gesture_shared_state | 5 from page_sets import repeatable_synthesize_scroll_gesture_shared_state |
| 6 | 6 |
| 7 from telemetry.page import page as page_module | 7 from telemetry.page import page as page_module |
| 8 from telemetry import story | 8 from telemetry import story |
| 9 | 9 |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 action_runner.EvaluateJavaScript(viewport_js) | 29 action_runner.EvaluateJavaScript(viewport_js) |
| 30 | 30 |
| 31 def RunPageInteractions(self, action_runner): | 31 def RunPageInteractions(self, action_runner): |
| 32 with action_runner.CreateInteraction('ToughAd'): | 32 with action_runner.CreateInteraction('ToughAd'): |
| 33 action_runner.Wait(10) | 33 action_runner.Wait(10) |
| 34 | 34 |
| 35 | 35 |
| 36 class AdPage(page_module.Page): | 36 class AdPage(page_module.Page): |
| 37 | 37 |
| 38 def __init__(self, url, page_set, make_javascript_deterministic=True, | 38 def __init__(self, url, page_set, make_javascript_deterministic=True, |
| 39 y_scroll_distance_multiplier=0.5, bidirectional_scroll=False, | 39 y_scroll_distance_multiplier=0.5, |
| 40 scroll=False, | 40 scroll=False, |
| 41 wait_for_interactive_or_better=False): | 41 wait_for_interactive_or_better=False): |
| 42 super(AdPage, self).__init__( | 42 super(AdPage, self).__init__( |
| 43 url=url, | 43 url=url, |
| 44 page_set=page_set, | 44 page_set=page_set, |
| 45 make_javascript_deterministic=make_javascript_deterministic, | 45 make_javascript_deterministic=make_javascript_deterministic, |
| 46 shared_page_state_class=( | 46 shared_page_state_class=( |
| 47 repeatable_synthesize_scroll_gesture_shared_state.\ | 47 repeatable_synthesize_scroll_gesture_shared_state.\ |
| 48 RepeatableSynthesizeScrollGestureSharedState)) | 48 RepeatableSynthesizeScrollGestureSharedState)) |
| 49 self._y_scroll_distance_multiplier = y_scroll_distance_multiplier | 49 self._y_scroll_distance_multiplier = y_scroll_distance_multiplier |
| 50 self._scroll = scroll | 50 self._scroll = scroll |
| 51 self._bidirectional_scroll = bidirectional_scroll | |
| 52 self._wait_for_interactive_or_better = wait_for_interactive_or_better | 51 self._wait_for_interactive_or_better = wait_for_interactive_or_better |
| 53 | 52 |
| 54 def RunNavigateSteps(self, action_runner): | 53 def RunNavigateSteps(self, action_runner): |
| 55 # Rewrite file urls to point to the replay server instead. | 54 # Rewrite file urls to point to the replay server instead. |
| 56 if self.is_file: | 55 if self.is_file: |
| 57 url = self.file_path_url_with_scheme | 56 url = self.file_path_url_with_scheme |
| 58 url = action_runner.tab.browser.platform.http_server.UrlOf( | 57 url = action_runner.tab.browser.platform.http_server.UrlOf( |
| 59 url[len('file://'):]) | 58 url[len('file://'):]) |
| 60 else: | 59 else: |
| 61 url = self._url | 60 url = self._url |
| (...skipping 13 matching lines...) Expand all Loading... |
| 75 else: | 74 else: |
| 76 action_runner.WaitForJavaScriptCondition( | 75 action_runner.WaitForJavaScriptCondition( |
| 77 'document.body != null && ' | 76 'document.body != null && ' |
| 78 'document.body.scrollHeight > window.innerHeight && ' | 77 'document.body.scrollHeight > window.innerHeight && ' |
| 79 '!document.body.addEventListener("touchstart", function() {})') | 78 '!document.body.addEventListener("touchstart", function() {})') |
| 80 | 79 |
| 81 def RunPageInteractions(self, action_runner): | 80 def RunPageInteractions(self, action_runner): |
| 82 if not self._scroll: | 81 if not self._scroll: |
| 83 with action_runner.CreateInteraction('ToughAd'): | 82 with action_runner.CreateInteraction('ToughAd'): |
| 84 action_runner.Wait(30) | 83 action_runner.Wait(30) |
| 85 elif self._bidirectional_scroll: | |
| 86 action_runner.RepeatableBrowserDrivenScroll( | |
| 87 y_scroll_distance_ratio=self._y_scroll_distance_multiplier, | |
| 88 repeat_count=4) | |
| 89 action_runner.RepeatableBrowserDrivenScroll( | |
| 90 y_scroll_distance_ratio=-self._y_scroll_distance_multiplier * .5, | |
| 91 repeat_count=4) | |
| 92 else: | 84 else: |
| 93 action_runner.RepeatableBrowserDrivenScroll( | 85 action_runner.RepeatableBrowserDrivenScroll( |
| 94 y_scroll_distance_ratio=self._y_scroll_distance_multiplier, | 86 y_scroll_distance_ratio=self._y_scroll_distance_multiplier, |
| 95 repeat_count=9) | 87 repeat_count=9) |
| 96 | 88 |
| 97 | 89 |
| 98 class ForbesAdPage(AdPage): | 90 class ForbesAdPage(AdPage): |
| 99 | 91 |
| 100 def __init__(self, url, page_set, scroll=False, bidirectional_scroll=False): | 92 def __init__(self, url, page_set, scroll=False): |
| 101 # forbes.com uses a strange dynamic transform on the body element, | 93 # forbes.com uses a strange dynamic transform on the body element, |
| 102 # which occasionally causes us to try scrolling from outside the | 94 # which occasionally causes us to try scrolling from outside the |
| 103 # screen. Start at the very top of the viewport to avoid this. | 95 # screen. Start at the very top of the viewport to avoid this. |
| 104 super(ForbesAdPage, self).__init__( | 96 super(ForbesAdPage, self).__init__( |
| 105 url=url, page_set=page_set, make_javascript_deterministic=False, | 97 url=url, page_set=page_set, make_javascript_deterministic=False, |
| 106 scroll=scroll, | 98 scroll=scroll, |
| 107 bidirectional_scroll=bidirectional_scroll, | |
| 108 wait_for_interactive_or_better=True) | 99 wait_for_interactive_or_better=True) |
| 109 | 100 |
| 110 def RunNavigateSteps(self, action_runner): | 101 def RunNavigateSteps(self, action_runner): |
| 111 super(ForbesAdPage, self).RunNavigateSteps(action_runner) | 102 super(ForbesAdPage, self).RunNavigateSteps(action_runner) |
| 112 # Wait until the interstitial banner goes away. | 103 # Wait until the interstitial banner goes away. |
| 113 action_runner.WaitForJavaScriptCondition( | 104 action_runner.WaitForJavaScriptCondition( |
| 114 'window.location.pathname.indexOf("welcome") == -1') | 105 'window.location.pathname.indexOf("welcome") == -1') |
| 115 | 106 |
| 116 | 107 |
| 117 class SyntheticToughAdCasesPageSet(story.StorySet): | 108 class SyntheticToughAdCasesPageSet(story.StorySet): |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 'CICAgMDOrcnRGRB4GNgEKAEyCP_ZBSfwUFsj.swf.webglbeta.html', | 161 'CICAgMDOrcnRGRB4GNgEKAEyCP_ZBSfwUFsj.swf.webglbeta.html', |
| 171 ] | 162 ] |
| 172 for page_name in swiffy_pages: | 163 for page_name in swiffy_pages: |
| 173 url = base_url + '/' + page_name | 164 url = base_url + '/' + page_name |
| 174 self.AddStory(SwiffyPage(url, self)) | 165 self.AddStory(SwiffyPage(url, self)) |
| 175 | 166 |
| 176 | 167 |
| 177 class ToughAdCasesPageSet(story.StorySet): | 168 class ToughAdCasesPageSet(story.StorySet): |
| 178 """Pages for measuring performance with advertising content.""" | 169 """Pages for measuring performance with advertising content.""" |
| 179 | 170 |
| 180 def __init__(self, scroll=False, bidirectional_scroll=False): | 171 def __init__(self, scroll=False): |
| 181 super(ToughAdCasesPageSet, self).__init__( | 172 super(ToughAdCasesPageSet, self).__init__( |
| 182 archive_data_file='data/tough_ad_cases.json', | 173 archive_data_file='data/tough_ad_cases.json', |
| 183 cloud_storage_bucket=story.INTERNAL_BUCKET) | 174 cloud_storage_bucket=story.INTERNAL_BUCKET) |
| 184 | 175 |
| 185 self.AddStory(AdPage('file://tough_ad_cases/' | 176 self.AddStory(AdPage('file://tough_ad_cases/' |
| 186 'swiffy_collection.html', self, make_javascript_deterministic=False, | 177 'swiffy_collection.html', self, make_javascript_deterministic=False, |
| 187 y_scroll_distance_multiplier=0.25, scroll=scroll, | 178 y_scroll_distance_multiplier=0.25, scroll=scroll)) |
| 188 bidirectional_scroll=bidirectional_scroll)) | |
| 189 self.AddStory(AdPage('file://tough_ad_cases/' | 179 self.AddStory(AdPage('file://tough_ad_cases/' |
| 190 'swiffy_webgl_collection.html', | 180 'swiffy_webgl_collection.html', |
| 191 self, make_javascript_deterministic=False, scroll=scroll, | 181 self, make_javascript_deterministic=False, scroll=scroll)) |
| 192 bidirectional_scroll=bidirectional_scroll)) | 182 self.AddStory(AdPage('http://www.latimes.com', self, scroll=scroll, |
| 193 self.AddStory(AdPage('http://www.latimes.com', self, | |
| 194 bidirectional_scroll=bidirectional_scroll, scroll=scroll, | |
| 195 wait_for_interactive_or_better=True)) | 183 wait_for_interactive_or_better=True)) |
| 196 self.AddStory(ForbesAdPage('http://www.forbes.com/sites/parmyolson/' | 184 self.AddStory(ForbesAdPage('http://www.forbes.com/sites/parmyolson/' |
| 197 '2015/07/29/jana-mobile-data-facebook-internet-org/', | 185 '2015/07/29/jana-mobile-data-facebook-internet-org/', |
| 198 self, scroll=scroll, bidirectional_scroll=bidirectional_scroll)) | 186 self, scroll=scroll)) |
| 199 self.AddStory(AdPage('http://androidcentral.com', self, scroll=scroll, | 187 self.AddStory(AdPage('http://androidcentral.com', self, scroll=scroll, |
| 200 bidirectional_scroll=bidirectional_scroll, | |
| 201 wait_for_interactive_or_better=True)) | 188 wait_for_interactive_or_better=True)) |
| 202 self.AddStory(AdPage('http://mashable.com', self, scroll=scroll, | 189 self.AddStory(AdPage('http://mashable.com', self, scroll=scroll, |
| 203 y_scroll_distance_multiplier=0.25, | 190 y_scroll_distance_multiplier=0.25)) |
| 204 bidirectional_scroll=bidirectional_scroll)) | |
| 205 self.AddStory(AdPage('http://www.androidauthority.com/' | 191 self.AddStory(AdPage('http://www.androidauthority.com/' |
| 206 'reduce-data-use-turn-on-data-compression-in-chrome-630064/', self, | 192 'reduce-data-use-turn-on-data-compression-in-chrome-630064/', self, |
| 207 scroll=scroll, bidirectional_scroll=bidirectional_scroll)) | 193 scroll=scroll)) |
| 208 self.AddStory(AdPage(('http://www.cnn.com/2015/01/09/politics/' | 194 self.AddStory(AdPage(('http://www.cnn.com/2015/01/09/politics/' |
| 209 'nebraska-keystone-pipeline/index.html'), | 195 'nebraska-keystone-pipeline/index.html'), |
| 210 self, scroll=scroll, | 196 self, scroll=scroll)) |
| 211 bidirectional_scroll=bidirectional_scroll)) | |
| 212 # Disabled: crbug.com/520509 | 197 # Disabled: crbug.com/520509 |
| 213 #self.AddStory(AdPage('http://time.com/3977891/' | 198 #self.AddStory(AdPage('http://time.com/3977891/' |
| 214 # 'donald-trump-debate-republican/', self, scroll=scroll, | 199 # 'donald-trump-debate-republican/', self, scroll=scroll)) |
| 215 # bidirectional_scroll=bidirectional_scroll)) | 200 self.AddStory(AdPage('http://www.theguardian.com/uk', self, scroll=scroll)) |
| 216 self.AddStory(AdPage('http://www.theguardian.com/uk', self, scroll=scroll, | |
| 217 bidirectional_scroll=bidirectional_scroll)) | |
| 218 # Disabled: http://crbug.com/597656 | 201 # Disabled: http://crbug.com/597656 |
| 219 # self.AddStory(AdPage('http://m.tmz.com', self, scroll=scroll, | 202 # self.AddStory(AdPage('http://m.tmz.com', self, scroll=scroll, |
| 220 # y_scroll_distance_multiplier=0.25, | 203 # y_scroll_distance_multiplier=0.25)) |
| 221 # bidirectional_scroll=bidirectional_scroll)) | |
| 222 self.AddStory(AdPage('http://androidpolice.com', self, scroll=scroll, | 204 self.AddStory(AdPage('http://androidpolice.com', self, scroll=scroll, |
| 223 bidirectional_scroll=bidirectional_scroll, | |
| 224 wait_for_interactive_or_better=True)) | 205 wait_for_interactive_or_better=True)) |
| 225 | 206 |
| 226 | 207 |
| 227 class ScrollingToughAdCasesPageSet(ToughAdCasesPageSet): | 208 class ScrollingToughAdCasesPageSet(ToughAdCasesPageSet): |
| 228 """Pages for measuring scrolling performance with advertising content.""" | 209 """Pages for measuring scrolling performance with advertising content.""" |
| 229 | 210 |
| 230 def __init__(self): | 211 def __init__(self): |
| 231 super(ScrollingToughAdCasesPageSet, self).__init__( | 212 super(ScrollingToughAdCasesPageSet, self).__init__( |
| 232 scroll=True) | 213 scroll=True) |
| 233 | |
| 234 | |
| 235 class BidirectionallyScrollingToughAdCasesPageSet(ToughAdCasesPageSet): | |
| 236 """Same as ScrollingToughAdCasesPageSet except we scroll in two directions.""" | |
| 237 | |
| 238 def __init__(self): | |
| 239 super(BidirectionallyScrollingToughAdCasesPageSet, self).__init__( | |
| 240 bidirectional_scroll=True) | |
| OLD | NEW |