Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: tools/android/loading/run_sandwich.py

Issue 1698883002: sandwich: Adds command line flag to disable WPR injections (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@d04
Patch Set: Address matt's nits Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/android/loading/device_setup.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #! /usr/bin/env python 1 #! /usr/bin/env python
2 # Copyright 2016 The Chromium Authors. All rights reserved. 2 # Copyright 2016 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Instructs Chrome to load series of web pages and reports results. 6 """Instructs Chrome to load series of web pages and reports results.
7 7
8 When running Chrome is sandwiched between preprocessed disk caches and 8 When running Chrome is sandwiched between preprocessed disk caches and
9 WepPageReplay serving all connections. 9 WepPageReplay serving all connections.
10 10
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 help='How many times to run the job') 289 help='How many times to run the job')
290 parser.add_argument('--cache-op', 290 parser.add_argument('--cache-op',
291 choices=['clear', 'save', 'push'], 291 choices=['clear', 'save', 'push'],
292 default='clear', 292 default='clear',
293 help='Configures cache operation to do before launching ' 293 help='Configures cache operation to do before launching '
294 +'Chrome. (Default is clear).') 294 +'Chrome. (Default is clear).')
295 parser.add_argument('--wpr-archive', default=None, type=str, 295 parser.add_argument('--wpr-archive', default=None, type=str,
296 help='Web page replay archive to load job\'s urls from.') 296 help='Web page replay archive to load job\'s urls from.')
297 parser.add_argument('--wpr-record', default=False, action='store_true', 297 parser.add_argument('--wpr-record', default=False, action='store_true',
298 help='Record web page replay archive.') 298 help='Record web page replay archive.')
299 parser.add_argument('--disable-wpr-script-injection', default=False,
300 action='store_true',
301 help='Disable WPR default script injection such as ' +
302 'overriding javascript\'s Math.random() and Date() ' +
303 'with deterministic implementations.')
299 args = parser.parse_args() 304 args = parser.parse_args()
300 305
301 if not os.path.isdir(args.output): 306 if not os.path.isdir(args.output):
302 try: 307 try:
303 os.makedirs(args.output) 308 os.makedirs(args.output)
304 except OSError: 309 except OSError:
305 logging.error('Cannot create directory for results: %s' % args.output) 310 logging.error('Cannot create directory for results: %s' % args.output)
306 raise 311 raise
307 else: 312 else:
308 _CleanPreviousTraces(args.output) 313 _CleanPreviousTraces(args.output)
309 314
310 job_urls = _ReadUrlsFromJobDescription(args.job) 315 job_urls = _ReadUrlsFromJobDescription(args.job)
311 device = device_utils.DeviceUtils.HealthyDevices()[0] 316 device = device_utils.DeviceUtils.HealthyDevices()[0]
312 local_cache_archive_path = os.path.join(args.output, 'cache.zip') 317 local_cache_archive_path = os.path.join(args.output, 'cache.zip')
313 local_cache_directory_path = None 318 local_cache_directory_path = None
314 319
315 if args.cache_op == 'push': 320 if args.cache_op == 'push':
316 assert os.path.isfile(local_cache_archive_path) 321 assert os.path.isfile(local_cache_archive_path)
317 local_cache_directory_path = tempfile.mkdtemp(suffix='.cache') 322 local_cache_directory_path = tempfile.mkdtemp(suffix='.cache')
318 _UnzipDirectoryContent(local_cache_archive_path, local_cache_directory_path) 323 _UnzipDirectoryContent(local_cache_archive_path, local_cache_directory_path)
319 324
320 with device_setup.WprHost(device, 325 with device_setup.WprHost(device, args.wpr_archive, args.wpr_record,
321 args.wpr_archive, 326 args.disable_wpr_script_injection) as additional_flags:
322 args.wpr_record) as additional_flags:
323 pages_loaded = 0 327 pages_loaded = 0
324 for _ in xrange(args.repeat): 328 for _ in xrange(args.repeat):
325 for url in job_urls: 329 for url in job_urls:
326 if args.cache_op == 'push': 330 if args.cache_op == 'push':
327 device.KillAll(_CHROME_PACKAGE, quiet=True) 331 device.KillAll(_CHROME_PACKAGE, quiet=True)
328 _PushBrowserCache(device, local_cache_directory_path) 332 _PushBrowserCache(device, local_cache_directory_path)
329 with device_setup.DeviceConnection( 333 with device_setup.DeviceConnection(
330 device=device, 334 device=device,
331 additional_flags=additional_flags) as connection: 335 additional_flags=additional_flags) as connection:
332 if (pages_loaded == 0 and args.cache_op == 'save' or 336 if (pages_loaded == 0 and args.cache_op == 'save' or
(...skipping 19 matching lines...) Expand all
352 device.KillAll(_CHROME_PACKAGE, quiet=True) 356 device.KillAll(_CHROME_PACKAGE, quiet=True)
353 time.sleep(_TIME_TO_DEVICE_IDLE_SECONDS) 357 time.sleep(_TIME_TO_DEVICE_IDLE_SECONDS)
354 358
355 cache_directory_path = _PullBrowserCache(device) 359 cache_directory_path = _PullBrowserCache(device)
356 _ZipDirectoryContent(cache_directory_path, local_cache_archive_path) 360 _ZipDirectoryContent(cache_directory_path, local_cache_archive_path)
357 shutil.rmtree(cache_directory_path) 361 shutil.rmtree(cache_directory_path)
358 362
359 363
360 if __name__ == '__main__': 364 if __name__ == '__main__':
361 sys.exit(main()) 365 sys.exit(main())
OLDNEW
« no previous file with comments | « tools/android/loading/device_setup.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698