Ejemplo n.º 1
0
  def __init__(self, browser_backend, path, is_record_mode, webpagereplay_host,
               webpagereplay_http_port, webpagereplay_https_port):
    self._browser_backend = browser_backend
    self._forwarder = None
    self._web_page_replay = None
    self._is_record_mode = is_record_mode
    self._webpagereplay_host = webpagereplay_host
    self._webpagereplay_http_port = webpagereplay_http_port
    self._webpagereplay_https_port = webpagereplay_https_port

    # Note: This can cause flake if server doesn't shut down properly and keeps
    # ports tied up. See crbug.com/157459.
    self._forwarder = browser_backend.CreateForwarder(
        util.PortPair(self._webpagereplay_http_port,
                      self._webpagereplay_http_port),
        util.PortPair(self._webpagereplay_https_port,
                      self._webpagereplay_https_port))

    options = []
    if self._is_record_mode:
      options.append('--record')
    if not browser_backend.options.wpr_make_javascript_deterministic:
      options.append('--inject_scripts=')
    self._web_page_replay = webpagereplay.ReplayServer(
        path,
        self._webpagereplay_host,
        self._webpagereplay_http_port,
        self._webpagereplay_https_port,
        options)
    self._web_page_replay.StartServer()
Ejemplo n.º 2
0
    def __init__(self, browser_backend, path, is_record_mode, is_append_mode,
                 make_javascript_deterministic):
        self._browser_backend = browser_backend
        self._forwarder = None
        self._web_page_replay = None
        self._is_record_mode = is_record_mode
        self._is_append_mode = is_append_mode

        self._forwarder = browser_backend.CreateForwarder(
            util.PortPair(browser_backend.webpagereplay_local_http_port,
                          browser_backend.webpagereplay_remote_http_port),
            util.PortPair(browser_backend.webpagereplay_local_https_port,
                          browser_backend.webpagereplay_remote_https_port))

        wpr_args = browser_backend.browser_options.extra_wpr_args
        if self._is_record_mode:
            if self._is_append_mode:
                wpr_args.append('--append')
            else:
                wpr_args.append('--record')
        if not make_javascript_deterministic:
            wpr_args.append('--inject_scripts=')
        browser_backend.AddReplayServerOptions(wpr_args)
        self._web_page_replay = webpagereplay.ReplayServer(
            path, browser_backend.WEBPAGEREPLAY_HOST,
            browser_backend.webpagereplay_local_http_port,
            browser_backend.webpagereplay_local_https_port, wpr_args)
        # Remove --no-dns_forwarding if it wasn't explicitly requested by backend.
        if '--no-dns_forwarding' not in wpr_args:
            self._web_page_replay.replay_options.remove('--no-dns_forwarding')
        self._web_page_replay.StartServer()
Ejemplo n.º 3
0
  def __init__(self, browser_backend, path, is_record_mode, webpagereplay_host,
               webpagereplay_local_http_port, webpagereplay_local_https_port,
               webpagereplay_remote_http_port, webpagereplay_remote_https_port):
    self._browser_backend = browser_backend
    self._forwarder = None
    self._web_page_replay = None
    self._is_record_mode = is_record_mode
    self._webpagereplay_host = webpagereplay_host
    self._webpagereplay_local_http_port = webpagereplay_local_http_port
    self._webpagereplay_local_https_port = webpagereplay_local_https_port
    self._webpagereplay_remote_http_port = webpagereplay_remote_http_port
    self._webpagereplay_remote_https_port = webpagereplay_remote_https_port

    self._forwarder = browser_backend.CreateForwarder(
        util.PortPair(self._webpagereplay_local_http_port,
                      self._webpagereplay_remote_http_port),
        util.PortPair(self._webpagereplay_local_https_port,
                      self._webpagereplay_remote_https_port))

    options = browser_backend.options.extra_wpr_args
    if self._is_record_mode:
      options.append('--record')
    if not browser_backend.options.wpr_make_javascript_deterministic:
      options.append('--inject_scripts=')
    self._web_page_replay = webpagereplay.ReplayServer(
        path,
        self._webpagereplay_host,
        self._webpagereplay_local_http_port,
        self._webpagereplay_local_https_port,
        options)
    self._web_page_replay.StartServer()
Ejemplo n.º 4
0
 def RunTestWithUrl(self, url):
     """Navigates browser to given URL and takes native memory snapshot."""
     replay_options = None
     hostname = urlparse(url).hostname
     archive_path = os.path.join(self.DATA_PATH, hostname + '.wpr')
     with webpagereplay.ReplayServer(archive_path, replay_options):
         self.NavigateToURL(url)
     snapshot = self._remote_inspector_client.GetProcessMemoryDistribution()
     logging.info('Got snapshot for url: %s' % url)
     self.PrintTestResult(hostname, snapshot)
Ejemplo n.º 5
0
 def ReplayServer(cls, archive_path):
   """Create a replay server."""
   # Inject customized scripts for Google webapps.
   # See the javascript file for details.
   scripts = cls.Path('scripts')
   if not os.path.exists(scripts):
     raise IOError('Injected scripts %s not found.' % scripts)
   replay_options = ['--inject_scripts', scripts]
   if 'WPR_RECORD' in os.environ:
     replay_options.append('--append')
   return webpagereplay.ReplayServer(archive_path, replay_options)
Ejemplo n.º 6
0
    def __init__(self, browser_backend, path, is_record_mode):
        self._browser_backend = browser_backend
        self._forwarder = None
        self._web_page_replay = None
        self._is_record_mode = is_record_mode

        self._forwarder = browser_backend.CreateForwarder(
            webpagereplay.HTTP_PORT, webpagereplay.HTTPS_PORT)

        options = []
        if self._is_record_mode:
            options.append('--record')
        if not browser_backend.options.wpr_make_javascript_deterministic:
            options.append('--inject_scripts=/dev/null')
        self._web_page_replay = webpagereplay.ReplayServer(path, options)
        self._web_page_replay.StartServer()
Ejemplo n.º 7
0
    def __init__(self, browser_backend, path, is_record_mode):
        self._browser_backend = browser_backend
        self._http_forwarder = None
        self._https_forwarder = None
        self._web_page_replay = None
        self._is_record_mode = is_record_mode

        self._http_forwarder = browser_backend.CreateForwarder(
            webpagereplay.HTTP_PORT)
        self._https_forwarder = browser_backend.CreateForwarder(
            webpagereplay.HTTPS_PORT)

        options = []
        if self._is_record_mode:
            options.append('--record')
        self._web_page_replay = webpagereplay.ReplayServer(path, options)
        self._web_page_replay.StartServer()
Ejemplo n.º 8
0
    def __init__(self, browser_backend, path, is_record_mode, is_append_mode,
                 make_javascript_deterministic):
        self._browser_backend = browser_backend
        self._forwarder = None
        self._web_page_replay = None
        self._is_record_mode = is_record_mode
        self._is_append_mode = is_append_mode

        wpr_args = browser_backend.browser_options.extra_wpr_args
        if self._is_record_mode:
            if self._is_append_mode:
                wpr_args.append('--append')
            else:
                wpr_args.append('--record')
        if not make_javascript_deterministic:
            wpr_args.append('--inject_scripts=')
        browser_backend.AddReplayServerOptions(wpr_args)
        self._web_page_replay = webpagereplay.ReplayServer(
            path, self._browser_backend.forwarder_factory.host_ip,
            browser_backend.wpr_port_pairs.dns.local_port
            if browser_backend.wpr_port_pairs.dns else 0,
            browser_backend.wpr_port_pairs.http.local_port,
            browser_backend.wpr_port_pairs.https.local_port, wpr_args)
        # Remove --no-dns_forwarding if it wasn't explicitly requested by backend.
        if '--no-dns_forwarding' not in wpr_args:
            self._web_page_replay.replay_options.remove('--no-dns_forwarding')
        self._web_page_replay.StartServer()

        browser_backend.wpr_port_pairs = forwarders.PortPairs(
            http=forwarders.PortPair(
                self._web_page_replay.http_port,
                browser_backend.wpr_port_pairs.http.remote_port
                or self._web_page_replay.http_port),
            https=forwarders.PortPair(
                self._web_page_replay.https_port,
                browser_backend.wpr_port_pairs.https.remote_port
                or self._web_page_replay.https_port),
            dns=forwarders.PortPair(
                self._web_page_replay.dns_port,
                browser_backend.wpr_port_pairs.dns.remote_port
                or self._web_page_replay.dns_port)
            if browser_backend.wpr_port_pairs.dns else None)

        self._forwarder = browser_backend.forwarder_factory.Create(
            browser_backend.wpr_port_pairs)