summaryrefslogtreecommitdiffstats
path: root/devtools/client/canvasdebugger/test/browser_canvas-frontend-call-search.js
blob: e865df39171516871a37e86cc53c61ad4ef23e07 (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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

/**
 * Tests if filtering the items in the call list works properly.
 */

function* ifTestingSupported() {
  let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
  let { window, $, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin;
  let searchbox = $("#calls-searchbox");

  yield reload(target);

  let firstRecordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
  let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
  SnapshotsListView._onRecordButtonClick();
  yield promise.all([firstRecordingFinished, callListPopulated]);

  is(searchbox.value, "",
    "The searchbox should be initially empty.");
  is(CallsListView.visibleItems.length, 8,
    "All the items should be initially visible in the calls list.");

  searchbox.focus();
  EventUtils.sendString("clear", window);

  is(searchbox.value, "clear",
    "The searchbox should now contain the 'clear' string.");
  is(CallsListView.visibleItems.length, 1,
    "Only one item should now be visible in the calls list.");

  is(CallsListView.visibleItems[0].attachment.actor.type, CallWatcherFront.METHOD_FUNCTION,
    "The visible item's type has the expected value.");
  is(CallsListView.visibleItems[0].attachment.actor.name, "clearRect",
    "The visible item's name has the expected value.");
  is(CallsListView.visibleItems[0].attachment.actor.file, SIMPLE_CANVAS_URL,
    "The visible item's file has the expected value.");
  is(CallsListView.visibleItems[0].attachment.actor.line, 25,
    "The visible item's line has the expected value.");
  is(CallsListView.visibleItems[0].attachment.actor.argsPreview, "0, 0, 128, 128",
    "The visible item's args have the expected value.");
  is(CallsListView.visibleItems[0].attachment.actor.callerPreview, "Object",
    "The visible item's caller has the expected value.");

  let secondRecordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
  callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);

  SnapshotsListView._onRecordButtonClick();
  yield secondRecordingFinished;

  SnapshotsListView.selectedIndex = 1;
  yield callListPopulated;

  is(searchbox.value, "clear",
    "The searchbox should still contain the 'clear' string.");
  is(CallsListView.visibleItems.length, 1,
    "Only one item should still be visible in the calls list.");

  for (let i = 0; i < 5; i++) {
    searchbox.focus();
    EventUtils.sendKey("BACK_SPACE", window);
  }

  is(searchbox.value, "",
    "The searchbox should now be emptied.");
  is(CallsListView.visibleItems.length, 8,
    "All the items should be initially visible again in the calls list.");

  yield teardown(panel);
  finish();
}