From 4eed9cf8c9870ebbf47b877e5299a69097b98402 Mon Sep 17 00:00:00 2001 From: Victor Porof Date: Mon, 7 Jul 2014 07:20:46 -0400 Subject: [PATCH] Bug 1034648 - The framerate actor needs a way to cancel a recording without retrieving the accumulated data, r=pbrosset --- toolkit/devtools/server/actors/framerate.js | 20 +++-- .../server/tests/mochitest/chrome.ini | 1 + .../tests/mochitest/test_framerate_05.html | 78 +++++++++++++++++++ 3 files changed, 93 insertions(+), 6 deletions(-) create mode 100644 toolkit/devtools/server/tests/mochitest/test_framerate_05.html diff --git a/toolkit/devtools/server/actors/framerate.js b/toolkit/devtools/server/actors/framerate.js index e8d2b0c227c6..b2ebdd89174e 100644 --- a/toolkit/devtools/server/actors/framerate.js +++ b/toolkit/devtools/server/actors/framerate.js @@ -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(); diff --git a/toolkit/devtools/server/tests/mochitest/chrome.ini b/toolkit/devtools/server/tests/mochitest/chrome.ini index 8637d444d413..ac556537a5ab 100644 --- a/toolkit/devtools/server/tests/mochitest/chrome.ini +++ b/toolkit/devtools/server/tests/mochitest/chrome.ini @@ -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] diff --git a/toolkit/devtools/server/tests/mochitest/test_framerate_05.html b/toolkit/devtools/server/tests/mochitest/test_framerate_05.html new file mode 100644 index 000000000000..0505b4535205 --- /dev/null +++ b/toolkit/devtools/server/tests/mochitest/test_framerate_05.html @@ -0,0 +1,78 @@ + + + + + + Framerate actor test + + + + +
+
+
+ +