| OLD | NEW |
| 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS 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 import logging, os, stat, time, utils | 5 import logging, os, stat, time, utils |
| 6 from autotest_lib.client.bin import chromeos_constants, site_cryptohome | 6 from autotest_lib.client.bin import chromeos_constants, site_cryptohome |
| 7 from autotest_lib.client.bin import site_login, test | 7 from autotest_lib.client.bin import site_login, test |
| 8 from autotest_lib.client.common_lib import error, site_httpd, site_ui | 8 from autotest_lib.client.common_lib import error, site_httpd, site_ui |
| 9 | 9 |
| 10 def respond_with_cookies(handler, url_args): | 10 def respond_with_cookies(handler, url_args): |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 def cleanup(self): | 49 def cleanup(self): |
| 50 self._testServer.stop() | 50 self._testServer.stop() |
| 51 | 51 |
| 52 | 52 |
| 53 def run_once(self, script = 'autox_script.json', timeout = 10): | 53 def run_once(self, script = 'autox_script.json', timeout = 10): |
| 54 logged_in = site_login.logged_in() | 54 logged_in = site_login.logged_in() |
| 55 | 55 |
| 56 if not logged_in: | 56 if not logged_in: |
| 57 # Test account information embedded into json file. | 57 # Test account information embedded into json file. |
| 58 if not site_login.attempt_login(self, script): | 58 site_login.attempt_login(self, script) |
| 59 raise error.TestError('Could not login') | |
| 60 | 59 |
| 61 # Get Default/Cookies mtime. | 60 # Get Default/Cookies mtime. |
| 62 cookies_info = os.stat(chromeos_constants.LOGIN_PROFILE + '/Cookies') | 61 cookies_info = os.stat(chromeos_constants.LOGIN_PROFILE + '/Cookies') |
| 63 cookies_mtime = cookies_info[stat.ST_MTIME] | 62 cookies_mtime = cookies_info[stat.ST_MTIME] |
| 64 | 63 |
| 65 # "crash" chrome. | 64 # "crash" chrome. |
| 65 site_login.wait_for_initial_chrome_window() |
| 66 site_login.nuke_process_by_name(chromeos_constants.BROWSER, | 66 site_login.nuke_process_by_name(chromeos_constants.BROWSER, |
| 67 with_prejudice = True) | 67 with_prejudice = True) |
| 68 site_login.wait_for_browser() | 68 site_login.wait_for_browser() |
| 69 | 69 |
| 70 # Navigate to site that leaves cookies. | 70 # Navigate to site that leaves cookies. |
| 71 latch = self._testServer.add_wait_url(self._wait_path) | 71 latch = self._testServer.add_wait_url(self._wait_path) |
| 72 cookie_fetch_args = ("--user-data-dir=" + | 72 cookie_fetch_args = ("--user-data-dir=" + |
| 73 chromeos_constants.USER_DATA_DIR + ' ' + | 73 chromeos_constants.USER_DATA_DIR + ' ' + |
| 74 self._test_url) | 74 self._test_url) |
| 75 session = site_ui.ChromeSession(args=cookie_fetch_args, | 75 session = site_ui.ChromeSession(args=cookie_fetch_args, |
| 76 clean_state=False) | 76 clean_state=False) |
| 77 logging.debug('Chrome session started.') | 77 logging.debug('Chrome session started.') |
| 78 latch.wait(timeout) | 78 latch.wait(timeout) |
| 79 | 79 |
| 80 # Ensure chrome writes state to disk. | 80 # Ensure chrome writes state to disk. |
| 81 site_login.attempt_logout() | 81 site_login.attempt_logout() |
| 82 site_login.wait_for_browser() | 82 site_login.attempt_login(self, script) |
| 83 if not site_login.attempt_login(self, script): | |
| 84 raise error.TestError('Could not log back in') | |
| 85 | 83 |
| 86 if not latch.is_set(): | 84 if not latch.is_set(): |
| 87 raise error.TestError('Never received callback from browser.') | 85 raise error.TestError('Never received callback from browser.') |
| 88 | 86 |
| 89 # Check mtime of Default/Cookies. If changed, KABLOOEY. | 87 # Check mtime of Default/Cookies. If changed, KABLOOEY. |
| 90 self.__wait_for_login_profile() | 88 self.__wait_for_login_profile() |
| 91 cookies_info = os.stat(chromeos_constants.LOGIN_PROFILE + '/Cookies') | 89 cookies_info = os.stat(chromeos_constants.LOGIN_PROFILE + '/Cookies') |
| 92 if cookies_mtime != cookies_info[stat.ST_MTIME]: | 90 if cookies_mtime != cookies_info[stat.ST_MTIME]: |
| 93 raise error.TestFail('Cookies in Default profile changed!') | 91 raise error.TestFail('Cookies in Default profile changed!') |
| 94 | 92 |
| 95 # If we started logged out, log back out. | 93 # If we started logged out, log back out. |
| 96 if not logged_in: | 94 if not logged_in: |
| 97 site_login.attempt_logout() | 95 site_login.attempt_logout() |
| OLD | NEW |