| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 # The test takes a list of URLs through stdin and prints results in CSV format. | 5 # The test takes a list of URLs through stdin and prints results in CSV format. |
| 6 # Example: python run_scroll_test.py < data/urls.txt > test_results.csv | 6 # Example: python run_scroll_test.py < data/urls.txt > test_results.csv |
| 7 import chrome_remote_control | 7 import chrome_remote_control |
| 8 | 8 |
| 9 import multi_page_benchmark | 9 import multi_page_benchmark |
| 10 import util | 10 import util |
| 11 | 11 |
| 12 | 12 |
| 13 class FirstPaintTimeBenchmark(multi_page_benchmark.MultiPageBenchmark): | 13 class FirstPaintTimeBenchmark(multi_page_benchmark.MultiPageBenchmark): |
| 14 def MeasurePage(self, page, tab): | 14 def MeasurePage(self, page, tab): |
| 15 if tab.browser.is_content_shell: |
| 16 return {"first_paint_secs": "unsupported"} |
| 17 |
| 15 tab.runtime.Execute(""" | 18 tab.runtime.Execute(""" |
| 16 window.__rafFired = false; | 19 window.__rafFired = false; |
| 17 window.webkitRequestAnimationFrame(function() { | 20 window.webkitRequestAnimationFrame(function() { |
| 18 window.__rafFired = true; | 21 window.__rafFired = true; |
| 19 }); | 22 }); |
| 20 """) | 23 """) |
| 21 chrome_remote_control.WaitFor( | 24 chrome_remote_control.WaitFor( |
| 22 lambda: tab.runtime.Evaluate('window.__rafFired'), 60) | 25 lambda: tab.runtime.Evaluate('window.__rafFired'), 60) |
| 23 | 26 |
| 24 first_paint_secs = tab.runtime.Evaluate( | 27 first_paint_secs = tab.runtime.Evaluate( |
| 25 'chrome.loadTimes().firstPaintTime - chrome.loadTimes().startLoadTime') | 28 'window.chrome.loadTimes().firstPaintTime - ' + |
| 29 'window.chrome.loadTimes().startLoadTime') |
| 26 | 30 |
| 27 return { | 31 return { |
| 28 "first_paint_secs": util.RoundTo3DecimalPlaces(first_paint_secs) | 32 "first_paint_secs": util.RoundTo3DecimalPlaces(first_paint_secs) |
| 29 } | 33 } |
| 30 | 34 |
| 31 def Main(): | 35 def Main(): |
| 32 return multi_page_benchmark.Main(FirstPaintTimeBenchmark()) | 36 return multi_page_benchmark.Main(FirstPaintTimeBenchmark()) |
| OLD | NEW |