1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/metro/base/tests/mochiperf/browser_miscgfx_01.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,108 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +"use strict"; 1.8 + 1.9 +function test() { 1.10 + requestLongerTimeout(2); 1.11 + runTests(); 1.12 +} 1.13 + 1.14 +function tapRadius() { 1.15 + let dpi = Util.displayDPI; 1.16 + return Services.prefs.getIntPref("ui.dragThresholdX") / 240 * dpi; // 27.999998728434246 1.17 +} 1.18 + 1.19 +gTests.push({ 1.20 + desc: "scrollBy", 1.21 + run: function run() { 1.22 + yield addTab(chromeRoot + "res/scroll_test.html"); 1.23 + yield hideContextUI(); 1.24 + yield hideNavBar(); 1.25 + 1.26 + let stopwatch = new StopWatch(); 1.27 + let win = Browser.selectedTab.browser.contentWindow; 1.28 + let domUtils = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils); 1.29 + let deferExit = Promise.defer(); 1.30 + let recordingHandle = domUtils.startFrameTimeRecording(); 1.31 + 1.32 + function step() { 1.33 + if (stopwatch.time() < 5000) { 1.34 + win.scrollBy(0, 2); 1.35 + win.mozRequestAnimationFrame(step); 1.36 + return; 1.37 + } 1.38 + 1.39 + let intervals = domUtils.stopFrameTimeRecording(recordingHandle); 1.40 + let msec = stopwatch.stop(); 1.41 + PerfTest.declareTest("79235F74-037C-4F6B-AE47-FDCCC13458C3", 1.42 + "scrollBy scroll", "graphics", "content", 1.43 + "Measures performance of single line scrolls for a large page of text using FTR."); 1.44 + PerfTest.declareFrameRateResult(intervals.length, msec, "fps"); 1.45 + deferExit.resolve(); 1.46 + } 1.47 + 1.48 + stopwatch.start(); 1.49 + win.mozRequestAnimationFrame(step); 1.50 + yield deferExit.promise; 1.51 + } 1.52 +}); 1.53 + 1.54 +gTests.push({ 1.55 + desc: "canvas perf test", 1.56 + run: function run() { 1.57 + yield addTab(chromeRoot + "res/ripples.html"); 1.58 + yield hideContextUI(); 1.59 + yield hideNavBar(); 1.60 + 1.61 + let win = Browser.selectedTab.browser.contentWindow; 1.62 + let domUtils = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils); 1.63 + let recordingHandle = domUtils.startFrameTimeRecording(); 1.64 + PerfTest.declareTest("6A455F96-2B2C-4B3C-B387-1AF2F1747CCF", 1.65 + "ripples", "graphics", "canvas", 1.66 + "Measures animation frames during a computationally " + 1.67 + "heavy graphics demo using canvas using FTR."); 1.68 + let stopwatch = new StopWatch(true); 1.69 + // test page runs for 5 seconds 1.70 + let event = yield waitForEvent(win, "test", 10000); 1.71 + let intervals = domUtils.stopFrameTimeRecording(recordingHandle); 1.72 + let msec = stopwatch.stop(); 1.73 + PerfTest.declareFrameRateResult(intervals.length, msec, "fps"); 1.74 + } 1.75 +}); 1.76 + 1.77 +gTests.push({ 1.78 + desc: "video perf test", 1.79 + run: function run() { 1.80 + yield addTab(chromeRoot + "res/tidevideo.html"); 1.81 + let win = Browser.selectedTab.browser.contentWindow; 1.82 + let domUtils = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils); 1.83 + let video = win.document.getElementById("videoelement"); 1.84 + video.pause(); 1.85 + yield hideContextUI(); 1.86 + yield hideNavBar(); 1.87 + yield waitForMs(1000); 1.88 + PerfTest.declareTest("7F55F9C4-0ECF-4A13-9A9C-A38D46922C0B", 1.89 + "video playback (moz paints)", "graphics", "video", 1.90 + "Measures frames per second during five seconds of playback of an mp4."); 1.91 + 1.92 + let recordingHandle = domUtils.startFrameTimeRecording(); 1.93 + let stopwatch = new StopWatch(true); 1.94 + video.play(); 1.95 + yield waitForMs(5000); 1.96 + video.pause(); 1.97 + let intervals = domUtils.stopFrameTimeRecording(recordingHandle); 1.98 + let msec = stopwatch.stop(); 1.99 + PerfTest.declareFrameRateResult(intervals.length, msec, "fps"); 1.100 + 1.101 + PerfTest.declareTest("E132D333-4642-4597-B1F0-1E74B625DBD7", 1.102 + "video playback (moz stats)", "graphics", "video", 1.103 + "Report moz* related video performance stats during five seconds of playback of an mp4."); 1.104 + let results = []; 1.105 + results.push({ value: (video.mozDecodedFrames / msec) * 1000.0, desc: "mozDecodedFrames" }); 1.106 + results.push({ value: (video.mozParsedFrames / msec) * 1000.0, desc: "mozParsedFrames", shareAxis: 0 }); 1.107 + results.push({ value: (video.mozPresentedFrames / msec) * 1000.0, desc: "mozPresentedFrames", shareAxis: 0 }); 1.108 + results.push({ value: (video.mozPaintedFrames / msec) * 1000.0, desc: "mozPaintedFrames", shareAxis: 0 }); 1.109 + PerfTest.declareNumericalResults(results); 1.110 + } 1.111 +});