Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: tools/telemetry/telemetry/core/chrome/cros_util.py

Issue 13836002: Fix navigation of chrome://oobe/login. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from telemetry.core import exceptions 5 from telemetry.core import exceptions
6 from telemetry.core import util 6 from telemetry.core import util
7 7
8 def _TabNotOobeScreen(browser_backend): 8 def _WebContentsNotOobe(browser_backend):
9 """Returns true if we're still on the oobe login screen. As a side-effect, 9 """Returns true if we're still on the oobe login screen. As a side-effect,
10 clicks the ok button on the user image selection screen""" 10 clicks the ok button on the user image selection screen."""
11 tab = browser_backend.tab_list_backend.Get(0, None) 11 oobe = browser_backend.misc_web_contents_backend.GetOobe()
12 if not (tab and tab.url and tab.url == 'chrome://oobe/login'): 12 if oobe is None:
13 return True 13 return True
14 try: 14 try:
15 tab.ExecuteJavaScript(""" 15 oobe.EvaluateJavaScript("""
16 var ok = document.getElementById("ok-button"); 16 var ok = document.getElementById("ok-button");
17 if (ok) { 17 if (ok) {
18 ok.click(); 18 ok.click();
19 } 19 }
20 """) 20 """)
21 except (exceptions.TabCrashException): 21 except (exceptions.TabCrashException):
22 pass 22 pass
23 return False 23 return False
24 24
25 def _StartupWindow(browser_backend): 25 def _StartupWindow(browser_backend):
26 """Closes the startup window, which is an extension on official builds, 26 """Closes the startup window, which is an extension on official builds,
27 and a webpage on chromiumos""" 27 and a webpage on chromiumos"""
28 startup_window_ext_id = 'honijodknafkokifofgiaalefdiedpko' 28 startup_window_ext_id = 'honijodknafkokifofgiaalefdiedpko'
29 return (browser_backend.extension_dict_backend[startup_window_ext_id] 29 return (browser_backend.extension_dict_backend[startup_window_ext_id]
30 if startup_window_ext_id in browser_backend.extension_dict_backend 30 if startup_window_ext_id in browser_backend.extension_dict_backend
31 else browser_backend.tab_list_backend.Get(0, None)) 31 else browser_backend.tab_list_backend.Get(0, None))
32 32
33 def NavigateLogin(browser_backend): 33 def NavigateLogin(browser_backend):
34 """Navigates through login screen""" 34 """Navigates through oobe login screen"""
35 # Wait for login screen to disappear. 35 # Wait to connect to oobe.
36 util.WaitFor(lambda: _TabNotOobeScreen(browser_backend), 20) 36 misc_wc = browser_backend.misc_web_contents_backend
37 util.WaitFor(lambda: misc_wc.GetOobe(), # pylint: disable=W0108
38 10)
39 # Dismiss the user image selection screen.
40 util.WaitFor(lambda: _WebContentsNotOobe(browser_backend), 15)
37 41
38 # Wait for the startup window, then close it. 42 # Wait for the startup window, then close it.
39 util.WaitFor(lambda: _StartupWindow(browser_backend) is not None, 20) 43 util.WaitFor(lambda: _StartupWindow(browser_backend) is not None, 20)
40 _StartupWindow(browser_backend).Close() 44 _StartupWindow(browser_backend).Close()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698