Bug 1034648 - The framerate actor needs a way to cancel a recording without retrieving the accumulated data, r=pbrosset

This commit is contained in:
Victor Porof 2014-07-07 07:20:46 -04:00
Родитель e0a07f062e
Коммит 4eed9cf8c9
3 изменённых файлов: 93 добавлений и 6 удалений

Просмотреть файл

@ -49,7 +49,7 @@ let FramerateActor = exports.FramerateActor = protocol.ActorClass({
this._ticks = [];
this._startTime = this._chromeWin.performance.now();
this._chromeWin.requestAnimationFrame(this._onRefreshDriverTick);
this._rafID = this._chromeWin.requestAnimationFrame(this._onRefreshDriverTick);
}, {
}),
@ -60,11 +60,8 @@ let FramerateActor = exports.FramerateActor = protocol.ActorClass({
if (!this._recording) {
return [];
}
this._recording = false;
// We don't need to store the ticks array for future use, release it.
let ticks = this.getPendingTicks(beginAt, endAt);
this._ticks = null;
this.cancelRecording();
return ticks;
}, {
request: {
@ -74,6 +71,17 @@ let FramerateActor = exports.FramerateActor = protocol.ActorClass({
response: { ticks: RetVal("array:number") }
}),
/**
* Stops monitoring framerate, without returning the recorded values.
*/
cancelRecording: method(function() {
this._chromeWin.cancelAnimationFrame(this._rafID);
this._recording = false;
this._ticks = null;
this._rafID = -1;
}, {
}),
/**
* Gets the refresh driver ticks recorded so far.
*/
@ -97,7 +105,7 @@ let FramerateActor = exports.FramerateActor = protocol.ActorClass({
if (!this._recording) {
return;
}
this._chromeWin.requestAnimationFrame(this._onRefreshDriverTick);
this._rafID = this._chromeWin.requestAnimationFrame(this._onRefreshDriverTick);
// Store the amount of time passed since the recording started.
let currentTime = this._chromeWin.performance.now();

Просмотреть файл

@ -23,6 +23,7 @@ support-files =
[test_framerate_02.html]
[test_framerate_03.html]
[test_framerate_04.html]
[test_framerate_05.html]
[test_highlighter-boxmodel_01.html]
[test_highlighter-boxmodel_02.html]
[test_highlighter-csstransform_01.html]

Просмотреть файл

@ -0,0 +1,78 @@
<!DOCTYPE HTML>
<html>
<!--
Bug 1034648 - Tests whether a framerate recording can be cancelled.
-->
<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");
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.cancelRecording().then(() => {
window.setTimeout(() => {
front.getPendingTicks().then(rawTicks => {
ok(rawTicks,
"The returned pending ticks should be empty (1).");
is(rawTicks.length, 0,
"The returned pending ticks should be empty (2).");
front.stopRecording().then(rawData => {
ok(rawData,
"The returned raw data should be an empty array (1).");
is(rawData.length, 0,
"The returned raw data should be an empty array (2).");
client.close(() => {
DebuggerServer.destroy();
SimpleTest.finish()
});
});
});
}, 1000);
});
}, 1000);
});
});
});
}
</script>
</pre>
</body>
</html>