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 google_pages
12 def _SpawnTab(action_runner
):
13 return action_runner
.EvaluateJavaScript('__telemetry_spawn_tab()')
16 def _CloseTab(action_runner
, tab
):
17 action_runner
.EvaluateJavaScript('__telemetry_close_tab(' + str(tab
) + ')')
20 def _CreateIdleMultiTabPageClass(base_page_cls
, base_js
):
21 class DerivedIdleMultiTabPage(base_page_cls
): # pylint: disable=W0232
23 def RunPageInteractions(self
, action_runner
):
25 action_runner
.ExecuteJavaScript(base_js
)
28 for tab
in xrange(MAX_TABS
):
29 tabs
[tab
] = _SpawnTab(action_runner
)
31 action_runner
.Wait(40)
33 for tab
in xrange(MAX_TABS
):
34 _CloseTab(action_runner
, tabs
[tab
])
36 action_runner
.Wait(40)
37 return DerivedIdleMultiTabPage
40 class IdleMultiTabCasesPageSet(story
.StorySet
):
42 """ Pages for testing GC efficiency on idle pages. """
45 super(IdleMultiTabCasesPageSet
, self
).__init
__(
46 archive_data_file
='data/idle_multi_tab_cases.json',
47 cloud_storage_bucket
=story
.PARTNER_BUCKET
)
48 with
open(os
.path
.join(os
.path
.dirname(__file__
),
49 'idle_multi_tab_cases.js')) as f
:
52 _CreateIdleMultiTabPageClass(google_pages
.GoogleDocPage
, base_js
)
53 (self
, shared_page_state
.SharedDesktopPageState
))