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"));' | |
30 'document.getElementsByTagName("head")[0].appendChild(meta);') | 28 'document.getElementsByTagName("head")[0].appendChild(meta);') |
31 action_runner.EvaluateJavaScript(viewport_js) | 29 action_runner.EvaluateJavaScript(viewport_js) |
32 | 30 |
33 def RunPageInteractions(self, action_runner): | 31 def RunPageInteractions(self, action_runner): |
34 with action_runner.CreateInteraction('ToughAd'): | 32 with action_runner.CreateInteraction('ToughAd'): |
35 action_runner.Wait(10) | 33 action_runner.Wait(10) |
36 | 34 |
37 | 35 |
38 class AdPage(page_module.Page): | 36 class AdPage(page_module.Page): |
39 | 37 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 self.AddStory(AdPage('http://androidpolice.com', self, scroll=scroll, | 204 self.AddStory(AdPage('http://androidpolice.com', self, scroll=scroll, |
207 wait_for_interactive_or_better=True)) | 205 wait_for_interactive_or_better=True)) |
208 | 206 |
209 | 207 |
210 class ScrollingToughAdCasesPageSet(ToughAdCasesPageSet): | 208 class ScrollingToughAdCasesPageSet(ToughAdCasesPageSet): |
211 """Pages for measuring scrolling performance with advertising content.""" | 209 """Pages for measuring scrolling performance with advertising content.""" |
212 | 210 |
213 def __init__(self): | 211 def __init__(self): |
214 super(ScrollingToughAdCasesPageSet, self).__init__( | 212 super(ScrollingToughAdCasesPageSet, self).__init__( |
215 scroll=True) | 213 scroll=True) |
OLD | NEW |