summaryrefslogtreecommitdiffstats
path: root/devtools/client/canvasdebugger/test/browser_canvas-frontend-snapshot-select-01.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /devtools/client/canvasdebugger/test/browser_canvas-frontend-snapshot-select-01.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/canvasdebugger/test/browser_canvas-frontend-snapshot-select-01.js')
-rw-r--r--devtools/client/canvasdebugger/test/browser_canvas-frontend-snapshot-select-01.js93
1 files changed, 93 insertions, 0 deletions
diff --git a/devtools/client/canvasdebugger/test/browser_canvas-frontend-snapshot-select-01.js b/devtools/client/canvasdebugger/test/browser_canvas-frontend-snapshot-select-01.js
new file mode 100644
index 000000000..4dc275282
--- /dev/null
+++ b/devtools/client/canvasdebugger/test/browser_canvas-frontend-snapshot-select-01.js
@@ -0,0 +1,93 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests if selecting snapshots in the frontend displays the appropriate data
+ * respective to their recorded animation frame.
+ */
+
+function* ifTestingSupported() {
+ let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
+ let { window, $, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin;
+
+ yield reload(target);
+
+ yield recordAndWaitForFirstSnapshot();
+ info("First snapshot recorded.");
+
+ is(SnapshotsListView.selectedIndex, 0,
+ "A snapshot should be automatically selected after first recording.");
+ is(CallsListView.selectedIndex, -1,
+ "There should be no call item automatically selected in the snapshot.");
+
+ yield recordAndWaitForAnotherSnapshot();
+ info("Second snapshot recorded.");
+
+ is(SnapshotsListView.selectedIndex, 0,
+ "A snapshot should not be automatically selected after another recording.");
+ is(CallsListView.selectedIndex, -1,
+ "There should still be no call item automatically selected in the snapshot.");
+
+ let secondSnapshotTarget = SnapshotsListView.getItemAtIndex(1).target;
+ let snapshotSelected = waitForSnapshotSelection();
+ EventUtils.sendMouseEvent({ type: "mousedown" }, secondSnapshotTarget, window);
+
+ yield snapshotSelected;
+ info("Second snapshot selected.");
+
+ is(SnapshotsListView.selectedIndex, 1,
+ "The second snapshot should now be selected.");
+ is(CallsListView.selectedIndex, -1,
+ "There should still be no call item automatically selected in the snapshot.");
+
+ let firstDrawCallContents = $(".call-item-contents", CallsListView.getItemAtIndex(2).target);
+ let screenshotDisplayed = once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
+ EventUtils.sendMouseEvent({ type: "mousedown" }, firstDrawCallContents, window);
+
+ yield screenshotDisplayed;
+ info("First draw call in the second snapshot selected.");
+
+ is(SnapshotsListView.selectedIndex, 1,
+ "The second snapshot should still be selected.");
+ is(CallsListView.selectedIndex, 2,
+ "The first draw call should now be selected in the snapshot.");
+
+ let firstSnapshotTarget = SnapshotsListView.getItemAtIndex(0).target;
+ snapshotSelected = waitForSnapshotSelection();
+ EventUtils.sendMouseEvent({ type: "mousedown" }, firstSnapshotTarget, window);
+
+ yield snapshotSelected;
+ info("First snapshot re-selected.");
+
+ is(SnapshotsListView.selectedIndex, 0,
+ "The first snapshot should now be re-selected.");
+ is(CallsListView.selectedIndex, -1,
+ "There should still be no call item automatically selected in the snapshot.");
+
+ function recordAndWaitForFirstSnapshot() {
+ let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
+ let snapshotSelected = waitForSnapshotSelection();
+ SnapshotsListView._onRecordButtonClick();
+ return promise.all([recordingFinished, snapshotSelected]);
+ }
+
+ function recordAndWaitForAnotherSnapshot() {
+ let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
+ SnapshotsListView._onRecordButtonClick();
+ return recordingFinished;
+ }
+
+ function waitForSnapshotSelection() {
+ let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
+ let thumbnailsDisplayed = once(window, EVENTS.THUMBNAILS_DISPLAYED);
+ let screenshotDisplayed = once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
+ return promise.all([
+ callListPopulated,
+ thumbnailsDisplayed,
+ screenshotDisplayed
+ ]);
+ }
+
+ yield teardown(panel);
+ finish();
+}