[Session restore] Rename group name Enabled to Restore.
[chromium-blink-merge.git] / tools / perf / measurements / polymer_load.py
blob40887afed68fbf7f5027930df3b633c930aee832
1 # Copyright 2014 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 telemetry.page import page
6 from telemetry.page import page_test
7 from telemetry.value import scalar
10 class PageForPolymerLoad(page.Page):
12 def __init__(self, url, page_set, ready_event='polymer-ready'):
13 super(PageForPolymerLoad, self).__init__(
14 url=url,
15 page_set=page_set)
16 self.script_to_evaluate_on_commit = '''
17 document.addEventListener("%s", function() {
18 var unused = document.body.offsetHeight;
19 window.__polymer_ready_time = performance.now();
20 setTimeout(function() {
21 window.__polymer_ready = true;
22 }, 1000);
24 ''' % ready_event
26 def RunNavigateSteps(self, action_runner):
27 super(PageForPolymerLoad, self).RunNavigateSteps(action_runner)
28 action_runner.WaitForJavaScriptCondition('window.__polymer_ready')
31 class PolymerLoadMeasurement(page_test.PageTest):
32 def __init__(self):
33 super(PolymerLoadMeasurement, self).__init__()
35 def ValidateAndMeasurePage(self, _, tab, results):
36 result = int(tab.EvaluateJavaScript('__polymer_ready_time'))
37 results.AddValue(scalar.ScalarValue(
38 results.current_page, 'Total', 'ms', result))