From c88d11bc9682840c71f2fdc47487791c3aa6c205 Mon Sep 17 00:00:00 2001 From: Jordan Santell Date: Wed, 6 May 2015 17:18:00 +0200 Subject: [PATCH] Bug 1160828 - Return null when attempting to get the current selection from a graph that is not yet ready. r=vp --HG-- extra : rebase_source : 7e97e63a6283d1fb169e83697aaa8093e223bad1 --- .../devtools/performance/modules/graphs.js | 9 ++++++-- .../test/browser_perf_recordings-io-01.js | 23 +++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/browser/devtools/performance/modules/graphs.js b/browser/devtools/performance/modules/graphs.js index 81720fb21f0d..3b9057d00e80 100644 --- a/browser/devtools/performance/modules/graphs.js +++ b/browser/devtools/performance/modules/graphs.js @@ -344,9 +344,14 @@ GraphsController.prototype = { return this._getPrimaryLink().setMappedSelection(selection, { mapStart, mapEnd }); }, + /** + * Fetches the currently mapped selection. If graphs are not yet rendered, + * (which throws in Graphs.jsm), return null. + */ getMappedSelection: function ({ mapStart, mapEnd }) { - if (this._getPrimaryLink()) { - return this._getPrimaryLink().getMappedSelection({ mapStart, mapEnd }); + let primary = this._getPrimaryLink(); + if (primary && primary.hasData()) { + return primary.getMappedSelection({ mapStart, mapEnd }); } else { return null; } diff --git a/browser/devtools/performance/test/browser_perf_recordings-io-01.js b/browser/devtools/performance/test/browser_perf_recordings-io-01.js index a3d884ae1c60..bee1bd86b431 100644 --- a/browser/devtools/performance/test/browser_perf_recordings-io-01.js +++ b/browser/devtools/performance/test/browser_perf_recordings-io-01.js @@ -6,8 +6,8 @@ */ let test = Task.async(function*() { - let { target, panel, toolbox } = yield initPerformance(SIMPLE_URL); - let { EVENTS, PerformanceController, DetailsView, DetailsSubview } = panel.panelWin; + var { target, panel, toolbox } = yield initPerformance(SIMPLE_URL); + var { EVENTS, PerformanceController, DetailsView, DetailsSubview } = panel.panelWin; // Enable memory to test the memory-calltree and memory-flamegraph. Services.prefs.setBoolPref(MEMORY_PREF, true); @@ -80,6 +80,25 @@ let test = Task.async(function*() { is(importedData.configuration.withMemory, originalData.configuration.withMemory, "The imported data is identical to the original data (9)."); + yield teardown(panel); + + // Test that when importing and no graphs rendered yet, + // we do not get a getMappedSelection error + // bug 1160828 + var { target, panel, toolbox } = yield initPerformance(SIMPLE_URL); + var { EVENTS, PerformanceController, DetailsView, DetailsSubview, OverviewView, WaterfallView } = panel.panelWin; + yield PerformanceController.clearRecordings(); + + rerendered = once(WaterfallView, EVENTS.WATERFALL_RENDERED); + imported = once(PerformanceController, EVENTS.RECORDING_IMPORTED); + yield PerformanceController.importRecording("", file); + + yield imported; + ok(true, "The recording data appears to have been successfully imported."); + + yield rerendered; + ok(true, "The imported data was re-rendered."); + yield teardown(panel); finish(); });