Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: tools/perf/page_sets/tough_ad_cases.py

Issue 2719853003: [Telemetry refactor] Drop "2" from method calls to JS API (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/perf/page_sets/top_pages.py ('k') | tools/perf/page_sets/tough_animation_cases.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17
18 def RunNavigateSteps(self, action_runner): 18 def RunNavigateSteps(self, action_runner):
19 super(SwiffyPage, self).RunNavigateSteps(action_runner) 19 super(SwiffyPage, self).RunNavigateSteps(action_runner)
20 # Make sure the ad has finished loading. 20 # Make sure the ad has finished loading.
21 util.WaitFor(action_runner.tab.HasReachedQuiescence, 60) 21 util.WaitFor(action_runner.tab.HasReachedQuiescence, 60)
22 # Swiffy overwrites toString() to return a constant string, so "undo" that 22 # 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. 23 # here so that we don't think it has stomped over console.time.
24 action_runner.EvaluateJavaScript2( 24 action_runner.EvaluateJavaScript(
25 'Function.prototype.toString = function() { return "[native code]"; }') 25 'Function.prototype.toString = function() { return "[native code]"; }')
26 # Make sure we have a reasonable viewport for mobile. 26 # Make sure we have a reasonable viewport for mobile.
27 action_runner.EvaluateJavaScript2(""" 27 action_runner.EvaluateJavaScript("""
28 var meta = document.createElement("meta"); 28 var meta = document.createElement("meta");
29 meta.name = "viewport"; 29 meta.name = "viewport";
30 meta.content = "width=device-width"; 30 meta.content = "width=device-width";
31 document.getElementsByTagName("head")[0].appendChild(meta); 31 document.getElementsByTagName("head")[0].appendChild(meta);
32 """) 32 """)
33 33
34 def RunPageInteractions(self, action_runner): 34 def RunPageInteractions(self, action_runner):
35 with action_runner.CreateInteraction('ToughAd'): 35 with action_runner.CreateInteraction('ToughAd'):
36 action_runner.Wait(10) 36 action_runner.Wait(10)
37 37
(...skipping 23 matching lines...) Expand all
61 url[len('file://'):]) 61 url[len('file://'):])
62 else: 62 else:
63 url = self._url 63 url = self._url
64 action_runner.tab.Navigate(url) 64 action_runner.tab.Navigate(url)
65 65
66 # Wait for the page to be scrollable. Simultaneously (to reduce latency due 66 # Wait for the page to be scrollable. Simultaneously (to reduce latency due
67 # to main thread round trips), insert a no-op touch handler on the body. 67 # to main thread round trips), insert a no-op touch handler on the body.
68 # Most ads have touch handlers and we want to simulate the worst case of the 68 # Most ads have touch handlers and we want to simulate the worst case of the
69 # user trying to scroll the page by grabbing an ad. 69 # user trying to scroll the page by grabbing an ad.
70 if self._wait_for_interactive_or_better: 70 if self._wait_for_interactive_or_better:
71 action_runner.WaitForJavaScriptCondition2( 71 action_runner.WaitForJavaScriptCondition(
72 '(document.readyState == "interactive" || ' 72 '(document.readyState == "interactive" || '
73 'document.readyState == "complete") &&' 73 'document.readyState == "complete") &&'
74 'document.body != null && ' 74 'document.body != null && '
75 'document.body.scrollHeight > window.innerHeight && ' 75 'document.body.scrollHeight > window.innerHeight && '
76 '!document.body.addEventListener("touchstart", function() {})') 76 '!document.body.addEventListener("touchstart", function() {})')
77 else: 77 else:
78 action_runner.WaitForJavaScriptCondition2( 78 action_runner.WaitForJavaScriptCondition(
79 'document.body != null && ' 79 'document.body != null && '
80 'document.body.scrollHeight > window.innerHeight && ' 80 'document.body.scrollHeight > window.innerHeight && '
81 '!document.body.addEventListener("touchstart", function() {})') 81 '!document.body.addEventListener("touchstart", function() {})')
82 82
83 def RunPageInteractions(self, action_runner): 83 def RunPageInteractions(self, action_runner):
84 if not self._scroll: 84 if not self._scroll:
85 with action_runner.CreateInteraction('ToughAd'): 85 with action_runner.CreateInteraction('ToughAd'):
86 action_runner.Wait(30) 86 action_runner.Wait(30)
87 else: 87 else:
88 action_runner.RepeatableBrowserDrivenScroll( 88 action_runner.RepeatableBrowserDrivenScroll(
89 y_scroll_distance_ratio=self._y_scroll_distance_multiplier, 89 y_scroll_distance_ratio=self._y_scroll_distance_multiplier,
90 repeat_count=9) 90 repeat_count=9)
91 91
92 92
93 class ForbesAdPage(AdPage): 93 class ForbesAdPage(AdPage):
94 94
95 def __init__(self, url, page_set, scroll=False): 95 def __init__(self, url, page_set, scroll=False):
96 # forbes.com uses a strange dynamic transform on the body element, 96 # forbes.com uses a strange dynamic transform on the body element,
97 # which occasionally causes us to try scrolling from outside the 97 # which occasionally causes us to try scrolling from outside the
98 # screen. Start at the very top of the viewport to avoid this. 98 # screen. Start at the very top of the viewport to avoid this.
99 super(ForbesAdPage, self).__init__( 99 super(ForbesAdPage, self).__init__(
100 url=url, page_set=page_set, make_javascript_deterministic=False, 100 url=url, page_set=page_set, make_javascript_deterministic=False,
101 scroll=scroll, 101 scroll=scroll,
102 wait_for_interactive_or_better=True) 102 wait_for_interactive_or_better=True)
103 103
104 def RunNavigateSteps(self, action_runner): 104 def RunNavigateSteps(self, action_runner):
105 super(ForbesAdPage, self).RunNavigateSteps(action_runner) 105 super(ForbesAdPage, self).RunNavigateSteps(action_runner)
106 # Wait until the interstitial banner goes away. 106 # Wait until the interstitial banner goes away.
107 action_runner.WaitForJavaScriptCondition2( 107 action_runner.WaitForJavaScriptCondition(
108 'window.location.pathname.indexOf("welcome") == -1') 108 'window.location.pathname.indexOf("welcome") == -1')
109 109
110 110
111 class SyntheticToughAdCasesPageSet(story.StorySet): 111 class SyntheticToughAdCasesPageSet(story.StorySet):
112 """Pages for measuring rendering performance with advertising content.""" 112 """Pages for measuring rendering performance with advertising content."""
113 113
114 def __init__(self): 114 def __init__(self):
115 super(SyntheticToughAdCasesPageSet, self).__init__( 115 super(SyntheticToughAdCasesPageSet, self).__init__(
116 archive_data_file='data/tough_ad_cases.json', 116 archive_data_file='data/tough_ad_cases.json',
117 cloud_storage_bucket=story.INTERNAL_BUCKET) 117 cloud_storage_bucket=story.INTERNAL_BUCKET)
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 self.AddStory(AdPage('http://androidpolice.com', self, scroll=scroll, 207 self.AddStory(AdPage('http://androidpolice.com', self, scroll=scroll,
208 wait_for_interactive_or_better=True)) 208 wait_for_interactive_or_better=True))
209 209
210 210
211 class ScrollingToughAdCasesPageSet(ToughAdCasesPageSet): 211 class ScrollingToughAdCasesPageSet(ToughAdCasesPageSet):
212 """Pages for measuring scrolling performance with advertising content.""" 212 """Pages for measuring scrolling performance with advertising content."""
213 213
214 def __init__(self): 214 def __init__(self):
215 super(ScrollingToughAdCasesPageSet, self).__init__( 215 super(ScrollingToughAdCasesPageSet, self).__init__(
216 scroll=True) 216 scroll=True)
OLDNEW
« no previous file with comments | « tools/perf/page_sets/top_pages.py ('k') | tools/perf/page_sets/tough_animation_cases.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698