summaryrefslogtreecommitdiff
path: root/browser/devtools/canvasdebugger/test/browser_canvas-frontend-img-thumbnails-02.js
blob: e5e56dac5dfede82af78824e0bcea1328e88312a (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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

/**
 * Tests if thumbnails are correctly linked with other UI elements like
 * function call items and their respective screenshots.
 */

function ifTestingSupported() {
  let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
  let { window, $, $all, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin;

  yield reload(target);

  let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
  let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
  let thumbnailsDisplayed = once(window, EVENTS.THUMBNAILS_DISPLAYED);
  let screenshotDisplayed = once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
  SnapshotsListView._onRecordButtonClick();
  yield promise.all([
    recordingFinished,
    callListPopulated,
    thumbnailsDisplayed,
    screenshotDisplayed
  ]);

  is($all(".filmstrip-thumbnail[highlighted]").length, 0,
    "There should be no highlighted thumbnail available yet.");
  is(CallsListView.selectedIndex, -1,
    "There should be no selected item in the calls list view.");

  EventUtils.sendMouseEvent({ type: "mousedown" }, $all(".filmstrip-thumbnail")[0], window);
  yield once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
  info("The first draw call was selected, by clicking the first thumbnail.");

  isnot($(".filmstrip-thumbnail[highlighted][index='0']"), null,
    "There should be a highlighted thumbnail available now, for the first draw call.");
  is($all(".filmstrip-thumbnail[highlighted]").length, 1,
    "There should be only one highlighted thumbnail available now.");
  is(CallsListView.selectedIndex, 0,
    "The first draw call should be selected in the calls list view.");

  EventUtils.sendMouseEvent({ type: "mousedown" }, $all(".call-item-view")[1], window);
  yield once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
  info("The second context call was selected, by clicking the second call item.");

  isnot($(".filmstrip-thumbnail[highlighted][index='0']"), null,
    "There should be a highlighted thumbnail available, for the first draw call.");
  is($all(".filmstrip-thumbnail[highlighted]").length, 1,
    "There should be only one highlighted thumbnail available.");
  is(CallsListView.selectedIndex, 1,
    "The second draw call should be selected in the calls list view.");

  EventUtils.sendMouseEvent({ type: "mousedown" }, $all(".call-item-view")[2], window);
  yield once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
  info("The second draw call was selected, by clicking the third call item.");

  isnot($(".filmstrip-thumbnail[highlighted][index='2']"), null,
    "There should be a highlighted thumbnail available, for the second draw call.");
  is($all(".filmstrip-thumbnail[highlighted]").length, 1,
    "There should be only one highlighted thumbnail available.");
  is(CallsListView.selectedIndex, 2,
    "The second draw call should be selected in the calls list view.");

  yield teardown(panel);
  finish();
}