summaryrefslogtreecommitdiffstats
path: root/devtools/client/canvasdebugger/test/browser_canvas-frontend-slider-02.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-slider-02.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-slider-02.js')
-rw-r--r--devtools/client/canvasdebugger/test/browser_canvas-frontend-slider-02.js97
1 files changed, 97 insertions, 0 deletions
diff --git a/devtools/client/canvasdebugger/test/browser_canvas-frontend-slider-02.js b/devtools/client/canvasdebugger/test/browser_canvas-frontend-slider-02.js
new file mode 100644
index 000000000..5074ab206
--- /dev/null
+++ b/devtools/client/canvasdebugger/test/browser_canvas-frontend-slider-02.js
@@ -0,0 +1,97 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests if the slider in the calls list view works as advertised.
+ */
+
+function* ifTestingSupported() {
+ let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
+ let { window, $, EVENTS, gFront, 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);
+ SnapshotsListView._onRecordButtonClick();
+ yield promise.all([recordingFinished, callListPopulated, thumbnailsDisplayed]);
+
+ let firstSnapshot = SnapshotsListView.getItemAtIndex(0);
+ let firstSnapshotOverview = yield firstSnapshot.attachment.actor.getOverview();
+
+ let thumbnails = firstSnapshotOverview.thumbnails;
+ is(thumbnails.length, 4,
+ "There should be 4 thumbnails cached for the snapshot item.");
+
+ let thumbnailImageElementSet = waitForMozSetImageElement(window);
+ $("#calls-slider").value = 1;
+ let thumbnailPixels = yield thumbnailImageElementSet;
+
+ ok(sameArray(thumbnailPixels, thumbnails[0].pixels),
+ "The screenshot element should have a thumbnail as an immediate background.");
+
+ yield once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
+ ok(true, "The full-sized screenshot was displayed for the item at index 1.");
+
+ thumbnailImageElementSet = waitForMozSetImageElement(window);
+ $("#calls-slider").value = 2;
+ thumbnailPixels = yield thumbnailImageElementSet;
+
+ ok(sameArray(thumbnailPixels, thumbnails[1].pixels),
+ "The screenshot element should have a thumbnail as an immediate background.");
+
+ yield once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
+ ok(true, "The full-sized screenshot was displayed for the item at index 2.");
+
+ thumbnailImageElementSet = waitForMozSetImageElement(window);
+ $("#calls-slider").value = 7;
+ thumbnailPixels = yield thumbnailImageElementSet;
+
+ ok(sameArray(thumbnailPixels, thumbnails[3].pixels),
+ "The screenshot element should have a thumbnail as an immediate background.");
+
+ yield once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
+ ok(true, "The full-sized screenshot was displayed for the item at index 7.");
+
+ thumbnailImageElementSet = waitForMozSetImageElement(window);
+ $("#calls-slider").value = 4;
+ thumbnailPixels = yield thumbnailImageElementSet;
+
+ ok(sameArray(thumbnailPixels, thumbnails[2].pixels),
+ "The screenshot element should have a thumbnail as an immediate background.");
+
+ yield once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
+ ok(true, "The full-sized screenshot was displayed for the item at index 4.");
+
+ thumbnailImageElementSet = waitForMozSetImageElement(window);
+ $("#calls-slider").value = 0;
+ thumbnailPixels = yield thumbnailImageElementSet;
+
+ ok(sameArray(thumbnailPixels, thumbnails[0].pixels),
+ "The screenshot element should have a thumbnail as an immediate background.");
+
+ yield once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
+ ok(true, "The full-sized screenshot was displayed for the item at index 0.");
+
+ yield teardown(panel);
+ finish();
+}
+
+function waitForMozSetImageElement(panel) {
+ let deferred = promise.defer();
+ panel._onMozSetImageElement = deferred.resolve;
+ return deferred.promise;
+}
+
+function sameArray(a, b) {
+ if (a.length != b.length) {
+ return false;
+ }
+ for (let i = 0; i < a.length; i++) {
+ if (a[i] !== b[i]) {
+ return false;
+ }
+ }
+ return true;
+}