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

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

Issue 1291513004: smoothness.scrolling_tough_ad_cases to use browser driven scrolls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Special handling of TMZ page Created 5 years, 4 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
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
6
5 from telemetry.core import exceptions 7 from telemetry.core import exceptions
6 from telemetry.page import page as page_module 8 from telemetry.page import page as page_module
9 from telemetry.web_perf import timeline_interaction_record
7 from telemetry import story 10 from telemetry import story
8 11
9 12
10 class SwiffyPage(page_module.Page): 13 class SwiffyPage(page_module.Page):
11 14
12 def __init__(self, url, page_set): 15 def __init__(self, url, page_set):
13 super(SwiffyPage, self).__init__(url=url, page_set=page_set, 16 super(SwiffyPage, self).__init__(url=url, page_set=page_set,
14 make_javascript_deterministic=False) 17 make_javascript_deterministic=False)
15 18
16 def RunNavigateSteps(self, action_runner): 19 def RunNavigateSteps(self, action_runner):
(...skipping 12 matching lines...) Expand all
29 32
30 def RunPageInteractions(self, action_runner): 33 def RunPageInteractions(self, action_runner):
31 with action_runner.CreateInteraction('ToughAd'): 34 with action_runner.CreateInteraction('ToughAd'):
32 action_runner.Wait(10) 35 action_runner.Wait(10)
33 36
34 37
35 class ScrollingPage(page_module.Page): 38 class ScrollingPage(page_module.Page):
36 39
37 def __init__(self, url, page_set, top_start_ratio=.5, 40 def __init__(self, url, page_set, top_start_ratio=.5,
38 make_javascript_deterministic=True): 41 make_javascript_deterministic=True):
39 super(ScrollingPage, self).__init__(url=url, page_set=page_set, 42 super(ScrollingPage, self).__init__(
40 make_javascript_deterministic=make_javascript_deterministic) 43 url=url,
44 page_set=page_set,
45 make_javascript_deterministic=make_javascript_deterministic,
46 shared_page_state_class=(
47 repeatable_synthesize_scroll_gesture_shared_state.\
48 RepeatableSynthesizeScrollGestureSharedState))
41 self._top_start_ratio = top_start_ratio 49 self._top_start_ratio = top_start_ratio
50 self._scroll_multiplier = 2
Sami 2015/08/18 15:06:46 Could you make this a named parameter?
alex clarke (OOO till 29th) 2015/08/19 11:42:20 Done.
51 print "ScrollingPage"
Sami 2015/08/18 15:06:46 Probably want to leave these out :)
alex clarke (OOO till 29th) 2015/08/19 11:42:20 Done.
42 52
43 def RunNavigateSteps(self, action_runner): 53 def RunNavigateSteps(self, action_runner):
44 # Rewrite file urls to point to the replay server instead. 54 # Rewrite file urls to point to the replay server instead.
45 if self.is_file: 55 if self.is_file:
46 url = self.file_path_url_with_scheme 56 url = self.file_path_url_with_scheme
47 url = action_runner.tab.browser.http_server.UrlOf(url[len('file://'):]) 57 url = action_runner.tab.browser.http_server.UrlOf(url[len('file://'):])
48 else: 58 else:
49 url = self._url 59 url = self._url
50 action_runner.tab.Navigate(url) 60 action_runner.tab.Navigate(url)
51 61
52 # Give the page one second to become interactive and start scrolling after 62 # Give the page one second to become interactive and start scrolling after
53 # the timeout regardless of the document's ready state. 63 # the timeout regardless of the document's ready state.
54 try: 64 try:
55 action_runner.tab.WaitForDocumentReadyStateToBeInteractiveOrBetter(1) 65 action_runner.tab.WaitForDocumentReadyStateToBeInteractiveOrBetter(1)
56 except exceptions.TimeoutException: 66 except exceptions.TimeoutException:
57 pass 67 pass
58 # Make sure we have a body element to scroll. 68 # Make sure we have a body element to scroll.
59 action_runner.WaitForJavaScriptCondition('document.body !== null') 69 action_runner.WaitForJavaScriptCondition('document.body !== null')
60 70
61 def RunPageInteractions(self, action_runner): 71 def RunPageInteractions(self, action_runner):
62 for _ in range(10): 72 # Get the dimensions of the screen.
Sami 2015/08/18 15:06:46 This is another round trip through the main thread
alex clarke (OOO till 29th) 2015/08/19 11:42:20 Done.
63 with action_runner.CreateGestureInteraction('ScrollAction', 73 js_result = action_runner.EvaluateJavaScript(
64 repeatable=True): 74 'window.screen.availWidth + "," + window.screen.availHeight')
65 action_runner.ScrollPage(distance=500, 75 screensize = [int(n) for n in js_result.split(',')]
66 top_start_ratio=self._top_start_ratio) 76 quarter_screen_height = screensize[1] / 4
67 action_runner.Wait(.25)
68 77
78 # Set up a browser driven repeating scroll. The delay between the scrolls
79 # should be unaffected by render thread responsivness (or lack there of).
80 flags = [timeline_interaction_record.REPEATABLE]
Sami 2015/08/18 15:06:46 Could you make this into a new Action instance (wi
alex clarke (OOO till 29th) 2015/08/19 11:42:20 Seems like a lot of boilerplate, I'm not sure I'm
Sami 2015/08/19 11:54:46 The idea was that we could use this in all page se
81 scroll_params = {
82 'x': screensize[0] / 2,
83 'y': 3 * quarter_screen_height,
84 'xDistance': 0,
85 'yDistance': -quarter_screen_height * self._scroll_multiplier,
86 'preventFling': True,
87 'repeatCount': 9,
88 'repeatDelayMs': 250,
89 'interactionMarkerName':
90 timeline_interaction_record.GetJavaScriptMarker(
91 'Gesture_ScrollAction', flags),
92 }
93 action_runner.tab.SynthesizeScrollGesture(scroll_params)
Sami 2015/08/18 15:06:46 Two blank lines here please.
alex clarke (OOO till 29th) 2015/08/19 11:42:20 Done.
69 94
70 class ScrollingForbesPage(ScrollingPage): 95 class ScrollingForbesPage(ScrollingPage):
71 96
72 def __init__(self, url, page_set): 97 def __init__(self, url, page_set):
73 # forbes.com uses a strange dynamic transform on the body element, 98 # forbes.com uses a strange dynamic transform on the body element,
74 # which occasionally causes us to try scrolling from outside the 99 # which occasionally causes us to try scrolling from outside the
75 # screen. Start at the very top of the viewport to avoid this. 100 # screen. Start at the very top of the viewport to avoid this.
76 super(ScrollingForbesPage, self).__init__( 101 super(ScrollingForbesPage, self).__init__(
77 url=url, page_set=page_set, top_start_ratio=0, 102 url=url, page_set=page_set, top_start_ratio=0,
78 make_javascript_deterministic=False) 103 make_javascript_deterministic=False)
79 104
80 def RunNavigateSteps(self, action_runner): 105 def RunNavigateSteps(self, action_runner):
81 super(ScrollingForbesPage, self).RunNavigateSteps(action_runner) 106 super(ScrollingForbesPage, self).RunNavigateSteps(action_runner)
82 # Wait until the interstitial banner goes away. 107 # Wait until the interstitial banner goes away.
83 action_runner.WaitForJavaScriptCondition( 108 action_runner.WaitForJavaScriptCondition(
84 'window.location.pathname.indexOf("welcome") == -1') 109 'window.location.pathname.indexOf("welcome") == -1')
85 # Make sure we have a body element to scroll. 110 # Make sure we have a body element to scroll.
86 action_runner.WaitForJavaScriptCondition('document.body !== null') 111 action_runner.WaitForJavaScriptCondition('document.body !== null')
87 112
88 113
114 class ScrollingTmzPage(ScrollingPage):
115
116 def __init__(self, url, page_set):
117 # The TMZ page can take a while to be scrollable.
118 super(ScrollingTmzPage, self).__init__(
119 url=url, page_set=page_set, top_start_ratio=0,
120 make_javascript_deterministic=False)
121 # The TMZ page is shorter than the others.
122 self._scroll_multiplier = 1
123
124 def RunNavigateSteps(self, action_runner):
125 super(ScrollingTmzPage, self).RunNavigateSteps(action_runner)
126 # Wait for the page to be scrollable.
127 action_runner.WaitForJavaScriptCondition(
128 'document.body.scrollHeight > window.screen.height')
129
130
89 class ToughAdCasesPageSet(story.StorySet): 131 class ToughAdCasesPageSet(story.StorySet):
90 """Pages for measuring rendering performance with advertising content.""" 132 """Pages for measuring rendering performance with advertising content."""
91 133
92 def __init__(self): 134 def __init__(self):
93 super(ToughAdCasesPageSet, self).__init__( 135 super(ToughAdCasesPageSet, self).__init__(
94 archive_data_file='data/tough_ad_cases.json', 136 archive_data_file='data/tough_ad_cases.json',
95 cloud_storage_bucket=story.INTERNAL_BUCKET) 137 cloud_storage_bucket=story.INTERNAL_BUCKET)
96 138
97 base_url = 'http://localhost:8000' 139 base_url = 'http://localhost:8000'
98 140
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 '2015/07/29/jana-mobile-data-facebook-internet-org/', self)) 173 '2015/07/29/jana-mobile-data-facebook-internet-org/', self))
132 self.AddStory(ScrollingPage('http://androidcentral.com', self)) 174 self.AddStory(ScrollingPage('http://androidcentral.com', self))
133 self.AddStory(ScrollingPage('http://mashable.com', self, top_start_ratio=0)) 175 self.AddStory(ScrollingPage('http://mashable.com', self, top_start_ratio=0))
134 self.AddStory(ScrollingPage('http://www.androidauthority.com/' 176 self.AddStory(ScrollingPage('http://www.androidauthority.com/'
135 'reduce-data-use-turn-on-data-compression-in-chrome-630064/', self)) 177 'reduce-data-use-turn-on-data-compression-in-chrome-630064/', self))
136 self.AddStory(ScrollingPage('http://www.cnn.com/2015/01/09/politics/' 178 self.AddStory(ScrollingPage('http://www.cnn.com/2015/01/09/politics/'
137 'nebraska-keystone-pipeline/index.html', self, top_start_ratio=0)) 179 'nebraska-keystone-pipeline/index.html', self, top_start_ratio=0))
138 self.AddStory(ScrollingPage('http://time.com/3977891/' 180 self.AddStory(ScrollingPage('http://time.com/3977891/'
139 'donald-trump-debate-republican/', self)) 181 'donald-trump-debate-republican/', self))
140 self.AddStory(ScrollingPage('http://www.theguardian.com/uk', self)) 182 self.AddStory(ScrollingPage('http://www.theguardian.com/uk', self))
141 self.AddStory(ScrollingPage('http://m.tmz.com', self)) 183 self.AddStory(ScrollingTmzPage('http://m.tmz.com', self))
142 self.AddStory(ScrollingPage('http://androidpolice.com', self, 184 self.AddStory(ScrollingPage('http://androidpolice.com', self,
143 top_start_ratio=0)) 185 top_start_ratio=0))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698