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.

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

mercurial