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 from telemetry
.page
import page
as page_module
5 from telemetry
.page
import shared_page_state
6 from telemetry
import story
9 class MobileMemoryPage(page_module
.Page
):
11 def __init__(self
, url
, page_set
):
12 super(MobileMemoryPage
, self
).__init
__(
13 url
=url
, page_set
=page_set
, credentials_path
= 'data/credentials.json',
14 shared_page_state_class
=shared_page_state
.SharedMobilePageState
)
15 self
.archive_data_file
= 'data/mobile_memory.json'
18 class GmailPage(MobileMemoryPage
):
20 def __init__(self
, page_set
):
21 super(GmailPage
, self
).__init
__(
22 url
='https://mail.google.com/mail/mu',
25 self
.reload_and_gc
= [{'action': 'reload'},
28 {'action': 'js_collect_garbage'}]
29 self
.credentials
= 'google'
31 def ReloadAndGc(self
, action_runner
):
32 action_runner
.ReloadPage()
33 action_runner
.Wait(15)
34 action_runner
.ForceGarbageCollection()
36 def RunPageInteractions(self
, action_runner
):
38 self
.ReloadAndGc(action_runner
)
41 class GoogleSearchPage(MobileMemoryPage
):
43 """ Why: Tests usage of discardable memory """
45 def __init__(self
, page_set
):
46 super(GoogleSearchPage
, self
).__init
__(
47 url
='https://www.google.com/search?site=&tbm=isch&q=google',
50 def RunPageInteractions(self
, action_runner
):
51 with action_runner
.CreateGestureInteraction('ScrollAction'):
52 action_runner
.ScrollPage()
54 with action_runner
.CreateGestureInteraction('ScrollAction'):
55 action_runner
.ScrollPage()
57 with action_runner
.CreateGestureInteraction('ScrollAction'):
58 action_runner
.ScrollPage()
60 with action_runner
.CreateGestureInteraction('ScrollAction'):
61 action_runner
.ScrollPage()
62 action_runner
.WaitForJavaScriptCondition(
63 'document.getElementById("rg_s").childElementCount > 300')
66 class ScrollPage(MobileMemoryPage
):
68 def __init__(self
, url
, page_set
):
69 super(ScrollPage
, self
).__init
__(url
=url
, page_set
=page_set
)
71 def RunPageInteractions(self
, action_runner
):
72 with action_runner
.CreateGestureInteraction('ScrollAction'):
73 action_runner
.ScrollPage()
76 class MobileMemoryPageSet(story
.StorySet
):
78 """ Mobile sites with interesting memory characteristics """
81 super(MobileMemoryPageSet
, self
).__init
__(
82 archive_data_file
='data/mobile_memory.json',
83 cloud_storage_bucket
=story
.PARTNER_BUCKET
)
85 self
.AddStory(GmailPage(self
))
86 self
.AddStory(GoogleSearchPage(self
))
89 # Why: Renderer process memory bloat
90 'http://techcrunch.com',
91 # pylint: disable=C0301
92 'http://techcrunch.com/2014/02/17/pixel-brings-brings-old-school-video-game-art-to-life-in-your-home/',
93 'http://techcrunch.com/2014/02/15/kickstarter-coins-2/',
94 'http://techcrunch.com/2014/02/15/was-y-combinator-worth-it/',
98 self
.AddStory(ScrollPage(url
, self
))