| 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 |
| 11 class SwiffyPage(page_module.Page): | 11 class SwiffyPage(page_module.Page): |
| 12 | 12 |
| 13 def __init__(self, url, page_set): | 13 def __init__(self, url, page_set): |
| 14 super(SwiffyPage, self).__init__(url=url, page_set=page_set, | 14 super(SwiffyPage, self).__init__(url=url, page_set=page_set, |
| 15 make_javascript_deterministic=False) | 15 make_javascript_deterministic=False) |
| 16 | 16 |
| 17 def RunNavigateSteps(self, action_runner): | 17 def RunNavigateSteps(self, action_runner): |
| 18 super(SwiffyPage, self).RunNavigateSteps(action_runner) | 18 super(SwiffyPage, self).RunNavigateSteps(action_runner) |
| 19 # Swiffy overwrites toString() to return a constant string, so "undo" that | 19 # Swiffy overwrites toString() to return a constant string, so "undo" that |
| 20 # here so that we don't think it has stomped over console.time. | 20 # here so that we don't think it has stomped over console.time. |
| 21 action_runner.EvaluateJavaScript( | 21 action_runner.EvaluateJavaScript( |
| 22 'Function.prototype.toString = function() { return "[native code]"; }') | 22 'Function.prototype.toString = function() { return "[native code]"; }') |
| 23 # Make sure we have a reasonable viewport for mobile. | 23 # Make sure we have a reasonable viewport for mobile. |
| 24 viewport_js = ( | 24 viewport_js = ( |
| 25 'var meta = document.createElement("meta");' | 25 'var meta = document.createElement("meta");' |
| 26 'meta.name = "viewport";' | 26 'meta.name = "viewport";' |
| 27 'meta.content = "width=device-width";' | 27 'meta.content = "width=device-width";' |
| 28 'if (!document.getElementsByTagName("head"))' |
| 29 ' document.body.appendChild(document.createElement("head"));' |
| 28 'document.getElementsByTagName("head")[0].appendChild(meta);') | 30 'document.getElementsByTagName("head")[0].appendChild(meta);') |
| 29 action_runner.EvaluateJavaScript(viewport_js) | 31 action_runner.EvaluateJavaScript(viewport_js) |
| 30 | 32 |
| 31 def RunPageInteractions(self, action_runner): | 33 def RunPageInteractions(self, action_runner): |
| 32 with action_runner.CreateInteraction('ToughAd'): | 34 with action_runner.CreateInteraction('ToughAd'): |
| 33 action_runner.Wait(10) | 35 action_runner.Wait(10) |
| 34 | 36 |
| 35 | 37 |
| 36 class AdPage(page_module.Page): | 38 class AdPage(page_module.Page): |
| 37 | 39 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 self.AddStory(AdPage('http://androidpolice.com', self, scroll=scroll, | 206 self.AddStory(AdPage('http://androidpolice.com', self, scroll=scroll, |
| 205 wait_for_interactive_or_better=True)) | 207 wait_for_interactive_or_better=True)) |
| 206 | 208 |
| 207 | 209 |
| 208 class ScrollingToughAdCasesPageSet(ToughAdCasesPageSet): | 210 class ScrollingToughAdCasesPageSet(ToughAdCasesPageSet): |
| 209 """Pages for measuring scrolling performance with advertising content.""" | 211 """Pages for measuring scrolling performance with advertising content.""" |
| 210 | 212 |
| 211 def __init__(self): | 213 def __init__(self): |
| 212 super(ScrollingToughAdCasesPageSet, self).__init__( | 214 super(ScrollingToughAdCasesPageSet, self).__init__( |
| 213 scroll=True) | 215 scroll=True) |
| OLD | NEW |