| 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.core import util | 7 from telemetry.core import util |
| 8 from telemetry.page import page as page_module | 8 from telemetry.page import page as page_module |
| 9 from telemetry import story | 9 from telemetry import story |
| 10 | 10 |
| 11 | 11 |
| 12 class SwiffyPage(page_module.Page): | 12 class SwiffyPage(page_module.Page): |
| 13 | 13 |
| 14 def __init__(self, url, page_set): | 14 def __init__(self, url, page_set): |
| 15 super(SwiffyPage, self).__init__(url=url, page_set=page_set, | 15 super(SwiffyPage, self).__init__(url=url, page_set=page_set, |
| 16 make_javascript_deterministic=False) | 16 make_javascript_deterministic=False, |
| 17 name=url) |
| 17 | 18 |
| 18 def RunNavigateSteps(self, action_runner): | 19 def RunNavigateSteps(self, action_runner): |
| 19 super(SwiffyPage, self).RunNavigateSteps(action_runner) | 20 super(SwiffyPage, self).RunNavigateSteps(action_runner) |
| 20 # Make sure the ad has finished loading. | 21 # Make sure the ad has finished loading. |
| 21 util.WaitFor(action_runner.tab.HasReachedQuiescence, 60) | 22 util.WaitFor(action_runner.tab.HasReachedQuiescence, 60) |
| 22 # Swiffy overwrites toString() to return a constant string, so "undo" that | 23 # Swiffy overwrites toString() to return a constant string, so "undo" that |
| 23 # here so that we don't think it has stomped over console.time. | 24 # here so that we don't think it has stomped over console.time. |
| 24 action_runner.EvaluateJavaScript( | 25 action_runner.EvaluateJavaScript( |
| 25 'Function.prototype.toString = function() { return "[native code]"; }') | 26 'Function.prototype.toString = function() { return "[native code]"; }') |
| 26 # Make sure we have a reasonable viewport for mobile. | 27 # Make sure we have a reasonable viewport for mobile. |
| 27 action_runner.EvaluateJavaScript(""" | 28 action_runner.EvaluateJavaScript(""" |
| 28 var meta = document.createElement("meta"); | 29 var meta = document.createElement("meta"); |
| 29 meta.name = "viewport"; | 30 meta.name = "viewport"; |
| 30 meta.content = "width=device-width"; | 31 meta.content = "width=device-width"; |
| 31 document.getElementsByTagName("head")[0].appendChild(meta); | 32 document.getElementsByTagName("head")[0].appendChild(meta); |
| 32 """) | 33 """) |
| 33 | 34 |
| 34 def RunPageInteractions(self, action_runner): | 35 def RunPageInteractions(self, action_runner): |
| 35 with action_runner.CreateInteraction('ToughAd'): | 36 with action_runner.CreateInteraction('ToughAd'): |
| 36 action_runner.Wait(10) | 37 action_runner.Wait(10) |
| 37 | 38 |
| 38 | 39 |
| 39 class AdPage(page_module.Page): | 40 class AdPage(page_module.Page): |
| 40 | 41 |
| 41 def __init__(self, url, page_set, make_javascript_deterministic=True, | 42 def __init__(self, url, page_set, make_javascript_deterministic=True, |
| 42 y_scroll_distance_multiplier=0.5, | 43 y_scroll_distance_multiplier=0.5, |
| 43 scroll=False, | 44 scroll=False, |
| 44 wait_for_interactive_or_better=False): | 45 wait_for_interactive_or_better=False): |
| 46 name = url |
| 47 if not name.startswith('http'): |
| 48 name = url.split('/')[-1] |
| 45 super(AdPage, self).__init__( | 49 super(AdPage, self).__init__( |
| 46 url=url, | 50 url=url, |
| 47 page_set=page_set, | 51 page_set=page_set, |
| 48 make_javascript_deterministic=make_javascript_deterministic, | 52 make_javascript_deterministic=make_javascript_deterministic, |
| 49 shared_page_state_class=( | 53 shared_page_state_class=( |
| 50 repeatable_synthesize_scroll_gesture_shared_state.\ | 54 repeatable_synthesize_scroll_gesture_shared_state.\ |
| 51 RepeatableSynthesizeScrollGestureSharedState)) | 55 RepeatableSynthesizeScrollGestureSharedState), |
| 56 name=name) |
| 52 self._y_scroll_distance_multiplier = y_scroll_distance_multiplier | 57 self._y_scroll_distance_multiplier = y_scroll_distance_multiplier |
| 53 self._scroll = scroll | 58 self._scroll = scroll |
| 54 self._wait_for_interactive_or_better = wait_for_interactive_or_better | 59 self._wait_for_interactive_or_better = wait_for_interactive_or_better |
| 55 | 60 |
| 56 def RunNavigateSteps(self, action_runner): | 61 def RunNavigateSteps(self, action_runner): |
| 57 # Rewrite file urls to point to the replay server instead. | 62 # Rewrite file urls to point to the replay server instead. |
| 58 if self.is_file: | 63 if self.is_file: |
| 59 url = self.file_path_url_with_scheme | 64 url = self.file_path_url_with_scheme |
| 60 url = action_runner.tab.browser.platform.http_server.UrlOf( | 65 url = action_runner.tab.browser.platform.http_server.UrlOf( |
| 61 url[len('file://'):]) | 66 url[len('file://'):]) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 action_runner.WaitForJavaScriptCondition( | 112 action_runner.WaitForJavaScriptCondition( |
| 108 'window.location.pathname.indexOf("welcome") == -1') | 113 'window.location.pathname.indexOf("welcome") == -1') |
| 109 | 114 |
| 110 | 115 |
| 111 class SyntheticToughAdCasesPageSet(story.StorySet): | 116 class SyntheticToughAdCasesPageSet(story.StorySet): |
| 112 """Pages for measuring rendering performance with advertising content.""" | 117 """Pages for measuring rendering performance with advertising content.""" |
| 113 | 118 |
| 114 def __init__(self): | 119 def __init__(self): |
| 115 super(SyntheticToughAdCasesPageSet, self).__init__( | 120 super(SyntheticToughAdCasesPageSet, self).__init__( |
| 116 archive_data_file='data/tough_ad_cases.json', | 121 archive_data_file='data/tough_ad_cases.json', |
| 117 cloud_storage_bucket=story.INTERNAL_BUCKET) | 122 cloud_storage_bucket=story.INTERNAL_BUCKET, |
| 123 verify_names=True) |
| 118 | 124 |
| 119 base_url = 'http://localhost:8000' | 125 base_url = 'http://localhost:8000' |
| 120 | 126 |
| 121 # See go/swiffy-chrome-samples for how to add new pages here or how to | 127 # See go/swiffy-chrome-samples for how to add new pages here or how to |
| 122 # update the existing ones. | 128 # update the existing ones. |
| 123 swiffy_pages = [ | 129 swiffy_pages = [ |
| 124 'CICAgICQ15a9NxDIARjIASgBMghBC1XuTk8ezw.swiffy72.html', | 130 'CICAgICQ15a9NxDIARjIASgBMghBC1XuTk8ezw.swiffy72.html', |
| 125 'shapes-CK7ptO3F8bi2KxDQAhiYAigBMgij6QBQtD2gyA.swiffy72.html', | 131 'shapes-CK7ptO3F8bi2KxDQAhiYAigBMgij6QBQtD2gyA.swiffy72.html', |
| 126 'CNP2xe_LmqPEKBCsAhj6ASgBMggnyMqth81h8Q.swiffy72.html', | 132 'CNP2xe_LmqPEKBCsAhj6ASgBMggnyMqth81h8Q.swiffy72.html', |
| 127 'clip-paths-CICAgMDO7Ye9-gEQ2AUYWigBMgjZxDii6aoK9w.swiffy72.html', | 133 'clip-paths-CICAgMDO7Ye9-gEQ2AUYWigBMgjZxDii6aoK9w.swiffy72.html', |
| 128 'filters-CNLa0t2T47qJ_wEQoAEY2AQoATIIFaIdc7VMBr4.swiffy72.html', | 134 'filters-CNLa0t2T47qJ_wEQoAEY2AQoATIIFaIdc7VMBr4.swiffy72.html', |
| 129 'shapes-CICAgMDO7cfIzwEQ1AMYPCgBMghqY8tqyRCArQ.swiffy72.html', | 135 'shapes-CICAgMDO7cfIzwEQ1AMYPCgBMghqY8tqyRCArQ.swiffy72.html', |
| 130 'CICAgIDQ2Pb-MxCsAhj6ASgBMgi5DLoSO0gPbQ.swiffy72.html', | 136 'CICAgIDQ2Pb-MxCsAhj6ASgBMgi5DLoSO0gPbQ.swiffy72.html', |
| 131 'CICAgKCN39CopQEQoAEY2AQoATIID59gK5hjjIg.swiffy72.html', | 137 'CICAgKCN39CopQEQoAEY2AQoATIID59gK5hjjIg.swiffy72.html', |
| 132 'CICAgKCNj4HgyAEQeBjYBCgBMgjQpPkOjyWNdw.1.swiffy72.html', | 138 'CICAgKCNj4HgyAEQeBjYBCgBMgjQpPkOjyWNdw.1.swiffy72.html', |
| 133 'clip-paths-CILZhLqO_-27bxB4GNgEKAEyCC46kMLBXnMT.swiffy72.html', | 139 'clip-paths-CILZhLqO_-27bxB4GNgEKAEyCC46kMLBXnMT.swiffy72.html', |
| 134 'CICAgMDOrcnRGRB4GNgEKAEyCP_ZBSfwUFsj.swiffy72.html', | 140 'CICAgMDOrcnRGRB4GNgEKAEyCP_ZBSfwUFsj.swiffy72.html', |
| 135 ] | 141 ] |
| 136 for page_name in swiffy_pages: | 142 for page_name in swiffy_pages: |
| 137 url = base_url + '/' + page_name | 143 url = base_url + '/' + page_name |
| 138 self.AddStory(SwiffyPage(url, self)) | 144 self.AddStory(SwiffyPage(url, self)) |
| 139 | 145 |
| 140 | 146 |
| 141 class SyntheticToughWebglAdCasesPageSet(story.StorySet): | 147 class SyntheticToughWebglAdCasesPageSet(story.StorySet): |
| 142 """Pages for measuring rendering performance with WebGL ad content.""" | 148 """Pages for measuring rendering performance with WebGL ad content.""" |
| 143 | 149 |
| 144 def __init__(self): | 150 def __init__(self): |
| 145 super(SyntheticToughWebglAdCasesPageSet, self).__init__( | 151 super(SyntheticToughWebglAdCasesPageSet, self).__init__( |
| 146 archive_data_file='data/tough_ad_cases.json', | 152 archive_data_file='data/tough_ad_cases.json', |
| 147 cloud_storage_bucket=story.INTERNAL_BUCKET) | 153 cloud_storage_bucket=story.INTERNAL_BUCKET, |
| 154 verify_names=True) |
| 148 | 155 |
| 149 base_url = 'http://localhost:8000' | 156 base_url = 'http://localhost:8000' |
| 150 | 157 |
| 151 # See go/swiffy-chrome-samples for how to add new pages here or how to | 158 # See go/swiffy-chrome-samples for how to add new pages here or how to |
| 152 # update the existing ones. | 159 # update the existing ones. |
| 153 swiffy_pages = [ | 160 swiffy_pages = [ |
| 154 'CICAgICQ15a9NxDIARjIASgBMghBC1XuTk8ezw.swf.webglbeta.html', | 161 'CICAgICQ15a9NxDIARjIASgBMghBC1XuTk8ezw.swf.webglbeta.html', |
| 155 'shapes-CK7ptO3F8bi2KxDQAhiYAigBMgij6QBQtD2gyA.swf.webglbeta.html', | 162 'shapes-CK7ptO3F8bi2KxDQAhiYAigBMgij6QBQtD2gyA.swf.webglbeta.html', |
| 156 'CNP2xe_LmqPEKBCsAhj6ASgBMggnyMqth81h8Q.swf.webglbeta.html', | 163 'CNP2xe_LmqPEKBCsAhj6ASgBMggnyMqth81h8Q.swf.webglbeta.html', |
| 157 'clip-paths-CICAgMDO7Ye9-gEQ2AUYWigBMgjZxDii6aoK9w.swf.webglbeta.html', | 164 'clip-paths-CICAgMDO7Ye9-gEQ2AUYWigBMgjZxDii6aoK9w.swf.webglbeta.html', |
| 158 'filters-CNLa0t2T47qJ_wEQoAEY2AQoATIIFaIdc7VMBr4.swf.webglbeta.html', | 165 'filters-CNLa0t2T47qJ_wEQoAEY2AQoATIIFaIdc7VMBr4.swf.webglbeta.html', |
| 159 'shapes-CICAgMDO7cfIzwEQ1AMYPCgBMghqY8tqyRCArQ.swf.webglbeta.html', | 166 'shapes-CICAgMDO7cfIzwEQ1AMYPCgBMghqY8tqyRCArQ.swf.webglbeta.html', |
| 160 'CICAgIDQ2Pb-MxCsAhj6ASgBMgi5DLoSO0gPbQ.swf.webglbeta.html', | 167 'CICAgIDQ2Pb-MxCsAhj6ASgBMgi5DLoSO0gPbQ.swf.webglbeta.html', |
| 161 'CICAgKCN39CopQEQoAEY2AQoATIID59gK5hjjIg.swf.webglbeta.html', | 168 'CICAgKCN39CopQEQoAEY2AQoATIID59gK5hjjIg.swf.webglbeta.html', |
| 162 'CICAgKCNj4HgyAEQeBjYBCgBMgjQpPkOjyWNdw.1.swf.webglbeta.html', | 169 'CICAgKCNj4HgyAEQeBjYBCgBMgjQpPkOjyWNdw.1.swf.webglbeta.html', |
| 163 'clip-paths-CILZhLqO_-27bxB4GNgEKAEyCC46kMLBXnMT.swf.webglbeta.html', | 170 'clip-paths-CILZhLqO_-27bxB4GNgEKAEyCC46kMLBXnMT.swf.webglbeta.html', |
| 164 'CICAgMDOrcnRGRB4GNgEKAEyCP_ZBSfwUFsj.swf.webglbeta.html', | 171 'CICAgMDOrcnRGRB4GNgEKAEyCP_ZBSfwUFsj.swf.webglbeta.html', |
| 165 ] | 172 ] |
| 166 for page_name in swiffy_pages: | 173 for page_name in swiffy_pages: |
| 167 url = base_url + '/' + page_name | 174 url = base_url + '/' + page_name |
| 168 self.AddStory(SwiffyPage(url, self)) | 175 self.AddStory(SwiffyPage(url, self)) |
| 169 | 176 |
| 170 | 177 |
| 171 class ToughAdCasesPageSet(story.StorySet): | 178 class ToughAdCasesPageSet(story.StorySet): |
| 172 """Pages for measuring performance with advertising content.""" | 179 """Pages for measuring performance with advertising content.""" |
| 173 | 180 |
| 174 def __init__(self, scroll=False): | 181 def __init__(self, scroll=False): |
| 175 super(ToughAdCasesPageSet, self).__init__( | 182 super(ToughAdCasesPageSet, self).__init__( |
| 176 archive_data_file='data/tough_ad_cases.json', | 183 archive_data_file='data/tough_ad_cases.json', |
| 177 cloud_storage_bucket=story.INTERNAL_BUCKET) | 184 cloud_storage_bucket=story.INTERNAL_BUCKET, |
| 185 verify_names=True) |
| 178 | 186 |
| 179 self.AddStory(AdPage('file://tough_ad_cases/' | 187 self.AddStory(AdPage('file://tough_ad_cases/' |
| 180 'swiffy_collection.html', self, make_javascript_deterministic=False, | 188 'swiffy_collection.html', self, make_javascript_deterministic=False, |
| 181 y_scroll_distance_multiplier=0.25, scroll=scroll)) | 189 y_scroll_distance_multiplier=0.25, scroll=scroll)) |
| 182 self.AddStory(AdPage('file://tough_ad_cases/' | 190 self.AddStory(AdPage('file://tough_ad_cases/' |
| 183 'swiffy_webgl_collection.html', | 191 'swiffy_webgl_collection.html', |
| 184 self, make_javascript_deterministic=False, scroll=scroll)) | 192 self, make_javascript_deterministic=False, scroll=scroll)) |
| 185 self.AddStory(AdPage('http://www.latimes.com', self, scroll=scroll, | 193 self.AddStory(AdPage('http://www.latimes.com', self, scroll=scroll, |
| 186 wait_for_interactive_or_better=True)) | 194 wait_for_interactive_or_better=True)) |
| 187 self.AddStory(ForbesAdPage('http://www.forbes.com/sites/parmyolson/' | 195 self.AddStory(ForbesAdPage('http://www.forbes.com/sites/parmyolson/' |
| (...skipping 19 matching lines...) Expand all Loading... |
| 207 self.AddStory(AdPage('http://androidpolice.com', self, scroll=scroll, | 215 self.AddStory(AdPage('http://androidpolice.com', self, scroll=scroll, |
| 208 wait_for_interactive_or_better=True)) | 216 wait_for_interactive_or_better=True)) |
| 209 | 217 |
| 210 | 218 |
| 211 class ScrollingToughAdCasesPageSet(ToughAdCasesPageSet): | 219 class ScrollingToughAdCasesPageSet(ToughAdCasesPageSet): |
| 212 """Pages for measuring scrolling performance with advertising content.""" | 220 """Pages for measuring scrolling performance with advertising content.""" |
| 213 | 221 |
| 214 def __init__(self): | 222 def __init__(self): |
| 215 super(ScrollingToughAdCasesPageSet, self).__init__( | 223 super(ScrollingToughAdCasesPageSet, self).__init__( |
| 216 scroll=True) | 224 scroll=True) |
| OLD | NEW |