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 arbitrary draw calls are generated properly. michael@0: */ michael@0: michael@0: function ifTestingSupported() { michael@0: let [target, debuggee, front] = yield initCanavsDebuggerBackend(SIMPLE_CANVAS_TRANSPARENT_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: is(functionCalls[0].name, "clearRect", michael@0: "The first called function's name is correct."); michael@0: is(functionCalls[2].name, "fillRect", michael@0: "The second called function's name is correct."); michael@0: is(functionCalls[4].name, "fillRect", michael@0: "The third called function's name is correct."); michael@0: is(functionCalls[6].name, "fillRect", michael@0: "The fourth called function's name is correct."); michael@0: michael@0: let firstDrawCallScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[0]); michael@0: let secondDrawCallScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[2]); michael@0: let thirdDrawCallScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[4]); michael@0: let fourthDrawCallScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[6]); michael@0: michael@0: ok(firstDrawCallScreenshot, michael@0: "The first draw call has a screenshot attached."); michael@0: is(firstDrawCallScreenshot.index, 0, michael@0: "The first draw call has the correct screenshot index."); michael@0: is(firstDrawCallScreenshot.width, 128, michael@0: "The first draw call has the correct screenshot width."); michael@0: is(firstDrawCallScreenshot.height, 128, michael@0: "The first draw call has the correct screenshot height."); michael@0: is([].find.call(firstDrawCallScreenshot.pixels, e => e > 0), undefined, michael@0: "The first draw call's screenshot's pixels seems to be completely transparent."); michael@0: michael@0: ok(secondDrawCallScreenshot, michael@0: "The second draw call has a screenshot attached."); michael@0: is(secondDrawCallScreenshot.index, 2, michael@0: "The second draw call has the correct screenshot index."); michael@0: is(secondDrawCallScreenshot.width, 128, michael@0: "The second draw call has the correct screenshot width."); michael@0: is(secondDrawCallScreenshot.height, 128, michael@0: "The second draw call has the correct screenshot height."); michael@0: is([].find.call(firstDrawCallScreenshot.pixels, e => e > 0), undefined, michael@0: "The second draw call's screenshot's pixels seems to be completely transparent."); michael@0: michael@0: ok(thirdDrawCallScreenshot, michael@0: "The third draw call has a screenshot attached."); michael@0: is(thirdDrawCallScreenshot.index, 4, michael@0: "The third draw call has the correct screenshot index."); michael@0: is(thirdDrawCallScreenshot.width, 128, michael@0: "The third draw call has the correct screenshot width."); michael@0: is(thirdDrawCallScreenshot.height, 128, michael@0: "The third draw call has the correct screenshot height."); michael@0: is([].find.call(thirdDrawCallScreenshot.pixels, e => e > 0), 2160001024, michael@0: "The third draw call's screenshot's pixels seems to not be completely transparent."); michael@0: michael@0: ok(fourthDrawCallScreenshot, michael@0: "The fourth draw call has a screenshot attached."); michael@0: is(fourthDrawCallScreenshot.index, 6, michael@0: "The fourth draw call has the correct screenshot index."); michael@0: is(fourthDrawCallScreenshot.width, 128, michael@0: "The fourth draw call has the correct screenshot width."); michael@0: is(fourthDrawCallScreenshot.height, 128, michael@0: "The fourth draw call has the correct screenshot height."); michael@0: is([].find.call(fourthDrawCallScreenshot.pixels, e => e > 0), 2147483839, michael@0: "The fourth draw call's screenshot's pixels seems to not be completely transparent."); michael@0: michael@0: isnot(firstDrawCallScreenshot.pixels, secondDrawCallScreenshot.pixels, michael@0: "The screenshots taken on consecutive draw calls are different (1)."); michael@0: isnot(secondDrawCallScreenshot.pixels, thirdDrawCallScreenshot.pixels, michael@0: "The screenshots taken on consecutive draw calls are different (2)."); michael@0: isnot(thirdDrawCallScreenshot.pixels, fourthDrawCallScreenshot.pixels, michael@0: "The screenshots taken on consecutive draw calls are different (3)."); michael@0: michael@0: yield removeTab(target.tab); michael@0: finish(); michael@0: }