exclude PluginsFieldTrialTest.NoPrefLeftBehind from valgrind bot
[chromium-blink-merge.git] / tools / perf / page_sets / tough_ad_cases.py
bloba944397d25fc9da099ba5f2ad84acfaf0588a7cb
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
3 # found in the LICENSE file.
5 from page_sets import repeatable_synthesize_scroll_gesture_shared_state
7 from telemetry.page import page as page_module
8 from telemetry import story
11 class SwiffyPage(page_module.Page):
13 def __init__(self, url, page_set):
14 super(SwiffyPage, self).__init__(url=url, page_set=page_set,
15 make_javascript_deterministic=False)
17 def RunNavigateSteps(self, action_runner):
18 super(SwiffyPage, self).RunNavigateSteps(action_runner)
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.
21 action_runner.EvaluateJavaScript(
22 'Function.prototype.toString = function() { return "[native code]"; }')
23 # Make sure we have a reasonable viewport for mobile.
24 viewport_js = (
25 'var meta = document.createElement("meta");'
26 'meta.name = "viewport";'
27 'meta.content = "width=device-width";'
28 'document.getElementsByTagName("head")[0].appendChild(meta);')
29 action_runner.EvaluateJavaScript(viewport_js)
31 def RunPageInteractions(self, action_runner):
32 with action_runner.CreateInteraction('ToughAd'):
33 action_runner.Wait(10)
36 class ScrollingPage(page_module.Page):
38 def __init__(self, url, page_set, make_javascript_deterministic=True,
39 y_scroll_distance_multiplier=0.5):
40 super(ScrollingPage, self).__init__(
41 url=url,
42 page_set=page_set,
43 make_javascript_deterministic=make_javascript_deterministic,
44 shared_page_state_class=(
45 repeatable_synthesize_scroll_gesture_shared_state.\
46 RepeatableSynthesizeScrollGestureSharedState))
47 self._y_scroll_distance_multiplier = y_scroll_distance_multiplier
49 def RunNavigateSteps(self, action_runner):
50 # Rewrite file urls to point to the replay server instead.
51 if self.is_file:
52 url = self.file_path_url_with_scheme
53 url = action_runner.tab.browser.http_server.UrlOf(url[len('file://'):])
54 else:
55 url = self._url
56 action_runner.tab.Navigate(url)
58 # Wait for the page to be scrollable. Simultaneously (to reduce latency due
59 # to main thread round trips), insert a no-op touch handler on the body.
60 # Most ads have touch handlers and we want to simulate the worst case of the
61 # user trying to scroll the page by grabbing an ad.
62 action_runner.WaitForJavaScriptCondition(
63 'document.body != null && '
64 'document.body.scrollHeight > window.innerHeight && '
65 '!document.body.addEventListener("touchstart", function() {})')
67 def RunPageInteractions(self, action_runner):
68 action_runner.RepeatableBrowserDrivenScroll(
69 y_scroll_distance_ratio=self._y_scroll_distance_multiplier,
70 repeat_count=9)
73 class ScrollingForbesPage(ScrollingPage):
75 def __init__(self, url, page_set):
76 # forbes.com uses a strange dynamic transform on the body element,
77 # which occasionally causes us to try scrolling from outside the
78 # screen. Start at the very top of the viewport to avoid this.
79 super(ScrollingForbesPage, self).__init__(
80 url=url, page_set=page_set, make_javascript_deterministic=False)
82 def RunNavigateSteps(self, action_runner):
83 super(ScrollingForbesPage, self).RunNavigateSteps(action_runner)
84 # Wait until the interstitial banner goes away.
85 action_runner.WaitForJavaScriptCondition(
86 'window.location.pathname.indexOf("welcome") == -1')
89 class ToughAdCasesPageSet(story.StorySet):
90 """Pages for measuring rendering performance with advertising content."""
92 def __init__(self):
93 super(ToughAdCasesPageSet, self).__init__(
94 archive_data_file='data/tough_ad_cases.json',
95 cloud_storage_bucket=story.INTERNAL_BUCKET)
97 base_url = 'http://localhost:8000'
99 # See go/swiffy-chrome-samples for how to add new pages here or how to
100 # update the existing ones.
101 swiffy_pages = [
102 'CICAgICQ15a9NxDIARjIASgBMghBC1XuTk8ezw.swiffy72.html',
103 'shapes-CK7ptO3F8bi2KxDQAhiYAigBMgij6QBQtD2gyA.swiffy72.html',
104 'CNP2xe_LmqPEKBCsAhj6ASgBMggnyMqth81h8Q.swiffy72.html',
105 'clip-paths-CICAgMDO7Ye9-gEQ2AUYWigBMgjZxDii6aoK9w.swiffy72.html',
106 'filters-CNLa0t2T47qJ_wEQoAEY2AQoATIIFaIdc7VMBr4.swiffy72.html',
107 'shapes-CICAgMDO7cfIzwEQ1AMYPCgBMghqY8tqyRCArQ.swiffy72.html',
108 'CICAgIDQ2Pb-MxCsAhj6ASgBMgi5DLoSO0gPbQ.swiffy72.html',
109 'CICAgKCN39CopQEQoAEY2AQoATIID59gK5hjjIg.swiffy72.html',
110 'CICAgKCNj4HgyAEQeBjYBCgBMgjQpPkOjyWNdw.1.swiffy72.html',
111 'clip-paths-CILZhLqO_-27bxB4GNgEKAEyCC46kMLBXnMT.swiffy72.html',
112 'CICAgMDOrcnRGRB4GNgEKAEyCP_ZBSfwUFsj.swiffy72.html',
114 for page_name in swiffy_pages:
115 url = base_url + '/' + page_name
116 self.AddStory(SwiffyPage(url, self))
119 class ToughWebglAdCasesPageSet(story.StorySet):
120 """Pages for measuring rendering performance with WebGL ad content."""
122 def __init__(self):
123 super(ToughWebglAdCasesPageSet, self).__init__(
124 archive_data_file='data/tough_ad_cases.json',
125 cloud_storage_bucket=story.INTERNAL_BUCKET)
127 base_url = 'http://localhost:8000'
129 # See go/swiffy-chrome-samples for how to add new pages here or how to
130 # update the existing ones.
131 swiffy_pages = [
132 'CICAgICQ15a9NxDIARjIASgBMghBC1XuTk8ezw.swf.webglbeta.html',
133 'shapes-CK7ptO3F8bi2KxDQAhiYAigBMgij6QBQtD2gyA.swf.webglbeta.html',
134 'CNP2xe_LmqPEKBCsAhj6ASgBMggnyMqth81h8Q.swf.webglbeta.html',
135 'clip-paths-CICAgMDO7Ye9-gEQ2AUYWigBMgjZxDii6aoK9w.swf.webglbeta.html',
136 'filters-CNLa0t2T47qJ_wEQoAEY2AQoATIIFaIdc7VMBr4.swf.webglbeta.html',
137 'shapes-CICAgMDO7cfIzwEQ1AMYPCgBMghqY8tqyRCArQ.swf.webglbeta.html',
138 'CICAgIDQ2Pb-MxCsAhj6ASgBMgi5DLoSO0gPbQ.swf.webglbeta.html',
139 'CICAgKCN39CopQEQoAEY2AQoATIID59gK5hjjIg.swf.webglbeta.html',
140 'CICAgKCNj4HgyAEQeBjYBCgBMgjQpPkOjyWNdw.1.swf.webglbeta.html',
141 'clip-paths-CILZhLqO_-27bxB4GNgEKAEyCC46kMLBXnMT.swf.webglbeta.html',
142 'CICAgMDOrcnRGRB4GNgEKAEyCP_ZBSfwUFsj.swf.webglbeta.html',
144 for page_name in swiffy_pages:
145 url = base_url + '/' + page_name
146 self.AddStory(SwiffyPage(url, self))
149 class ScrollingToughAdCasesPageSet(story.StorySet):
150 """Pages for measuring scrolling performance with advertising content."""
152 def __init__(self):
153 super(ScrollingToughAdCasesPageSet, self).__init__(
154 archive_data_file='data/tough_ad_cases.json',
155 cloud_storage_bucket=story.INTERNAL_BUCKET)
157 self.AddStory(ScrollingPage('file://tough_ad_cases/'
158 'swiffy_collection.html', self, make_javascript_deterministic=False,
159 y_scroll_distance_multiplier=0.25))
160 self.AddStory(ScrollingPage('file://tough_ad_cases/'
161 'swiffy_webgl_collection.html',
162 self, make_javascript_deterministic=False))
163 self.AddStory(ScrollingPage('http://www.latimes.com', self))
164 self.AddStory(ScrollingForbesPage('http://www.forbes.com/sites/parmyolson/'
165 '2015/07/29/jana-mobile-data-facebook-internet-org/', self))
166 self.AddStory(ScrollingPage('http://androidcentral.com', self))
167 self.AddStory(ScrollingPage('http://mashable.com', self,
168 y_scroll_distance_multiplier=0.25))
169 self.AddStory(ScrollingPage('http://www.androidauthority.com/'
170 'reduce-data-use-turn-on-data-compression-in-chrome-630064/', self))
171 self.AddStory(ScrollingPage('http://www.cnn.com/2015/01/09/politics/'
172 'nebraska-keystone-pipeline/index.html', self))
173 # Disabled: crbug.com/520509
174 #self.AddStory(ScrollingPage('http://time.com/3977891/'
175 # 'donald-trump-debate-republican/', self))
176 self.AddStory(ScrollingPage('http://www.theguardian.com/uk', self))
177 self.AddStory(ScrollingPage('http://m.tmz.com', self,
178 y_scroll_distance_multiplier=0.25))
179 self.AddStory(ScrollingPage('http://androidpolice.com', self))