michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests if screenshots for non-draw calls can still be retrieved properly, michael@0: * by deferring the the most recent previous draw-call. michael@0: */ michael@0: michael@0: function ifTestingSupported() { michael@0: let [target, debuggee, front] = yield initCanavsDebuggerBackend(SIMPLE_CANVAS_URL); michael@0: michael@0: let navigated = once(target, "navigate"); michael@0: michael@0: yield front.setup({ reload: true }); michael@0: ok(true, "The front was setup up successfully."); michael@0: michael@0: yield navigated; michael@0: ok(true, "Target automatically navigated when the front was set up."); michael@0: michael@0: let snapshotActor = yield front.recordAnimationFrame(); michael@0: let animationOverview = yield snapshotActor.getOverview(); michael@0: michael@0: let functionCalls = animationOverview.calls; michael@0: ok(functionCalls, michael@0: "An array of function call actors was sent after recording."); michael@0: is(functionCalls.length, 8, michael@0: "The number of function call actors is correct."); michael@0: michael@0: let firstNonDrawCall = yield functionCalls[1].getDetails(); michael@0: let secondNonDrawCall = yield functionCalls[3].getDetails(); michael@0: let lastNonDrawCall = yield functionCalls[7].getDetails(); michael@0: michael@0: is(firstNonDrawCall.name, "fillStyle", michael@0: "The first non-draw function's name is correct."); michael@0: is(secondNonDrawCall.name, "fillStyle", michael@0: "The second non-draw function's name is correct."); michael@0: is(lastNonDrawCall.name, "requestAnimationFrame", michael@0: "The last non-draw function's name is correct."); michael@0: michael@0: let firstScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[1]); michael@0: let secondScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[3]); michael@0: let lastScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[7]); michael@0: michael@0: ok(firstScreenshot, michael@0: "A screenshot was successfully retrieved for the first non-draw function."); michael@0: ok(secondScreenshot, michael@0: "A screenshot was successfully retrieved for the second non-draw function."); michael@0: ok(lastScreenshot, michael@0: "A screenshot was successfully retrieved for the last non-draw function."); michael@0: michael@0: let firstActualScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[0]); michael@0: ok(sameArray(firstScreenshot.pixels, firstActualScreenshot.pixels), michael@0: "The screenshot for the first non-draw function is correct."); michael@0: is(firstScreenshot.width, 128, michael@0: "The screenshot for the first non-draw function has the correct width."); michael@0: is(firstScreenshot.height, 128, michael@0: "The screenshot for the first non-draw function has the correct height."); michael@0: michael@0: let secondActualScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[2]); michael@0: ok(sameArray(secondScreenshot.pixels, secondActualScreenshot.pixels), michael@0: "The screenshot for the second non-draw function is correct."); michael@0: is(secondScreenshot.width, 128, michael@0: "The screenshot for the second non-draw function has the correct width."); michael@0: is(secondScreenshot.height, 128, michael@0: "The screenshot for the second non-draw function has the correct height."); michael@0: michael@0: let lastActualScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[6]); michael@0: ok(sameArray(lastScreenshot.pixels, lastActualScreenshot.pixels), michael@0: "The screenshot for the last non-draw function is correct."); michael@0: is(lastScreenshot.width, 128, michael@0: "The screenshot for the last non-draw function has the correct width."); michael@0: is(lastScreenshot.height, 128, michael@0: "The screenshot for the last non-draw function has the correct height."); michael@0: michael@0: ok(!sameArray(firstScreenshot.pixels, secondScreenshot.pixels), michael@0: "The screenshots taken on consecutive draw calls are different (1)."); michael@0: ok(!sameArray(secondScreenshot.pixels, lastScreenshot.pixels), michael@0: "The screenshots taken on consecutive draw calls are different (2)."); michael@0: michael@0: yield removeTab(target.tab); michael@0: finish(); michael@0: } michael@0: michael@0: function sameArray(a, b) { michael@0: if (a.length != b.length) { michael@0: return false; michael@0: } michael@0: for (let i = 0; i < a.length; i++) { michael@0: if (a[i] !== b[i]) { michael@0: return false; michael@0: } michael@0: } michael@0: return true; michael@0: }