Esempio n. 1
0
  def SetUpEnvironment(self, browser_options):
    super(PossibleAndroidBrowser, self).SetUpEnvironment(browser_options)
    self._platform_backend.DismissCrashDialogIfNeeded()
    device = self._platform_backend.device
    startup_args = self.GetBrowserStartupArgs(self._browser_options)
    device.adb.Logcat(clear=True)

    # use legacy commandline path if in compatibility mode
    self._flag_changer = flag_changer.FlagChanger(
        device, self._backend_settings.command_line_name, use_legacy_path=
        compat_mode_options.LEGACY_COMMAND_LINE_PATH in
        browser_options.compatibility_mode)
    self._flag_changer.ReplaceFlags(startup_args, log_flags=False)
    formatted_args = format_for_logging.ShellFormat(
        startup_args, trim=browser_options.trim_logs)
    logging.info('Flags set on device were %s', formatted_args)
    # Stop any existing browser found already running on the device. This is
    # done *after* setting the command line flags, in case some other Android
    # process manages to trigger Chrome's startup before we do.
    self._platform_backend.StopApplication(self._backend_settings.package)
    self._SetupProfile()

    # Remove any old crash dumps
    self._platform_backend.device.RemovePath(
        self._platform_backend.GetDumpLocation(self._backend_settings.package),
        recursive=True, force=True)
Esempio n. 2
0
 def testShellFormat_Trim_UsesCopyAndSmokeTest(self):
   COMMAND = ['./chrome', '--force-fieldtrials=FeatureThatIsVerbose',
              '--blahblah']
   command = list(COMMAND)
   formatted_command = format_for_logging.ShellFormat(command, trim=True)
   self.assertEqual(command, COMMAND, 'logging command should not edit input')
   self.assertIn('chrome', formatted_command)
   self.assertIn('blahblah', formatted_command)
Esempio n. 3
0
    def LogStartCommand(self, command, env):
        """Log the command used to start Chrome.

    In order to keep the length of logs down (see crbug.com/943650),
    we sometimes trim the start command depending on browser_options.
    The command may change between runs, but usually in innocuous ways like
    --user-data-dir changes to a new temporary directory. Some benchmarks
    do use different startup arguments for different stories, but this is
    discouraged. This method could be changed to print arguments that are
    different since the last run if need be.
    """
        formatted_command = format_for_logging.ShellFormat(
            command, trim=self.browser_options.trim_logs)
        logging.info('Starting Chrome: %s\n', formatted_command)
        if not self.browser_options.trim_logs:
            logging.info('Chrome Env: %s', env)
Esempio n. 4
0
    def Start(self, startup_args):
        self._cri.OpenConnection()
        # Remove the stale file with the devtools port / browser target
        # prior to restarting chrome.
        self._cri.RmRF(self._GetDevToolsActivePortPath())

        # DesktopMinidumpFinder is meant for Linux/Mac/Windows, but since dumps are
        # pulled off the emulator/device onto the host, and we only support Linux
        # hosts, we can use it as-is.
        # TODO(https://crbug.com/994274): Rename this class when minidump
        # symbolization code is consolidated.
        self._dump_finder = desktop_minidump_finder.DesktopMinidumpFinder(
            self.browser.platform.GetOSName(),
            self.browser.platform.GetArchName())

        # Escape all commas in the startup arguments we pass to Chrome
        # because dbus-send delimits array elements by commas
        startup_args = [a.replace(',', '\\,') for a in startup_args]

        # Restart Chrome with the login extension and remote debugging.
        pid = self.GetPid()
        logging.info('Restarting Chrome (pid=%d) with remote port', pid)
        args = [
            'dbus-send', '--system', '--type=method_call',
            '--dest=org.chromium.SessionManager',
            '/org/chromium/SessionManager',
            'org.chromium.SessionManagerInterface.EnableChromeTesting',
            'boolean:true',
            'array:string:"%s"' % ','.join(startup_args), 'array:string:'
        ]
        formatted_args = format_for_logging.ShellFormat(
            args, trim=self.browser_options.trim_logs)
        logging.info('Starting Chrome: %s', formatted_args)
        self._cri.RunCmdOnDevice(args)

        # Wait for new chrome and oobe.
        py_utils.WaitFor(lambda: pid != self.GetPid(), 15)
        self.BindDevToolsClient()
        py_utils.WaitFor(lambda: self.oobe_exists, 30)

        if self.browser_options.auto_login:
            if self._is_guest:
                pid = self.GetPid()
                self.oobe.NavigateGuestLogin()
                # Guest browsing shuts down the current browser and launches an
                # incognito browser in a separate process, which we need to wait for.
                try:
                    py_utils.WaitFor(lambda: pid != self.GetPid(), 15)

                    # Also make sure we reconnect the devtools client to the new browser
                    # process. It's important to do this before waiting for _IsLoggedIn,
                    # otherwise the devtools connection check will still try to reach the
                    # older DevTools agent (and fail to do so).
                    self.BindDevToolsClient()
                except py_utils.TimeoutException:
                    self._RaiseOnLoginFailure(
                        'Failed to restart browser in guest mode (pid %d).' %
                        pid)

            elif self.browser_options.gaia_login:
                self.oobe.NavigateGaiaLogin(self._username, self._password)
            else:
                # Wait for few seconds(the time of password typing) to have mini ARC
                # container up and running. Default is 0.
                time.sleep(self.browser_options.login_delay)
                # crbug.com/976983.
                retries = 3
                while True:
                    try:
                        self.oobe.NavigateFakeLogin(
                            self._username, self._password, self._gaia_id,
                            not self.browser_options.disable_gaia_services)
                        break
                    except py_utils.TimeoutException:
                        logging.error('TimeoutException %d', retries)
                        retries -= 1
                        if not retries:
                            raise

            try:
                self._WaitForLogin()
            except py_utils.TimeoutException:
                self._RaiseOnLoginFailure(
                    'Timed out going through login screen. ' +
                    self._GetLoginStatus())

        logging.info('Browser is up!')
Esempio n. 5
0
    def Start(self, startup_args):
        # Remove the stale file with the devtools port / browser target
        # prior to restarting chrome.
        self._cri.RmRF(self._GetDevToolsActivePortPath())

        # Escape all commas in the startup arguments we pass to Chrome
        # because dbus-send delimits array elements by commas
        startup_args = [a.replace(',', '\\,') for a in startup_args]

        # Restart Chrome with the login extension and remote debugging.
        pid = self.GetPid()
        logging.info('Restarting Chrome (pid=%d) with remote port', pid)
        args = [
            'dbus-send', '--system', '--type=method_call',
            '--dest=org.chromium.SessionManager',
            '/org/chromium/SessionManager',
            'org.chromium.SessionManagerInterface.EnableChromeTesting',
            'boolean:true',
            'array:string:"%s"' % ','.join(startup_args), 'array:string:'
        ]
        formatted_args = format_for_logging.ShellFormat(
            args, trim=self.browser_options.trim_logs)
        logging.info('Starting Chrome: %s', formatted_args)
        self._cri.RunCmdOnDevice(args)

        # Wait for new chrome and oobe.
        py_utils.WaitFor(lambda: pid != self.GetPid(), 15)
        self.BindDevToolsClient()
        py_utils.WaitFor(lambda: self.oobe_exists, 30)

        if self.browser_options.auto_login:
            if self._is_guest:
                pid = self.GetPid()
                self.oobe.NavigateGuestLogin()
                # Guest browsing shuts down the current browser and launches an
                # incognito browser in a separate process, which we need to wait for.
                try:
                    py_utils.WaitFor(lambda: pid != self.GetPid(), 15)
                except py_utils.TimeoutException:
                    self._RaiseOnLoginFailure(
                        'Failed to restart browser in guest mode (pid %d).' %
                        pid)

            elif self.browser_options.gaia_login:
                self.oobe.NavigateGaiaLogin(self._username, self._password)
            else:
                # Wait for few seconds(the time of password typing) to have mini ARC
                # container up and running. Default is 0.
                time.sleep(self.browser_options.login_delay)
                self.oobe.NavigateFakeLogin(
                    self._username, self._password, self._gaia_id,
                    not self.browser_options.disable_gaia_services)

            try:
                self._WaitForLogin()
            except py_utils.TimeoutException:
                self._RaiseOnLoginFailure(
                    'Timed out going through login screen. ' +
                    self._GetLoginStatus())

        logging.info('Browser is up!')