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.
7 from telemetry
.page
import shared_page_state
8 from telemetry
import story
10 from page_sets
import top_7_stress
11 from page_sets
import top_pages
14 def _SpawnTab(action_runner
):
15 return action_runner
.EvaluateJavaScript('__telemetry_spawn_tab()')
18 def _CloseTab(action_runner
, tab
):
19 action_runner
.EvaluateJavaScript('__telemetry_close_tab(' + str(tab
) + ')')
22 def _CreateIdleMultiTabPageClass(base_page_cls
, base_js
):
23 class DerivedIdleMultiTabPage(base_page_cls
): # pylint: disable=W0232
25 def RunPageInteractions(self
, action_runner
):
27 action_runner
.ExecuteJavaScript(base_js
)
30 for tab
in xrange(MAX_TABS
):
31 tabs
[tab
] = _SpawnTab(action_runner
)
33 action_runner
.Wait(20)
35 for tab
in xrange(MAX_TABS
):
36 _CloseTab(action_runner
, tabs
[tab
])
38 action_runner
.Wait(30)
40 for tab
in xrange(MAX_TABS
):
41 tabs
[tab
] = _SpawnTab(action_runner
)
42 action_runner
.Wait(20)
44 for tab
in xrange(MAX_TABS
):
45 _CloseTab(action_runner
, tabs
[tab
])
46 action_runner
.Wait(30)
47 return DerivedIdleMultiTabPage
50 class IdleMultiTabCasesPageSet(story
.StorySet
):
52 """ Pages for testing GC efficiency on idle pages. """
55 super(IdleMultiTabCasesPageSet
, self
).__init
__(
56 archive_data_file
='data/top_25.json',
57 cloud_storage_bucket
=story
.PARTNER_BUCKET
)
58 with
open(os
.path
.join(os
.path
.dirname(__file__
),
59 'idle_multi_tab_cases.js')) as f
:
62 _CreateIdleMultiTabPageClass(top_pages
.GoogleDocPage
, base_js
)
63 (self
, shared_page_state
.SharedDesktopPageState
))
65 _CreateIdleMultiTabPageClass(top_7_stress
.GooglePlusPage
, base_js
)