1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 from measurements import startup
6 from metrics import startup_metric
8 class StartWithUrl(startup.Startup):
9 """Measures Chromium's startup performance when started with a URL
11 This test inherits support for the --warm or --cold command line options -
12 see startup.py for details.
16 super(StartWithUrl, self).__init__()
17 self.close_tabs_before_run = False
20 def AddCommandLineOptions(self, parser):
21 super(StartWithUrl, self).AddCommandLineOptions(parser)
22 parser.add_option('--url', action='store', default=None,
23 help='Start with a request to open a specific URL')
25 def CustomizeBrowserOptions(self, options):
26 super(StartWithUrl, self).CustomizeBrowserOptions(options)
28 browser_options = options.browser_options
29 browser_options.startup_url = options.url
30 options.AppendExtraBrowserArgs([
31 '--restore-last-session'
34 def CanRunForPage(self, page):
35 # No matter how many pages in the pageset, just perform one test iteration.
36 return page.page_set.pages.index(page) == 0
38 def RunNavigateSteps(self, page, tab):
39 # Overriden so that no page navigation occurs.
42 def ValidatePageSet(self, page_set):
43 # Reject any pageset that contains more than one WPR archive.
46 wpr_archives[page_set.WprFilePathForPage(page)] = True
48 if len(wpr_archives.keys()) > 1:
49 raise Exception("Invalid pageset: more than 1 WPR archive found.: " +
50 ', '.join(wpr_archives.keys()))
52 def MeasurePage(self, page, tab, results):
53 # Wait for all tabs to finish loading.
54 for i in xrange(len(tab.browser.tabs)):
55 t = tab.browser.tabs[i]
56 t.WaitForDocumentReadyStateToBeComplete()
58 startup_metric.StartupMetric().AddResults(tab, results)