Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / tools / perf / page_sets / key_mobile_sites.py
1 # Copyright 2014 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.
4 # pylint: disable=W0401,W0614
5 from telemetry.page.actions.all_page_actions import *
6 from telemetry.page import page as page_module
7 from telemetry.page import page_set as page_set_module
8
9
10 class KeyMobileSitesPage(page_module.Page):
11
12   def __init__(self, url, page_set, name=''):
13     super(KeyMobileSitesPage, self).__init__(url=url, page_set=page_set,
14                                              name=name)
15     self.credentials_path = 'data/credentials.json'
16     self.user_agent_type = 'mobile'
17     self.archive_data_file = 'data/key_mobile_sites.json'
18
19   def RunSmoothness(self, action_runner):
20     action_runner.RunAction(ScrollAction())
21
22   def RunRepaint(self, action_runner):
23     action_runner.RunAction(RepaintContinuouslyAction({'seconds': 5}))
24
25
26 class Page1(KeyMobileSitesPage):
27
28   """ Why: Top news site """
29
30   def __init__(self, page_set):
31     super(Page1, self).__init__(
32       url='http://nytimes.com/',
33       page_set=page_set)
34
35     self.fastpath = True
36
37
38 class Page2(KeyMobileSitesPage):
39
40   """ Why: Typical mobile business site """
41
42   def __init__(self, page_set):
43     super(Page2, self).__init__(
44       url=('http://iphone.capitolvolkswagen.com/index.htm'
45            '#new-inventory_p_2Fsb-new_p_2Ehtm_p_3Freset_p_3DInventoryListing'),
46       page_set=page_set)
47
48   def RunNavigateSteps(self, action_runner):
49     action_runner.RunAction(NavigateAction())
50     action_runner.RunAction(WaitAction(
51       {
52         'text': 'Next 35',
53         'condition': 'element'
54       }))
55     action_runner.RunAction(WaitAction(
56       {
57         'javascript': 'document.body.scrollHeight > 2560'
58       }))
59
60
61 class Page3(KeyMobileSitesPage):
62
63   """ Why: Image-heavy site """
64
65   def __init__(self, page_set):
66     super(Page3, self).__init__(
67       url='http://cuteoverload.com',
68       page_set=page_set)
69
70     self.fastpath = True
71
72
73 class Page4(KeyMobileSitesPage):
74
75   """ Why: Top tech blog """
76
77   def __init__(self, page_set):
78     super(Page4, self).__init__(
79       # pylint: disable=C0301
80       url='http://www.theverge.com/2012/10/28/3568746/amazon-7-inch-fire-hd-ipad-mini-ad-ballsy',
81       page_set=page_set)
82
83   def RunNavigateSteps(self, action_runner):
84     action_runner.RunAction(NavigateAction())
85     action_runner.RunAction(WaitAction(
86       {
87         'javascript': ('window.Chorus !== undefined &&'
88                        'window.Chorus.Comments !== undefined &&'
89                        'window.Chorus.Comments.Json !== undefined &&'
90                        '(window.Chorus.Comments.loaded ||'
91                        ' window.Chorus.Comments.Json.load_comments())')
92       }))
93
94
95 class Page5(KeyMobileSitesPage):
96
97   """ Why: Top news site """
98
99   def __init__(self, page_set):
100     super(Page5, self).__init__(
101       # pylint: disable=C0301
102       url='http://www.cnn.com/2012/10/03/politics/michelle-obama-debate/index.html',
103       page_set=page_set)
104
105   def RunNavigateSteps(self, action_runner):
106     action_runner.RunAction(NavigateAction())
107     action_runner.RunAction(WaitAction({'seconds': 8}))
108
109
110 class Page6(KeyMobileSitesPage):
111
112   """ Why: Social; top Google property; Public profile; infinite scrolls """
113
114   def __init__(self, page_set):
115     super(Page6, self).__init__(
116       # pylint: disable=C0301
117       url='https://plus.google.com/app/basic/110031535020051778989/posts?source=apppromo',
118       page_set=page_set)
119
120   def RunSmoothness(self, action_runner):
121     action_runner.RunAction(ScrollAction({'scroll_is_infinite': True}))
122
123
124 class Page7(KeyMobileSitesPage):
125
126   """ Why: #1 (Alexa global) """
127
128   def __init__(self, page_set):
129     super(Page7, self).__init__(
130       url='https://facebook.com/barackobama',
131       page_set=page_set)
132
133   def RunNavigateSteps(self, action_runner):
134     action_runner.RunAction(NavigateAction())
135     action_runner.RunAction(WaitAction(
136       {
137         'javascript': ('document.getElementById("u_0_c") !== null &&'
138                        'document.body.scrollHeight > window.innerHeight')
139       }))
140
141
142 class Page8(KeyMobileSitesPage):
143
144   """ Why: #3 (Alexa global) """
145
146   def __init__(self, page_set):
147     super(Page8, self).__init__(
148       url='http://m.youtube.com/watch?v=9hBpF_Zj4OA',
149       page_set=page_set)
150
151   def RunNavigateSteps(self, action_runner):
152     action_runner.RunAction(NavigateAction())
153     action_runner.RunAction(WaitAction(
154       {
155         'javascript': 'document.getElementById("paginatortarget") !== null'
156       }))
157
158
159 class Page9(KeyMobileSitesPage):
160
161   """
162   Why: #11 (Alexa global), google property; some blogger layouts have infinite
163   scroll but more interesting
164   """
165
166   def __init__(self, page_set):
167     super(Page9, self).__init__(
168       url='http://googlewebmastercentral.blogspot.com/',
169       page_set=page_set,
170       name='Blogger')
171
172
173 class Page10(KeyMobileSitesPage):
174
175   """ Why: #18 (Alexa global), Picked an interesting post """
176
177   def __init__(self, page_set):
178     super(Page10, self).__init__(
179       # pylint: disable=C0301
180       url='http://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks-for-august-2012/',
181       page_set=page_set,
182       name='Wordpress')
183
184
185 class Page11(KeyMobileSitesPage):
186
187   """ Why: #12 (Alexa global),Public profile """
188
189   def __init__(self, page_set):
190     super(Page11, self).__init__(
191       url='https://www.linkedin.com/in/linustorvalds',
192       page_set=page_set,
193       name='LinkedIn')
194
195   def RunNavigateSteps(self, action_runner):
196     action_runner.RunAction(NavigateAction())
197     action_runner.RunAction(WaitAction(
198       {
199         'javascript':
200           'document.getElementById("profile-view-scroller") !== null'
201       }))
202
203
204 class Page12(KeyMobileSitesPage):
205
206   """ Why: #6 (Alexa) most visited worldwide, picked an interesting page """
207
208   def __init__(self, page_set):
209     super(Page12, self).__init__(
210       url='http://en.wikipedia.org/wiki/Wikipedia',
211       page_set=page_set,
212       name='Wikipedia (1 tab)')
213
214
215 class Page13(KeyMobileSitesPage):
216
217   """ Why: #8 (Alexa global), picked an interesting page """
218
219   def __init__(self, page_set):
220     super(Page13, self).__init__(
221       url='http://twitter.com/katyperry',
222       page_set=page_set,
223       name='Twitter')
224     self.disabled = 'Forbidden (Rate Limit Exceeded)'
225
226
227 class Page14(KeyMobileSitesPage):
228
229   """ Why: #37 (Alexa global) """
230
231   def __init__(self, page_set):
232     super(Page14, self).__init__(
233       url='http://pinterest.com',
234       page_set=page_set,
235       name='Pinterest')
236
237
238 class Page15(KeyMobileSitesPage):
239
240   """ Why: #1 sports """
241
242   def __init__(self, page_set):
243     super(Page15, self).__init__(
244       url='http://espn.go.com',
245       page_set=page_set,
246       name='ESPN')
247     self.disabled = 'Fails often; crbug.com/249722'
248
249
250 class Page16(KeyMobileSitesPage):
251
252   """ Why: #1 Alexa reference """
253
254   def __init__(self, page_set):
255     super(Page16, self).__init__(
256       # pylint: disable=C0301
257       url='http://answers.yahoo.com/question/index?qid=20110117024343AAopj8f',
258       page_set=page_set)
259
260   def RunNavigateSteps(self, action_runner):
261     action_runner.RunAction(NavigateAction())
262     action_runner.RunAction(WaitAction(
263       {
264         'text': 'Other Answers (1 - 20 of 149)',
265         'condition': 'element'
266       }))
267     action_runner.RunAction(ClickElementAction(
268       {
269         'text': 'Other Answers (1 - 20 of 149)'
270       }))
271
272
273 class Page17(KeyMobileSitesPage):
274
275   """ Why: productivity, top google properties """
276
277   def __init__(self, page_set):
278     super(Page17, self).__init__(
279       url='https://mail.google.com/mail/',
280       page_set=page_set)
281
282     self.credentials = 'google'
283
284   def RunNavigateSteps(self, action_runner):
285     action_runner.RunAction(NavigateAction())
286     action_runner.RunAction(WaitAction(
287       {
288         'javascript': 'document.getElementById("og_user_warning") !== null'
289       }))
290     action_runner.RunAction(WaitAction(
291       {
292         'javascript': 'document.getElementById("og_user_warning") === null'
293       }))
294
295   def RunSmoothness(self, action_runner):
296     action_runner.RunAction(ScrollAction(
297       {
298         'scrollable_element_function':
299           ('function(callback) {'
300            'callback(document.getElementById("views")'
301            '.childNodes[1].firstChild); }')
302       }))
303     action_runner.RunAction(ScrollAction(
304       {
305         'scrollable_element_function':
306           ('function(callback) { '
307            'callback(document.getElementById("views")'
308            '.childNodes[1].firstChild); }')
309       }))
310
311
312 class Page18(KeyMobileSitesPage):
313
314   """ Why: crbug.com/169827 """
315
316   def __init__(self, page_set):
317     super(Page18, self).__init__(
318       url='http://slashdot.org/',
319       page_set=page_set)
320
321     self.fastpath = True
322
323
324 class Page19(KeyMobileSitesPage):
325
326   """ Why: #5 Alexa news """
327
328   def __init__(self, page_set):
329     super(Page19, self).__init__(
330       url='http://www.reddit.com/r/programming/comments/1g96ve',
331       page_set=page_set)
332
333     self.fastpath = True
334
335
336 class Page20(KeyMobileSitesPage):
337
338   """ Why: Problematic use of fixed position elements """
339
340   def __init__(self, page_set):
341     super(Page20, self).__init__(
342       url='http://www.boingboing.net',
343       page_set=page_set)
344
345     self.fastpath = True
346
347
348 class Page21(KeyMobileSitesPage):
349
350   """ Why: crbug.com/172906 """
351
352   def __init__(self, page_set):
353     super(Page21, self).__init__(
354       url='http://groupcloned.com',
355       page_set=page_set)
356
357     self.disabled = ('Page behaves non-deterministically, replaced with test'
358                      'version for now')
359
360   def RunNavigateSteps(self, action_runner):
361     action_runner.RunAction(NavigateAction())
362     action_runner.RunAction(WaitAction({'seconds': 5}))
363     action_runner.RunAction(WaitAction(
364       {
365         'javascript': '''
366           document.getElementById("element-19") !== null &&
367           document.getElementById("element-19").contentDocument
368             .getElementById("element-22") !== null &&
369           document.getElementById("element-19").contentDocument
370             .getElementsByClassName(
371               "container list-item gc-list-item stretched").length !== 0'''
372       }))
373
374   def RunSmoothness(self, action_runner):
375     action_runner.RunAction(ScrollAction(
376       {
377         'scroll_distance_function': '''
378           function() {
379             return Math.max(0, 1250 + document.getElementById("element-19")
380                                               .contentDocument
381                                               .getElementById("element-22")
382                                               .getBoundingClientRect().top);
383           }''',
384         'scroll_requires_touch': True
385       }))
386
387
388 class Page22(KeyMobileSitesPage):
389
390   """ Why: crbug.com/172906 """
391
392   def __init__(self, page_set):
393     super(Page22, self).__init__(
394       url='http://groupcloned.com/test/list-images-variable/index.html',
395       page_set=page_set)
396
397   def RunNavigateSteps(self, action_runner):
398     action_runner.RunAction(NavigateAction())
399     action_runner.RunAction(WaitAction(
400       {
401         'javascript': 'document.getElementById("element-5") !== null'
402       }))
403
404   def RunSmoothness(self, action_runner):
405     action_runner.RunAction(ScrollAction(
406       {
407         'scroll_distance_function': '''
408           function() {
409             return Math.max(0, 1250 +
410               document.getElementById("element-5").getBoundingClientRect().top);
411           }''',
412         'scroll_requires_touch': True
413       }))
414
415
416 class Page23(KeyMobileSitesPage):
417
418   """ Why: crbug.com/231413 """
419
420   def __init__(self, page_set):
421     super(Page23, self).__init__(
422       url='http://forecast.io',
423       page_set=page_set)
424
425     self.disabled = u"Doesn't scroll; crbug.com/249736"
426
427
428 class Page24(KeyMobileSitesPage):
429
430   """ Why: Google News: accelerated scrolling version """
431
432   def __init__(self, page_set):
433     super(Page24, self).__init__(
434       url='http://mobile-news.sandbox.google.com/news/pt1',
435       page_set=page_set)
436
437   def RunNavigateSteps(self, action_runner):
438     action_runner.RunAction(NavigateAction())
439     action_runner.RunAction(WaitAction(
440       {
441         'javascript': ('typeof NEWS_telemetryReady !== "undefined" && '
442                        'NEWS_telemetryReady == true')
443       }))
444
445
446 class Page25(KeyMobileSitesPage):
447
448   """
449   Why: Google News: this iOS version is slower than accelerated scrolling
450   """
451
452   def __init__(self, page_set):
453     super(Page25, self).__init__(
454       url='http://mobile-news.sandbox.google.com/news/pt0',
455       page_set=page_set)
456
457   def RunNavigateSteps(self, action_runner):
458     action_runner.RunAction(NavigateAction())
459     action_runner.RunAction(WaitAction(
460       {
461         'javascript': 'document.getElementById(":h") != null'
462       }))
463     action_runner.RunAction(WaitAction(
464       {
465         'seconds': 1
466       }))
467
468   def RunSmoothness(self, action_runner):
469     action_runner.RunAction(ScrollAction(
470       {
471         'scroll_requires_touch': True,
472         'scrollable_element_function': '''
473           function(callback) {
474             callback(document.getElementById(':5'));
475           }''',
476         'scroll_distance_function': '''
477           function() {
478             return Math.max(0, 2500 +
479               document.getElementById(':h').getBoundingClientRect().top);
480           }'''
481       }))
482
483
484 class Page26(KeyMobileSitesPage):
485
486   """
487   Why: #1 world commerce website by visits; #3 commerce in the US by time spent
488   """
489
490   def __init__(self, page_set):
491     super(Page26, self).__init__(
492       url='http://www.amazon.com/gp/aw/s/ref=is_box_?k=nicolas+cage',
493       page_set=page_set)
494
495   def RunSmoothness(self, action_runner):
496     action_runner.RunAction(ScrollAction(
497       {
498         'scrollable_element_function': '''
499           function(callback) {
500             callback(document.getElementById('search'));
501           }''',
502         'scroll_distance_function': '''
503           function() {
504             return document.body.scrollHeight - window.innerHeight;
505           }'''
506       }))
507
508
509 class KeyMobileSitesPageSet(page_set_module.PageSet):
510
511   """ Key mobile sites """
512
513   def __init__(self):
514     super(KeyMobileSitesPageSet, self).__init__(
515       credentials_path='data/credentials.json',
516       user_agent_type='mobile',
517       archive_data_file='data/key_mobile_sites.json')
518
519     self.AddPage(Page1(self))
520     self.AddPage(Page2(self))
521     self.AddPage(Page3(self))
522     self.AddPage(Page4(self))
523     self.AddPage(Page5(self))
524     self.AddPage(Page6(self))
525     self.AddPage(Page7(self))
526     self.AddPage(Page8(self))
527     self.AddPage(Page9(self))
528     self.AddPage(Page10(self))
529     self.AddPage(Page11(self))
530     self.AddPage(Page12(self))
531 #    self.AddPage(Page13(self))
532     self.AddPage(Page14(self))
533 #    self.AddPage(Page15(self))
534     self.AddPage(Page16(self))
535     self.AddPage(Page17(self))
536     self.AddPage(Page18(self))
537     self.AddPage(Page19(self))
538     self.AddPage(Page20(self))
539     self.AddPage(Page21(self))
540     self.AddPage(Page22(self))
541 #    self.AddPage(Page23(self))
542     self.AddPage(Page24(self))
543     self.AddPage(Page25(self))
544     self.AddPage(Page26(self))
545
546     urls_list = [
547       # Why: crbug.com/242544
548       ('http://www.androidpolice.com/2012/10/03/rumor-evidence-mounts-that-an-'
549        'lg-optimus-g-nexus-is-coming-along-with-a-nexus-phone-certification-'
550        'program/'),
551       # Why: crbug.com/149958
552       'http://gsp.ro',
553       # Why: Top tech blog
554       'http://theverge.com',
555       # Why: Top tech site
556       'http://digg.com',
557       # Why: Top Google property; a Google tab is often open
558       'https://www.google.com/#hl=en&q=barack+obama',
559       # Why: #1 news worldwide (Alexa global)
560       'http://news.yahoo.com',
561       # Why: #2 news worldwide
562       'http://www.cnn.com',
563       # Why: #1 commerce website by time spent by users in US
564       'http://shop.mobileweb.ebay.com/searchresults?kw=viking+helmet',
565       # Why: #1 Alexa recreation
566       # pylint: disable=C0301
567       'http://www.booking.com/searchresults.html?src=searchresults&latitude=65.0500&longitude=25.4667',
568       # Why: #1 Alexa sports
569       'http://sports.yahoo.com/',
570       # Why: Top tech blog
571       'http://techcrunch.com',
572       # Why: #6 Alexa sports
573       'http://mlb.com/',
574       # Why: #14 Alexa California
575       'http://www.sfgate.com/',
576       # Why: Non-latin character set
577       'http://worldjournal.com/',
578       # Why: Mobile wiki
579       'http://www.wowwiki.com/World_of_Warcraft:_Mists_of_Pandaria',
580       # Why: #15 Alexa news
581       'http://online.wsj.com/home-page',
582       # Why: Image-heavy mobile site
583       'http://www.deviantart.com/',
584       # Why: Top search engine
585       ('http://www.baidu.com/s?wd=barack+obama&rsv_bp=0&rsv_spt=3&rsv_sug3=9&'
586        'rsv_sug=0&rsv_sug4=3824&rsv_sug1=3&inputT=4920'),
587       # Why: Top search engine
588       'http://www.bing.com/search?q=sloths'
589     ]
590
591     for url in urls_list:
592       self.AddPage(KeyMobileSitesPage(url, self))