Bug 1023018 - Make the framerate actor take 'start' and 'end' params for specifying a range when retrieving the refresh driver ticks, r=pbrosset

This commit is contained in:
Victor Porof 2014-06-10 10:55:25 -04:00
parent f4e0cf8c3b
commit 073fae60d5
3 changed files with 89 additions and 3 deletions

View File

@ -54,18 +54,22 @@ let FramerateActor = exports.FramerateActor = protocol.ActorClass({
/**
* Stops monitoring framerate, returning the recorded values.
*/
stopRecording: method(function() {
stopRecording: method(function(beginAt = 0, endAt = Number.MAX_SAFE_INTEGER) {
if (!this._recording) {
return [];
}
this._recording = false;
// We don't need to store the ticks array for future use, release it.
let ticks = this._ticks;
let ticks = this._ticks.filter(e => e >= beginAt && e <= endAt);
this._ticks = null;
return ticks;
}, {
response: { timeline: RetVal("array:number") }
request: {
beginAt: Arg(0, "nullable:number"),
endAt: Arg(1, "nullable:number")
},
response: { ticks: RetVal("array:number") }
}),
/**

View File

@ -21,6 +21,7 @@ support-files =
[test_device.html]
[test_framerate_01.html]
[test_framerate_02.html]
[test_framerate_03.html]
[test_inspector-changeattrs.html]
[test_inspector-changevalue.html]
[test_inspector-hide.html]

View File

@ -0,0 +1,81 @@
<!DOCTYPE HTML>
<html>
<!--
Bug 1023018 - Tests whether or not the framerate actor can handle time ranges.
-->
<head>
<meta charset="utf-8">
<title>Framerate actor test</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script>
window.onload = function() {
var Cu = Components.utils;
var Cc = Components.classes;
var Ci = Components.interfaces;
Cu.import("resource://gre/modules/Services.jsm");
// Always log packets when running tests.
Services.prefs.setBoolPref("devtools.debugger.log", true);
SimpleTest.registerCleanupFunction(function() {
Services.prefs.clearUserPref("devtools.debugger.log");
});
Cu.import("resource://gre/modules/devtools/Loader.jsm");
Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
SimpleTest.waitForExplicitFinish();
var {FramerateFront} = devtools.require("devtools/server/actors/framerate");
var START_TICK = 2000;
var STOP_TICK = 3000;
var TOTAL_TIME = 5000;
DebuggerServer.init(function () { return true; });
DebuggerServer.addBrowserActors();
var client = new DebuggerClient(DebuggerServer.connectPipe());
client.connect(function onConnect() {
client.listTabs(function onListTabs(aResponse) {
var form = aResponse.tabs[aResponse.selected];
var front = FramerateFront(client, form);
front.startRecording().then(() => {
window.setTimeout(() => {
front.stopRecording(START_TICK, STOP_TICK).then(rawData => {
onRecordingStopped(front, rawData);
});
}, TOTAL_TIME);
});
});
});
function onRecordingStopped(front, rawData) {
ok(rawData, "There should be a recording available.");
ok(!rawData.find(e => e < START_TICK),
"There should be no tick before 2000ms.");
ok(!rawData.find(e => e > STOP_TICK),
"There should be no tick after 3000ms.");
for (var tick of rawData) {
info("Testing tick: " + tick);
is(typeof tick, "number", "All values should be numbers.");
}
client.close(() => {
DebuggerServer.destroy();
SimpleTest.finish()
});
}
}
</script>
</pre>
</body>
</html>