Пример #1
0
    def __init__(self, platform_backend, supports_tab_control,
                 supports_extensions, browser_options, output_profile_path,
                 extensions_to_load):
        super(ChromeBrowserBackend,
              self).__init__(platform_backend=platform_backend,
                             supports_extensions=supports_extensions,
                             browser_options=browser_options,
                             tab_list_backend=tab_list_backend.TabListBackend)
        self._port = None

        self._supports_tab_control = supports_tab_control
        self._devtools_client = None
        self._system_info_backend = None

        self._output_profile_path = output_profile_path
        self._extensions_to_load = extensions_to_load

        if browser_options.netsim:
            self.wpr_port_pairs = forwarders.PortPairs(
                http=forwarders.PortPair(80, 80),
                https=forwarders.PortPair(443, 443),
                dns=forwarders.PortPair(53, 53))
        else:
            self.wpr_port_pairs = forwarders.PortPairs(
                http=forwarders.PortPair(0, 0),
                https=forwarders.PortPair(0, 0),
                dns=None)

        if (self.browser_options.dont_override_profile
                and not options_for_unittests.AreSet()):
            sys.stderr.write(
                'Warning: Not overriding profile. This can cause '
                'unexpected effects due to profile-specific settings, '
                'such as about:flags settings, cookies, and '
                'extensions.\n')
Пример #2
0
    def __init__(self, project):
        self._project = project
        self._browser = None
        self._tab = None
        self._server = None

        if telemetry == None:
            raise Exception(
                'Not supported: trace-viewer must be inside a chrome checkout for this to work.'
            )

        # If run in the context of the telemetry test runner, use
        # telemetry's browser options instead.
        if telemetry_options_for_unittests.AreSet():
            finder_options = telemetry_options_for_unittests.GetCopy()
        else:
            finder_options = browser_options.BrowserFinderOptions()
            parser = finder_options.CreateParser('telemetry_perf_test.py')
            from tvcm import test_runner
            finder_options, _ = parser.parse_args(
                ['--browser', test_runner.BROWSER_TYPE_TO_USE])

        finder_options.browser_options.warn_if_no_flash = False
        browser_to_create = browser_finder.FindBrowser(finder_options)
        if not browser_to_create:
            raise Exception('Failed to find the specified browser. ' +
                            ' Its binary is probably broken.')

        self._browser = browser_to_create.Create()
        self._tab = None

        try:
            self._browser.Start()
            self._tab = self._browser.tabs[0]

            # Prevent the project from being mutated from here on out.
            project.Freeze()

            self._server = _LocalDevServer(self._project)
            self._browser.StartLocalServer(self._server)

        except:
            self._browser.Close()
            raise