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. 4 5"""Impact HTML5 Gaming benchmark. 6 7Tests one very specific use case: smooth running games rendered with the 8<canvas> element. The score for the HTML5-Benchmark takes the total time the 9browser spent rendering frames (formula is 1000000/(sqrt(totalTime) + lagTime * 100.1)). The benchmark automatically runs at a reasonable screen size. Final 11score is a indicator for the browser's ability to smoothly run HTML5 games.""" 12 13import os 14 15from telemetry import test 16from telemetry.page import page_measurement 17from telemetry.page import page_set 18 19class _HTML5GamingMeasurement(page_measurement.PageMeasurement): 20 def MeasurePage(self, _, tab, results): 21 tab.ExecuteJavaScript('benchmark();') 22 # Default value of score element is 87485, its value is updated with actual 23 # score when test finish. 24 tab.WaitForJavaScriptExpression( 25 'document.getElementById("score").innerHTML != "87485"', 200) 26 result = int(tab.EvaluateJavaScript( 27 'document.getElementById("score").innerHTML')) 28 results.Add('Score', 'score', result) 29 30 31class HTML5Gaming(test.Test): 32 """Imapct HTML5 smooth running games benchmark suite.""" 33 test = _HTML5GamingMeasurement 34 def CreatePageSet(self, options): 35 ps = page_set.PageSet( 36 file_path=os.path.abspath(__file__), 37 archive_data_file='../page_sets/data/html5gaming.json', 38 make_javascript_deterministic=False) 39 ps.AddPageWithDefaultRunNavigate('http://html5-benchmark.com/') 40 return ps 41