summaryrefslogtreecommitdiffstats
path: root/devtools/client/performance/test/helpers/recording-utils.js
blob: e51e2d5dd95a297e24ff029f0dd3580a625502f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";

/**
 * These utilities provide a functional interface for accessing the particulars
 * about the recording's details.
 */

/**
 * Access the selected view from the panel's recording list.
 *
 * @param {object} panel - The current panel.
 * @return {object} The recording model.
 */
exports.getSelectedRecording = function (panel) {
  const view = panel.panelWin.RecordingsView;
  return view.selected;
};

/**
 * Set the selected index of the recording via the panel.
 *
 * @param {object} panel - The current panel.
 * @return {number} index
 */
exports.setSelectedRecording = function (panel, index) {
  const view = panel.panelWin.RecordingsView;
  view.setSelectedByIndex(index);
  return index;
};

/**
 * Access the selected view from the panel's recording list.
 *
 * @param {object} panel - The current panel.
 * @return {number} index
 */
exports.getSelectedRecordingIndex = function (panel) {
  const view = panel.panelWin.RecordingsView;
  return view.getSelectedIndex();
};

exports.getDurationLabelText = function (panel, elementIndex) {
  const { $$ } = panel.panelWin;
  const elements = $$(".recording-list-item-duration", panel.panelWin.document);
  return elements[elementIndex].innerHTML;
};

exports.getRecordingsCount = function (panel) {
  const { $$ } = panel.panelWin;
  return $$(".recording-list-item", panel.panelWin.document).length;
};