@@ -268,48 +268,66 @@ def start_recording(self):
268268 self .send_command ('Profiler.enable' , {})
269269 self .send_command ('Profiler.setSamplingInterval' , {'interval' : 100 })
270270 self .send_command ('Profiler.start' , {})
271+ trace_config = {"recordMode" : "recordAsMuchAsPossible" ,
272+ "includedCategories" : []}
271273 if 'trace' in self .job and self .job ['trace' ]:
272274 if 'traceCategories' in self .job :
273- trace = self .job ['traceCategories' ]
274- if not trace .startswith ('-*,' ):
275- trace = '-*,' + trace
276- if trace .find ('netlog' ) >= 0 :
275+ categories = self .job ['traceCategories' ].split (',' )
276+ for category in categories :
277+ if category .find ("*" ) < 0 and category not in trace_config ["includedCategories" ]:
278+ trace_config ["includedCategories" ].append (category )
279+ if "netlog" in trace_config ["includedCategories" ]:
277280 self .job ['keep_netlog' ] = True
278281 else :
279- trace = "-*,toplevel,blink,v8,cc,gpu,blink.net," \
280- "disabled-by-default-v8.runtime_stats"
282+ trace_config ["includedCategories" ] = [
283+ "toplevel" ,
284+ "blink" ,
285+ "v8" ,
286+ "cc" ,
287+ "gpu" ,
288+ "blink.net" ,
289+ "disabled-by-default-v8.runtime_stats"
290+ ]
281291 self .job ['keep_netlog' ] = True
282292 else :
283293 self .job ['keep_netlog' ] = False
284- trace = "-*"
285294 if 'netlog' in self .job and self .job ['netlog' ]:
286295 self .job ['keep_netlog' ] = True
287296 if 'timeline' in self .job and self .job ['timeline' ]:
288- trace += ',' + ',' .join ([
289- 'blink.console' ,
290- 'devtools.timeline'
291- ])
297+ if "blink.console" not in trace_config ["includedCategories" ]:
298+ trace_config ["includedCategories" ].append ("blink.console" )
299+ if "devtools.timeline" not in trace_config ["includedCategories" ]:
300+ trace_config ["includedCategories" ].append ("devtools.timeline" )
301+ trace_config ["enableSampling" ] = True
292302 if 'timeline_fps' in self .job and self .job ['timeline_fps' ]:
293- trace += ',' + ',' . join ([
294- ' disabled-by-default-devtools.timeline' ,
295- ' disabled-by-default-devtools.timeline.frame'
296- ] )
303+ if "disabled-by-default-devtools.timeline" not in trace_config [ "includedCategories" ]:
304+ trace_config [ "includedCategories" ]. append ( " disabled-by-default-devtools.timeline" )
305+ if " disabled-by-default-devtools.timeline.frame" not in trace_config [ "includedCategories" ]:
306+ trace_config [ "includedCategories" ]. append ( "disabled-by-default-devtools.timeline.frame" )
297307 if self .use_devtools_video and self .job ['video' ]:
298- trace += ",disabled-by-default-devtools.screenshot"
308+ if "disabled-by-default-devtools.screenshot" not in trace_config ["includedCategories" ]:
309+ trace_config ["includedCategories" ].append ("disabled-by-default-devtools.screenshot" )
299310 self .recording_video = True
300311 # Add the required trace events
301- if trace .find (',rail' ) == - 1 :
302- trace += ',rail'
303- if trace .find (',blink.user_timing' ) == - 1 :
304- trace += ',blink.user_timing'
305- if trace .find (',netlog' ) == - 1 :
306- trace += ',netlog'
307- if trace .find (',disabled-by-default-blink.feature_usage' ) == - 1 :
308- trace += ',disabled-by-default-blink.feature_usage'
312+ if "rail" not in trace_config ["includedCategories" ]:
313+ trace_config ["includedCategories" ].append ("rail" )
314+ if "blink.user_timing" not in trace_config ["includedCategories" ]:
315+ trace_config ["includedCategories" ].append ("blink.user_timing" )
316+ if "netlog" not in trace_config ["includedCategories" ]:
317+ trace_config ["includedCategories" ].append ("netlog" )
318+ if "net" not in trace_config ["includedCategories" ]:
319+ trace_config ["includedCategories" ].append ("net" )
320+ if "disabled-by-default-netlog" not in trace_config ["includedCategories" ]:
321+ trace_config ["includedCategories" ].append ("disabled-by-default-netlog" )
322+ if "disabled-by-default-net" not in trace_config ["includedCategories" ]:
323+ trace_config ["includedCategories" ].append ("disabled-by-default-net" )
324+ if "disabled-by-default-network" not in trace_config ["includedCategories" ]:
325+ trace_config ["includedCategories" ].append ("disabled-by-default-network" )
326+ if "disabled-by-default-blink.feature_usage" not in trace_config ["includedCategories" ]:
327+ trace_config ["includedCategories" ].append ("disabled-by-default-blink.feature_usage" )
309328 self .trace_enabled = True
310329 self .send_command ('Tracing.start' ,
311- {'categories' : trace ,
312- 'options' : 'record-as-much-as-possible' },
330+ {'traceConfig' : trace_config },
313331 wait = True )
314332 now = monotonic .monotonic ()
315333 if not self .task ['stop_at_onload' ]:
0 commit comments