1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/canvasdebugger/test/browser_canvas-actor-test-06.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,95 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Tests if screenshots for arbitrary draw calls are generated properly. 1.9 + */ 1.10 + 1.11 +function ifTestingSupported() { 1.12 + let [target, debuggee, front] = yield initCanavsDebuggerBackend(SIMPLE_CANVAS_TRANSPARENT_URL); 1.13 + 1.14 + let navigated = once(target, "navigate"); 1.15 + 1.16 + yield front.setup({ reload: true }); 1.17 + ok(true, "The front was setup up successfully."); 1.18 + 1.19 + yield navigated; 1.20 + ok(true, "Target automatically navigated when the front was set up."); 1.21 + 1.22 + let snapshotActor = yield front.recordAnimationFrame(); 1.23 + let animationOverview = yield snapshotActor.getOverview(); 1.24 + 1.25 + let functionCalls = animationOverview.calls; 1.26 + ok(functionCalls, 1.27 + "An array of function call actors was sent after recording."); 1.28 + is(functionCalls.length, 8, 1.29 + "The number of function call actors is correct."); 1.30 + 1.31 + is(functionCalls[0].name, "clearRect", 1.32 + "The first called function's name is correct."); 1.33 + is(functionCalls[2].name, "fillRect", 1.34 + "The second called function's name is correct."); 1.35 + is(functionCalls[4].name, "fillRect", 1.36 + "The third called function's name is correct."); 1.37 + is(functionCalls[6].name, "fillRect", 1.38 + "The fourth called function's name is correct."); 1.39 + 1.40 + let firstDrawCallScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[0]); 1.41 + let secondDrawCallScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[2]); 1.42 + let thirdDrawCallScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[4]); 1.43 + let fourthDrawCallScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[6]); 1.44 + 1.45 + ok(firstDrawCallScreenshot, 1.46 + "The first draw call has a screenshot attached."); 1.47 + is(firstDrawCallScreenshot.index, 0, 1.48 + "The first draw call has the correct screenshot index."); 1.49 + is(firstDrawCallScreenshot.width, 128, 1.50 + "The first draw call has the correct screenshot width."); 1.51 + is(firstDrawCallScreenshot.height, 128, 1.52 + "The first draw call has the correct screenshot height."); 1.53 + is([].find.call(firstDrawCallScreenshot.pixels, e => e > 0), undefined, 1.54 + "The first draw call's screenshot's pixels seems to be completely transparent."); 1.55 + 1.56 + ok(secondDrawCallScreenshot, 1.57 + "The second draw call has a screenshot attached."); 1.58 + is(secondDrawCallScreenshot.index, 2, 1.59 + "The second draw call has the correct screenshot index."); 1.60 + is(secondDrawCallScreenshot.width, 128, 1.61 + "The second draw call has the correct screenshot width."); 1.62 + is(secondDrawCallScreenshot.height, 128, 1.63 + "The second draw call has the correct screenshot height."); 1.64 + is([].find.call(firstDrawCallScreenshot.pixels, e => e > 0), undefined, 1.65 + "The second draw call's screenshot's pixels seems to be completely transparent."); 1.66 + 1.67 + ok(thirdDrawCallScreenshot, 1.68 + "The third draw call has a screenshot attached."); 1.69 + is(thirdDrawCallScreenshot.index, 4, 1.70 + "The third draw call has the correct screenshot index."); 1.71 + is(thirdDrawCallScreenshot.width, 128, 1.72 + "The third draw call has the correct screenshot width."); 1.73 + is(thirdDrawCallScreenshot.height, 128, 1.74 + "The third draw call has the correct screenshot height."); 1.75 + is([].find.call(thirdDrawCallScreenshot.pixels, e => e > 0), 2160001024, 1.76 + "The third draw call's screenshot's pixels seems to not be completely transparent."); 1.77 + 1.78 + ok(fourthDrawCallScreenshot, 1.79 + "The fourth draw call has a screenshot attached."); 1.80 + is(fourthDrawCallScreenshot.index, 6, 1.81 + "The fourth draw call has the correct screenshot index."); 1.82 + is(fourthDrawCallScreenshot.width, 128, 1.83 + "The fourth draw call has the correct screenshot width."); 1.84 + is(fourthDrawCallScreenshot.height, 128, 1.85 + "The fourth draw call has the correct screenshot height."); 1.86 + is([].find.call(fourthDrawCallScreenshot.pixels, e => e > 0), 2147483839, 1.87 + "The fourth draw call's screenshot's pixels seems to not be completely transparent."); 1.88 + 1.89 + isnot(firstDrawCallScreenshot.pixels, secondDrawCallScreenshot.pixels, 1.90 + "The screenshots taken on consecutive draw calls are different (1)."); 1.91 + isnot(secondDrawCallScreenshot.pixels, thirdDrawCallScreenshot.pixels, 1.92 + "The screenshots taken on consecutive draw calls are different (2)."); 1.93 + isnot(thirdDrawCallScreenshot.pixels, fourthDrawCallScreenshot.pixels, 1.94 + "The screenshots taken on consecutive draw calls are different (3)."); 1.95 + 1.96 + yield removeTab(target.tab); 1.97 + finish(); 1.98 +}