Commit de955514 authored by wuhu's avatar wuhu Committed by Commit bot

Revert of Removing browser.Start() and instead starts the browser at the point...

Revert of Removing browser.Start() and instead starts the browser at the point of creation. (patchset #6 id:120001 of https://codereview.chromium.org/565803002/)

Reason for revert:
investigate build error

Original issue's description:
> Removing browser.Start() and instead starts the browser at the point of creation.
>
> BUG=412126
>
> Committed: https://crrev.com/01c68e8765254d9971296b291ff718b4f6af3004
> Cr-Commit-Position: refs/heads/master@{#295591}
>
> Committed: https://crrev.com/74c6ef17a08754abadb6fb64da14249898285fa8
> Cr-Commit-Position: refs/heads/master@{#296107}

TBR=nednguyen@google.com,slamm@chromium.org,slamm@google.com
NOTREECHECKS=true
NOTRY=true
BUG=412126

Review URL: https://codereview.chromium.org/601473002

Cr-Commit-Position: refs/heads/master@{#296247}
parent 14fd659a
......@@ -113,12 +113,7 @@ class PossibleAndroidBrowser(possible_browser.PossibleBrowser):
output_profile_path=self.finder_options.output_profile_path,
extensions_to_load=self.finder_options.extensions_to_load,
target_arch=self.finder_options.target_arch)
b = browser.Browser(backend,
self._platform_backend,
self._archive_path,
self._append_to_existing_wpr,
self._make_javascript_deterministic,
self._credentials_path)
b = browser.Browser(backend, self._platform_backend)
return b
def SupportsOptions(self, finder_options):
......
......@@ -50,12 +50,7 @@ class PossibleCrOSBrowser(possible_browser.PossibleBrowser):
if browser_options.create_browser_with_oobe:
return cros_browser_with_oobe.CrOSBrowserWithOOBE(
backend, self._platform_backend)
return browser.Browser(backend,
self._platform_backend,
self._archive_path,
self._append_to_existing_wpr,
self._make_javascript_deterministic,
self._credentials_path)
return browser.Browser(backend, self._platform_backend)
def SupportsOptions(self, finder_options):
if (len(finder_options.extensions_to_load) != 0) and self._is_guest:
......
......@@ -8,16 +8,9 @@ from telemetry.core.backends.chrome import cros_browser_backend
class CrOSBrowserWithOOBE(browser.Browser):
"""Cros-specific browser."""
def __init__(self, backend, platform_backend, archive_path,
append_to_existing_wpr, make_javascript_deterministic,
credentials_path):
def __init__(self, backend, platform_backend):
assert isinstance(backend, cros_browser_backend.CrOSBrowserBackend)
super(CrOSBrowserWithOOBE, self).__init__(backend,
platform_backend,
archive_path,
append_to_existing_wpr,
make_javascript_deterministic,
credentials_path)
super(CrOSBrowserWithOOBE, self).__init__(backend, platform_backend)
@property
def oobe(self):
......
......@@ -60,12 +60,7 @@ class PossibleDesktopBrowser(possible_browser.PossibleBrowser):
self._flash_path, self._is_content_shell, self._browser_directory,
output_profile_path=self.finder_options.output_profile_path,
extensions_to_load=self.finder_options.extensions_to_load)
return browser.Browser(backend,
self._platform_backend,
self._archive_path,
self._append_to_existing_wpr,
self._make_javascript_deterministic,
self._credentials_path)
return browser.Browser(backend, self._platform_backend)
def SupportsOptions(self, finder_options):
if (len(finder_options.extensions_to_load) != 0) and self._is_content_shell:
......
......@@ -35,12 +35,7 @@ class PossibleIOSBrowser(possible_browser.PossibleBrowser):
def Create(self):
backend = ios_browser_backend.IosBrowserBackend(
self.finder_options.browser_options)
return browser.Browser(backend,
self._platform_backend,
self._archive_path,
self._append_to_existing_wpr,
self._make_javascript_deterministic,
self._credentials_path)
return browser.Browser(backend, self._platform_backend)
def SupportsOptions(self, finder_options):
#TODO(baxley): Implement me.
......
......@@ -49,12 +49,7 @@ class PossibleWebDriverBrowser(possible_browser.PossibleBrowser):
def Create(self):
self._InitPlatformIfNeeded()
backend = self.CreateWebDriverBackend(self._platform_backend)
return browser.Browser(backend,
self._platform_backend,
self._archive_path,
self._append_to_existing_wpr,
self._make_javascript_deterministic,
self._credentials_path)
return browser.Browser(backend, self._platform_backend)
def SupportsOptions(self, finder_options):
if len(finder_options.extensions_to_load) != 0:
......
......@@ -27,9 +27,7 @@ class Browser(object):
with browser_to_create.Create() as browser:
... do all your operations on browser here
"""
def __init__(self, backend, platform_backend, archive_path,
append_to_existing_wpr, make_javascript_deterministic,
credentials_path):
def __init__(self, backend, platform_backend):
assert platform_backend.platform != None
self._browser_backend = backend
......@@ -38,29 +36,10 @@ class Browser(object):
self._local_server_controller = local_server.LocalServerController(backend)
self._tabs = tab_list.TabList(backend.tab_list_backend)
self.credentials = browser_credentials.BrowserCredentials()
self.credentials.credentials_path = credentials_path
self._platform_backend.DidCreateBrowser(self, self._browser_backend)
self.SetReplayArchivePath(archive_path,
append_to_existing_wpr,
make_javascript_deterministic)
browser_options = self._browser_backend.browser_options
self.platform.FlushDnsCache()
if browser_options.clear_sytem_cache_for_browser_and_profile_on_start:
if self.platform.CanFlushIndividualFilesFromSystemCache():
self.platform.FlushSystemCacheForDirectory(
self._browser_backend.profile_directory)
self.platform.FlushSystemCacheForDirectory(
self._browser_backend.browser_directory)
else:
self.platform.FlushEntireSystemCache()
self._browser_backend.SetBrowser(self)
self._browser_backend.Start()
self._platform_backend.DidStartBrowser(self, self._browser_backend)
def __enter__(self):
self.Start()
return self
def __exit__(self, *args):
......@@ -251,6 +230,22 @@ class Browser(object):
del result['ProcessCount']
return result
def Start(self):
browser_options = self._browser_backend.browser_options
self.platform.FlushDnsCache()
if browser_options.clear_sytem_cache_for_browser_and_profile_on_start:
if self.platform.CanFlushIndividualFilesFromSystemCache():
self.platform.FlushSystemCacheForDirectory(
self._browser_backend.profile_directory)
self.platform.FlushSystemCacheForDirectory(
self._browser_backend.browser_directory)
else:
self.platform.FlushEntireSystemCache()
self._browser_backend.SetBrowser(self)
self._browser_backend.Start()
self._platform_backend.DidStartBrowser(self, self._browser_backend)
def Close(self):
"""Closes this browser."""
if self._browser_backend.IsBrowserRunning():
......
......@@ -67,11 +67,11 @@ class BrowserCredentials(object):
self._backends[credentials_type].LoginNoLongerNeeded(tab)
@property
def credentials_path(self): # pylint: disable=E0202
def credentials_path(self):
return self._credentials_path
@credentials_path.setter
def credentials_path(self, credentials_path): # pylint: disable=E0202
def credentials_path(self, credentials_path):
self._credentials_path = credentials_path
self._RebuildCredentials()
......
......@@ -32,6 +32,7 @@ class ExtensionTest(unittest.TestCase):
# May not find a browser that supports extensions.
return False
self._browser = browser_to_create.Create()
self._browser.Start()
self._extension = self._browser.extensions[load_extension]
self._extension_id = load_extension.extension_id
self.assertTrue(self._extension)
......@@ -123,6 +124,7 @@ class MultipleExtensionTest(unittest.TestCase):
# May not find a browser that supports extensions.
if browser_to_create:
self._browser = browser_to_create.Create()
self._browser.Start()
def tearDown(self):
if self._browser:
......
......@@ -18,10 +18,6 @@ class PossibleBrowser(object):
self._supports_tab_control = supports_tab_control
self._platform = None
self._platform_backend = None
self._archive_path = None
self._append_to_existing_wpr = False
self._make_javascript_deterministic = True
self._credentials_path = None
def __repr__(self):
return 'PossibleBrowser(browser_type=%s)' % self.browser_type
......@@ -69,12 +65,3 @@ class PossibleBrowser(object):
def last_modification_time(self):
return -1
def SetReplayArchivePath(self, archive_path, append_to_existing_wpr,
make_javascript_deterministic):
self._archive_path = archive_path
self._append_to_existing_wpr = append_to_existing_wpr
self._make_javascript_deterministic = make_javascript_deterministic
def SetCredentialsPath(self, credentials_path):
self._credentials_path = credentials_path
......@@ -45,14 +45,17 @@ class _RunState(object):
# Create a browser.
if not self.browser:
test.CustomizeBrowserOptionsForSinglePage(page, finder_options)
possible_browser.SetReplayArchivePath(archive_path,
self.browser = possible_browser.Create()
self.browser.credentials.credentials_path = credentials_path
# Set up WPR path on the new browser.
self.browser.SetReplayArchivePath(archive_path,
self._append_to_existing_wpr,
page_set.make_javascript_deterministic)
possible_browser.SetCredentialsPath(credentials_path)
self._last_archive_path = page.archive_path
test.WillStartBrowser(possible_browser.platform)
self.browser = possible_browser.Create()
self.browser.Start()
test.DidStartBrowser(self.browser)
if self._first_browser:
......
......@@ -22,6 +22,7 @@ class BrowserTestCase(unittest.TestCase):
cls._browser = None
try:
cls._browser = browser_to_create.Create()
cls._browser.Start()
except:
cls.tearDownClass()
raise
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment