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.
5 from page_sets
.login_helpers
import google_login
7 from telemetry
.page
import page
as page_module
8 from telemetry
.page
import shared_page_state
12 def _DeterministicPerformanceCounters():
13 with
open(os
.path
.join(os
.path
.dirname(__file__
),
14 'deterministic_performance_counters.js')) as f
:
17 class GooglePages(page_module
.Page
):
18 def __init__(self
, url
, page_set
, shared_page_state_class
,
19 name
='', credentials
=None):
20 super(GooglePages
, self
).__init
__(
21 url
=url
, page_set
=page_set
, name
=name
,
22 credentials_path
='data/credentials.json',
23 shared_page_state_class
=shared_page_state_class
)
24 self
.archive_data_file
= 'data/google_pages.json'
25 self
.credentials
= credentials
26 self
.script_to_evaluate_on_commit
= _DeterministicPerformanceCounters()
29 class GmailPage(GooglePages
):
30 def __init__(self
, page_set
,
31 shared_page_state_class
=shared_page_state
.SharedPageState
):
32 super(GmailPage
, self
).__init
__(
33 url
='https://mail.google.com/mail/',
35 shared_page_state_class
=shared_page_state_class
)
37 def RunNavigateSteps(self
, action_runner
):
38 google_login
.LoginGoogleAccount(action_runner
, 'google',
39 self
.credentials_path
)
40 super(GmailPage
, self
).RunNavigateSteps(action_runner
)
41 action_runner
.WaitForJavaScriptCondition(
42 'window.gmonkey !== undefined &&'
43 'document.getElementById("gb") !== null')
45 class GoogleDocPage(GooglePages
):
46 def __init__(self
, page_set
,
47 shared_page_state_class
=shared_page_state
.SharedPageState
):
48 super(GoogleDocPage
, self
).__init
__(
49 # pylint: disable=C0301
50 url
='https://docs.google.com/document/d/1X-IKNjtEnx-WW5JIKRLsyhz5sbsat3mfTpAPUSX3_s4/view',
52 shared_page_state_class
=shared_page_state_class
)
54 def RunNavigateSteps(self
, action_runner
):
55 google_login
.LoginGoogleAccount(action_runner
, 'google',
56 self
.credentials_path
)
57 super(GoogleDocPage
, self
).RunNavigateSteps(action_runner
)
59 action_runner
.WaitForJavaScriptCondition(
60 'document.getElementsByClassName("kix-appview-editor").length')