123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- /* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
- "use strict";
- /**
- * Tests that the details view hides the allocations buttons when a recording
- * does not have allocations data ("withAllocations": false), and that when an
- * allocations panel is selected to a panel that does not have allocations goes
- * to a default panel instead.
- */
- const { SIMPLE_URL } = require("devtools/client/performance/test/helpers/urls");
- const { UI_ENABLE_ALLOCATIONS_PREF } = require("devtools/client/performance/test/helpers/prefs");
- const { initPerformanceInNewTab, teardownToolboxAndRemoveTab } = require("devtools/client/performance/test/helpers/panel-utils");
- const { startRecording, stopRecording } = require("devtools/client/performance/test/helpers/actions");
- const { once } = require("devtools/client/performance/test/helpers/event-utils");
- const { setSelectedRecording } = require("devtools/client/performance/test/helpers/recording-utils");
- add_task(function* () {
- let { panel } = yield initPerformanceInNewTab({
- url: SIMPLE_URL,
- win: window
- });
- let {
- EVENTS,
- $,
- DetailsView,
- WaterfallView,
- MemoryCallTreeView,
- MemoryFlameGraphView
- } = panel.panelWin;
- let flameBtn = $("toolbarbutton[data-view='memory-flamegraph']");
- let callBtn = $("toolbarbutton[data-view='memory-calltree']");
- // Disable allocations to prevent recording them.
- Services.prefs.setBoolPref(UI_ENABLE_ALLOCATIONS_PREF, false);
- yield startRecording(panel);
- yield stopRecording(panel);
- ok(DetailsView.isViewSelected(WaterfallView),
- "The waterfall view is selected by default in the details view.");
- // Re-enable allocations to test.
- Services.prefs.setBoolPref(UI_ENABLE_ALLOCATIONS_PREF, true);
- // The toolbar buttons will always be hidden when a recording isn't available,
- // so make sure we have one that's finished.
- yield startRecording(panel);
- yield stopRecording(panel);
- ok(DetailsView.isViewSelected(WaterfallView),
- "The waterfall view is still selected in the details view.");
- is(callBtn.hidden, false,
- "The `memory-calltree` button is shown when recording has memory data.");
- is(flameBtn.hidden, false,
- "The `memory-flamegraph` button is shown when recording has memory data.");
- let selected = once(DetailsView, EVENTS.UI_DETAILS_VIEW_SELECTED);
- let rendered = once(MemoryCallTreeView, EVENTS.UI_MEMORY_CALL_TREE_RENDERED);
- DetailsView.selectView("memory-calltree");
- yield selected;
- yield rendered;
- ok(DetailsView.isViewSelected(MemoryCallTreeView),
- "The memory call tree view can now be selected.");
- selected = once(DetailsView, EVENTS.UI_DETAILS_VIEW_SELECTED);
- rendered = once(MemoryFlameGraphView, EVENTS.UI_MEMORY_FLAMEGRAPH_RENDERED);
- DetailsView.selectView("memory-flamegraph");
- yield selected;
- yield rendered;
- ok(DetailsView.isViewSelected(MemoryFlameGraphView),
- "The memory flamegraph view can now be selected.");
- // Select the first recording with no memory data.
- selected = once(DetailsView, EVENTS.UI_DETAILS_VIEW_SELECTED);
- rendered = once(WaterfallView, EVENTS.UI_WATERFALL_RENDERED);
- setSelectedRecording(panel, 0);
- yield selected;
- yield rendered;
- ok(DetailsView.isViewSelected(WaterfallView), "The waterfall view is now selected " +
- "when switching back to a recording that does not have memory data.");
- is(callBtn.hidden, true,
- "The `memory-calltree` button is hidden when recording has no memory data.");
- is(flameBtn.hidden, true,
- "The `memory-flamegraph` button is hidden when recording has no memory data.");
- // Go back to the recording with memory data.
- rendered = once(WaterfallView, EVENTS.UI_WATERFALL_RENDERED);
- setSelectedRecording(panel, 1);
- yield rendered;
- ok(DetailsView.isViewSelected(WaterfallView),
- "The waterfall view is still selected in the details view.");
- is(callBtn.hidden, false,
- "The `memory-calltree` button is shown when recording has memory data.");
- is(flameBtn.hidden, false,
- "The `memory-flamegraph` button is shown when recording has memory data.");
- selected = once(DetailsView, EVENTS.UI_DETAILS_VIEW_SELECTED);
- rendered = once(MemoryCallTreeView, EVENTS.UI_MEMORY_CALL_TREE_RENDERED);
- DetailsView.selectView("memory-calltree");
- yield selected;
- yield rendered;
- ok(DetailsView.isViewSelected(MemoryCallTreeView), "The memory call tree view can be " +
- "selected again after going back to the view with memory data.");
- selected = once(DetailsView, EVENTS.UI_DETAILS_VIEW_SELECTED);
- rendered = once(MemoryFlameGraphView, EVENTS.UI_MEMORY_FLAMEGRAPH_RENDERED);
- DetailsView.selectView("memory-flamegraph");
- yield selected;
- yield rendered;
- ok(DetailsView.isViewSelected(MemoryFlameGraphView), "The memory flamegraph view can " +
- "be selected again after going back to the view with memory data.");
- yield teardownToolboxAndRemoveTab(panel);
- });
|