Home | History | Annotate | Download | only in measurements
      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.
      4 
      5 from telemetry.page import page
      6 from telemetry.page import page_measurement
      7 
      8 
      9 class PageForPolymerLoad(page.Page):
     10 
     11   def __init__(self, url, page_set):
     12     super(PageForPolymerLoad, self).__init__(
     13       url=url,
     14       page_set=page_set)
     15     self.script_to_evaluate_on_commit = '''
     16       document.addEventListener("polymer-ready", function() {
     17         var unused = document.body.offsetHeight;
     18         window.__polymer_ready_time = performance.now();
     19         setTimeout(function() {
     20           window.__polymer_ready = true;
     21         }, 1000);
     22       })
     23     '''
     24 
     25   def RunNavigateSteps(self, action_runner):
     26     action_runner.NavigateToPage(self)
     27     action_runner.WaitForJavaScriptCondition('window.__polymer_ready')
     28 
     29 
     30 class PolymerLoadMeasurement(page_measurement.PageMeasurement):
     31   def MeasurePage(self, _, tab, results):
     32     result = int(tab.EvaluateJavaScript('__polymer_ready_time'))
     33     results.Add('Total', 'ms', result)
     34