ulan | 38fc6e6 | 2015-07-23 15:27:37 | [diff] [blame] | 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. |
| 4 | |
| 5 | from page_sets.login_helpers import google_login |
| 6 | |
| 7 | from telemetry.page import page as page_module |
| 8 | from telemetry.page import shared_page_state |
| 9 | |
| 10 | import os |
| 11 | |
| 12 | def _DeterministicPerformanceCounters(): |
| 13 | with open(os.path.join(os.path.dirname(__file__), |
| 14 | 'deterministic_performance_counters.js')) as f: |
| 15 | return f.read() |
| 16 | |
| 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) |
ulan | 38fc6e6 | 2015-07-23 15:27:37 | [diff] [blame] | 24 | self.credentials = credentials |
| 25 | self.script_to_evaluate_on_commit = _DeterministicPerformanceCounters() |
| 26 | |
| 27 | |
| 28 | class GmailPage(GooglePages): |
| 29 | def __init__(self, page_set, |
| 30 | shared_page_state_class=shared_page_state.SharedPageState): |
| 31 | super(GmailPage, self).__init__( |
| 32 | url='https://mail.google.com/mail/', |
| 33 | page_set=page_set, |
ashleymarie | bd6683a | 2017-06-05 20:44:20 | [diff] [blame] | 34 | shared_page_state_class=shared_page_state_class, |
| 35 | name='https://mail.google.com/mail/') |
ulan | 38fc6e6 | 2015-07-23 15:27:37 | [diff] [blame] | 36 | |
| 37 | def RunNavigateSteps(self, action_runner): |
| 38 | google_login.LoginGoogleAccount(action_runner, 'google', |
| 39 | self.credentials_path) |
| 40 | super(GmailPage, self).RunNavigateSteps(action_runner) |
perezju | d42421be | 2017-02-28 09:40:20 | [diff] [blame] | 41 | action_runner.WaitForJavaScriptCondition( |
ulan | 38fc6e6 | 2015-07-23 15:27:37 | [diff] [blame] | 42 | 'window.gmonkey !== undefined &&' |
| 43 | 'document.getElementById("gb") !== null') |