summaryrefslogtreecommitdiff
path: root/toolkit/devtools/timeline/test/browser_timeline_overview-update.js
blob: 130f7db11c6a48d8b74cf9432f7b9bce89a1c8ce (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

/**
 * Tests if the markers and memory overviews are continuously updated.
 */

add_task(function*() {
  let { target, panel } = yield initTimelinePanel("about:blank");
  let { $, EVENTS, TimelineView, TimelineController } = panel.panelWin;

  $("#memory-checkbox").checked = true;
  yield TimelineController.updateMemoryRecording();

  yield TimelineController.toggleRecording();
  ok(true, "Recording has started.");

  ok("selectionEnabled" in TimelineView.markersOverview,
    "The selection should not be enabled for the markers overview (1).");
  is(TimelineView.markersOverview.selectionEnabled, false,
    "The selection should not be enabled for the markers overview (2).");
  is(TimelineView.markersOverview.hasSelection(), false,
    "The markers overview shouldn't have a selection before recording.");

  ok("selectionEnabled" in TimelineView.memoryOverview,
    "The selection should not be enabled for the memory overview (1).");
  is(TimelineView.memoryOverview.selectionEnabled, false,
    "The selection should not be enabled for the memory overview (2).");
  is(TimelineView.memoryOverview.hasSelection(), false,
    "The memory overview shouldn't have a selection before recording.");

  let updated = 0;
  panel.panelWin.on(EVENTS.OVERVIEW_UPDATED, () => updated++);

  ok((yield waitUntil(() => updated > 10)),
    "The overviews were updated a bunch of times.");
  ok((yield waitUntil(() => TimelineController.getMemory().length > 10)),
    "There are some memory measurements available now.");

  ok("selectionEnabled" in TimelineView.markersOverview,
    "The selection should still not be enabled for the markers overview (3).");
  is(TimelineView.markersOverview.selectionEnabled, false,
    "The selection should still not be enabled for the markers overview (4).");
  is(TimelineView.markersOverview.hasSelection(), false,
    "The markers overview should not have a selection while recording.");

  ok("selectionEnabled" in TimelineView.memoryOverview,
    "The selection should still not be enabled for the memory overview (3).");
  is(TimelineView.memoryOverview.selectionEnabled, false,
    "The selection should still not be enabled for the memory overview (4).");
  is(TimelineView.memoryOverview.hasSelection(), false,
    "The memory overview should not have a selection while recording.");

  yield TimelineController.toggleRecording();
  ok(true, "Recording has ended.");

  // TODO: Re-enable this assertion as part of bug 1120830
  // is(TimelineController.getMarkers().length, 0,
  //  "There are no markers available.");
  isnot(TimelineController.getMemory().length, 0,
    "There are some memory measurements available.");

  is(TimelineView.markersOverview.selectionEnabled, true,
    "The selection should now be enabled for the markers overview.");
  // TODO: Re-enable this assertion as part of bug 1120830
  // is(TimelineView.markersOverview.hasSelection(), false,
  //  "The markers overview should not have a selection after recording.");

  is(TimelineView.memoryOverview.selectionEnabled, true,
    "The selection should now be enabled for the memory overview.");
  // TODO: Re-enable this assertion as part of bug 1120830
  // is(TimelineView.memoryOverview.hasSelection(), false,
  //  "The memory overview should not have a selection after recording.");
});