def RecordUrlNavigation( cls, url, connection, chrome_metadata, categories, timeout_seconds=devtools_monitor.DEFAULT_TIMEOUT_SECONDS, stop_delay_multiplier=0): """Create a loading trace by using controller to fetch url. Args: url: (str) url to fetch. connection: An opened devtools connection. chrome_metadata: Dictionary of chrome metadata. categories: as in tracing_track.TracingTrack timeout_seconds: monitoring connection timeout in seconds. stop_delay_multiplier: How long to wait after page load completed before tearing down, relative to the time it took to reach the page load to complete. Returns: LoadingTrace instance. """ page = page_track.PageTrack(connection) request = request_track.RequestTrack(connection) trace = tracing_track.TracingTrack(connection, categories) start_date_str = datetime.datetime.utcnow().isoformat() seconds_since_epoch = time.time() connection.MonitorUrl(url, timeout_seconds=timeout_seconds, stop_delay_multiplier=stop_delay_multiplier) trace = cls(url, chrome_metadata, page, request, trace) trace.metadata.update(date=start_date_str, seconds_since_epoch=seconds_since_epoch) return trace
def _EventsFromRawEvents(cls, raw_events): track = tracing_track.TracingTrack(None, clovis_constants.DEFAULT_CATEGORIES) track.Handle('Tracing.dataCollected', {'params': { 'value': raw_events }}) return track.GetEvents()
def LoadingTraceFromEvents(requests, page_events=None, trace_events=None): """Returns a LoadingTrace instance from various events.""" request = FakeRequestTrack(requests) page_event_track = FakePageTrack(page_events if page_events else []) if trace_events is not None: track = tracing_track.TracingTrack(None, clovis_constants.DEFAULT_CATEGORIES) track.Handle('Tracing.dataCollected', {'params': { 'value': [e for e in trace_events] }}) else: track = None return loading_trace.LoadingTrace(None, None, page_event_track, request, track)
def setUp(self): self.track = tracing_track.TracingTrack( None, clovis_constants.DEFAULT_CATEGORIES)