Bug 1165885 - Handle scenario when clearing out recordings while a console profile is recording. r=pbrosset

This commit is contained in:
Jordan Santell 2015-05-19 15:06:59 -07:00
parent ab4c5f3838
commit 9a0cfb467d
4 changed files with 43 additions and 0 deletions

View File

@ -454,6 +454,11 @@ let PerformanceController = {
* @param {RecordingModel} model
*/
_onRecordingStateChange: function (state, model) {
// If we get a state change for a recording that isn't being tracked in the front,
// just ignore it. This can occur when stopping a profile via console that was cleared.
if (state !== "recording-starting" && this.getRecordings().indexOf(model) === -1) {
return;
}
switch (state) {
// Fired when a RecordingModel was just created from the front
case "recording-starting":

View File

@ -37,6 +37,7 @@ support-files =
[browser_perf-console-record-06.js]
[browser_perf-console-record-07.js]
[browser_perf-console-record-08.js]
[browser_perf-console-record-09.js]
[browser_perf-data-massaging-01.js]
[browser_perf-data-samples.js]
[browser_perf-details-calltree-render.js]

View File

@ -0,0 +1,31 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Tests that an error is not thrown when clearing out the recordings if there's
* an in-progress console profile.
*/
function spawnTest () {
loadFrameScripts();
let { target, toolbox, panel } = yield initPerformance(SIMPLE_URL);
let win = panel.panelWin;
let { gFront, PerformanceController } = win;
info("Starting console.profile()...");
yield consoleProfile(win);
yield PerformanceController.clearRecordings();
info("Ending console.profileEnd()...");
consoleMethod("profileEnd");
// Wait for the front to receive the stopped event
yield once(gFront, "recording-stopped");
// Wait an extra tick or two since the above promise will be resolved
// the same time as _onRecordingStateChange, which should not cause any throwing
yield idleWait(100);
ok(true, "Stopping an in-progress console profile after clearing recordings does not throw.");
yield teardown(panel);
finish();
}

View File

@ -407,6 +407,12 @@ function OverviewViewOnStateChange (fn) {
// from the event name, since there is a delay between starting
// a recording and changing the selection.
if (!currentRecording || !recording) {
// If no recording (this can occur when having a console.profile recording, and
// we do not stop it from the backend), and we are still rendering updates,
// stop that.
if (this.isRendering()) {
this._stopPolling();
}
return;
}