browser/devtools/canvasdebugger/test/browser_canvas-frontend-snapshot-select.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * Tests if selecting snapshots in the frontend displays the appropriate data
     6  * respective to their recorded animation frame.
     7  */
     9 function ifTestingSupported() {
    10   let [target, debuggee, panel] = yield initCanavsDebuggerFrontend(SIMPLE_CANVAS_URL);
    11   let { window, $, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin;
    13   yield reload(target);
    15   yield recordAndWaitForFirstSnapshot();
    16   info("First snapshot recorded.")
    18   is(SnapshotsListView.selectedIndex, 0,
    19     "A snapshot should be automatically selected after first recording.");
    20   is(CallsListView.selectedIndex, -1,
    21     "There should be no call item automatically selected in the snapshot.");
    23   yield recordAndWaitForAnotherSnapshot();
    24   info("Second snapshot recorded.")
    26   is(SnapshotsListView.selectedIndex, 0,
    27     "A snapshot should not be automatically selected after another recording.");
    28   is(CallsListView.selectedIndex, -1,
    29     "There should still be no call item automatically selected in the snapshot.");
    31   let secondSnapshotTarget = SnapshotsListView.getItemAtIndex(1).target;
    32   let snapshotSelected = waitForSnapshotSelection();
    33   EventUtils.sendMouseEvent({ type: "mousedown" }, secondSnapshotTarget, window);
    35   yield snapshotSelected;
    36   info("Second snapshot selected.");
    38   is(SnapshotsListView.selectedIndex, 1,
    39     "The second snapshot should now be selected.");
    40   is(CallsListView.selectedIndex, -1,
    41     "There should still be no call item automatically selected in the snapshot.");
    43   let firstDrawCallContents = $(".call-item-contents", CallsListView.getItemAtIndex(2).target);
    44   let screenshotDisplayed = once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
    45   EventUtils.sendMouseEvent({ type: "mousedown" }, firstDrawCallContents, window);
    47   yield screenshotDisplayed;
    48   info("First draw call in the second snapshot selected.");
    50   is(SnapshotsListView.selectedIndex, 1,
    51     "The second snapshot should still be selected.");
    52   is(CallsListView.selectedIndex, 2,
    53     "The first draw call should now be selected in the snapshot.");
    55   let firstSnapshotTarget = SnapshotsListView.getItemAtIndex(0).target;
    56   let snapshotSelected = waitForSnapshotSelection();
    57   EventUtils.sendMouseEvent({ type: "mousedown" }, firstSnapshotTarget, window);
    59   yield snapshotSelected;
    60   info("First snapshot re-selected.");
    62   is(SnapshotsListView.selectedIndex, 0,
    63     "The first snapshot should now be re-selected.");
    64   is(CallsListView.selectedIndex, -1,
    65     "There should still be no call item automatically selected in the snapshot.");
    67   function recordAndWaitForFirstSnapshot() {
    68     let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
    69     let snapshotSelected = waitForSnapshotSelection();
    70     SnapshotsListView._onRecordButtonClick();
    71     return promise.all([recordingFinished, snapshotSelected]);
    72   }
    74   function recordAndWaitForAnotherSnapshot() {
    75     let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
    76     SnapshotsListView._onRecordButtonClick();
    77     return recordingFinished;
    78   }
    80   function waitForSnapshotSelection() {
    81     let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
    82     let thumbnailsDisplayed = once(window, EVENTS.THUMBNAILS_DISPLAYED);
    83     let screenshotDisplayed = once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
    84     return promise.all([
    85       callListPopulated,
    86       thumbnailsDisplayed,
    87       screenshotDisplayed
    88     ]);
    89   }
    91   yield teardown(panel);
    92   finish();
    93 }

mercurial