<commit_before># Copyright 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import logging

from py_utils import cloud_storage
from py_utils import exc_util

from telemetry.core import exceptions
from telemetry import decorators
from telemetry.internal import app
from telemetry.internal.backends import browser_backend
from telemetry.internal.backends.chrome_inspector import tracing_backend
from telemetry.internal.browser import extension_dict
from telemetry.internal.browser import tab_list
from telemetry.internal.browser import web_contents
from telemetry.testing import test_utils


class Browser(app.App):
  """A running browser instance that can be controlled in a limited way.

  To create a browser instance, use browser_finder.FindBrowser, e.g:

    possible_browser = browser_finder.FindBrowser(finder_options)
    with possible_browser.BrowserSession(
        finder_options.browser_options) as browser:
      # Do all your operations on browser here.

  See telemetry.internal.browser.possible_browser for more details and use
  cases.
  """
  def __init__(self, backend, platform_backend, startup_args,
               find_existing=False):
    super(Browser, self).__init__(app_backend=backend,
                                  platform_backend=platform_backend)
    try:
      self._browser_backend = backend
      self._platform_backend = platform_backend
      self._tabs = tab_list.TabList(backend.tab_list_backend)
      self._browser_backend.SetBrowser(self)
      if find_existing:
        self._browser_backend.BindDevToolsClient()
      else:
        self._browser_backend.Start(startup_args)
      self._LogBrowserInfo()
    except Exception:
      self.DumpStateUponFailure()
      self.Close()
      raise

  @property
  def browser_type(self):
    return self.app_type
<commit_msg>[Telemetry] Expose browser startup args<commit_after># Copyright 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import logging

from py_utils import cloud_storage
from py_utils import exc_util

from telemetry.core import exceptions
from telemetry import decorators
from telemetry.internal import app
from telemetry.internal.backends import browser_backend
from telemetry.internal.backends.chrome_inspector import tracing_backend
from telemetry.internal.browser import extension_dict
from telemetry.internal.browser import tab_list
from telemetry.internal.browser import web_contents
from telemetry.testing import test_utils


class Browser(app.App):
  """A running browser instance that can be controlled in a limited way.

  To create a browser instance, use browser_finder.FindBrowser, e.g:

    possible_browser = browser_finder.FindBrowser(finder_options)
    with possible_browser.BrowserSession(
        finder_options.browser_options) as browser:
      # Do all your operations on browser here.

  See telemetry.internal.browser.possible_browser for more details and use
  cases.
  """
  def __init__(self, backend, platform_backend, startup_args,
               find_existing=False):
    super(Browser, self).__init__(app_backend=backend,
                                  platform_backend=platform_backend)
    try:
      self._browser_backend = backend
      self._platform_backend = platform_backend
      self._startup_args = startup_args
      self._tabs = tab_list.TabList(backend.tab_list_backend)
      self._browser_backend.SetBrowser(self)
      if find_existing:
        self._browser_backend.BindDevToolsClient()
      else:
        self._browser_backend.Start(startup_args)
      self._LogBrowserInfo()
    except Exception:
      self.DumpStateUponFailure()
      self.Close()
      raise

  @property
  def browser_type(self):
    return self.app_type

  @property
  def startup_args(self):
    return self._startup_args

{'fraction_non_alphanumeric': 0.058823529411764705, 'fraction_numerical': 0.002019691996970462, 'mean_word_length': 3.855392156862745, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3099799', 'n_tokens_mistral': 1066, 'n_tokens_neox': 1033, 'n_words': 313}