Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | /** |
michael@0 | 5 | * Tests if screenshots for arbitrary draw calls are generated properly. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | function ifTestingSupported() { |
michael@0 | 9 | let [target, debuggee, front] = yield initCanavsDebuggerBackend(SIMPLE_CANVAS_TRANSPARENT_URL); |
michael@0 | 10 | |
michael@0 | 11 | let navigated = once(target, "navigate"); |
michael@0 | 12 | |
michael@0 | 13 | yield front.setup({ reload: true }); |
michael@0 | 14 | ok(true, "The front was setup up successfully."); |
michael@0 | 15 | |
michael@0 | 16 | yield navigated; |
michael@0 | 17 | ok(true, "Target automatically navigated when the front was set up."); |
michael@0 | 18 | |
michael@0 | 19 | let snapshotActor = yield front.recordAnimationFrame(); |
michael@0 | 20 | let animationOverview = yield snapshotActor.getOverview(); |
michael@0 | 21 | |
michael@0 | 22 | let functionCalls = animationOverview.calls; |
michael@0 | 23 | ok(functionCalls, |
michael@0 | 24 | "An array of function call actors was sent after recording."); |
michael@0 | 25 | is(functionCalls.length, 8, |
michael@0 | 26 | "The number of function call actors is correct."); |
michael@0 | 27 | |
michael@0 | 28 | is(functionCalls[0].name, "clearRect", |
michael@0 | 29 | "The first called function's name is correct."); |
michael@0 | 30 | is(functionCalls[2].name, "fillRect", |
michael@0 | 31 | "The second called function's name is correct."); |
michael@0 | 32 | is(functionCalls[4].name, "fillRect", |
michael@0 | 33 | "The third called function's name is correct."); |
michael@0 | 34 | is(functionCalls[6].name, "fillRect", |
michael@0 | 35 | "The fourth called function's name is correct."); |
michael@0 | 36 | |
michael@0 | 37 | let firstDrawCallScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[0]); |
michael@0 | 38 | let secondDrawCallScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[2]); |
michael@0 | 39 | let thirdDrawCallScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[4]); |
michael@0 | 40 | let fourthDrawCallScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[6]); |
michael@0 | 41 | |
michael@0 | 42 | ok(firstDrawCallScreenshot, |
michael@0 | 43 | "The first draw call has a screenshot attached."); |
michael@0 | 44 | is(firstDrawCallScreenshot.index, 0, |
michael@0 | 45 | "The first draw call has the correct screenshot index."); |
michael@0 | 46 | is(firstDrawCallScreenshot.width, 128, |
michael@0 | 47 | "The first draw call has the correct screenshot width."); |
michael@0 | 48 | is(firstDrawCallScreenshot.height, 128, |
michael@0 | 49 | "The first draw call has the correct screenshot height."); |
michael@0 | 50 | is([].find.call(firstDrawCallScreenshot.pixels, e => e > 0), undefined, |
michael@0 | 51 | "The first draw call's screenshot's pixels seems to be completely transparent."); |
michael@0 | 52 | |
michael@0 | 53 | ok(secondDrawCallScreenshot, |
michael@0 | 54 | "The second draw call has a screenshot attached."); |
michael@0 | 55 | is(secondDrawCallScreenshot.index, 2, |
michael@0 | 56 | "The second draw call has the correct screenshot index."); |
michael@0 | 57 | is(secondDrawCallScreenshot.width, 128, |
michael@0 | 58 | "The second draw call has the correct screenshot width."); |
michael@0 | 59 | is(secondDrawCallScreenshot.height, 128, |
michael@0 | 60 | "The second draw call has the correct screenshot height."); |
michael@0 | 61 | is([].find.call(firstDrawCallScreenshot.pixels, e => e > 0), undefined, |
michael@0 | 62 | "The second draw call's screenshot's pixels seems to be completely transparent."); |
michael@0 | 63 | |
michael@0 | 64 | ok(thirdDrawCallScreenshot, |
michael@0 | 65 | "The third draw call has a screenshot attached."); |
michael@0 | 66 | is(thirdDrawCallScreenshot.index, 4, |
michael@0 | 67 | "The third draw call has the correct screenshot index."); |
michael@0 | 68 | is(thirdDrawCallScreenshot.width, 128, |
michael@0 | 69 | "The third draw call has the correct screenshot width."); |
michael@0 | 70 | is(thirdDrawCallScreenshot.height, 128, |
michael@0 | 71 | "The third draw call has the correct screenshot height."); |
michael@0 | 72 | is([].find.call(thirdDrawCallScreenshot.pixels, e => e > 0), 2160001024, |
michael@0 | 73 | "The third draw call's screenshot's pixels seems to not be completely transparent."); |
michael@0 | 74 | |
michael@0 | 75 | ok(fourthDrawCallScreenshot, |
michael@0 | 76 | "The fourth draw call has a screenshot attached."); |
michael@0 | 77 | is(fourthDrawCallScreenshot.index, 6, |
michael@0 | 78 | "The fourth draw call has the correct screenshot index."); |
michael@0 | 79 | is(fourthDrawCallScreenshot.width, 128, |
michael@0 | 80 | "The fourth draw call has the correct screenshot width."); |
michael@0 | 81 | is(fourthDrawCallScreenshot.height, 128, |
michael@0 | 82 | "The fourth draw call has the correct screenshot height."); |
michael@0 | 83 | is([].find.call(fourthDrawCallScreenshot.pixels, e => e > 0), 2147483839, |
michael@0 | 84 | "The fourth draw call's screenshot's pixels seems to not be completely transparent."); |
michael@0 | 85 | |
michael@0 | 86 | isnot(firstDrawCallScreenshot.pixels, secondDrawCallScreenshot.pixels, |
michael@0 | 87 | "The screenshots taken on consecutive draw calls are different (1)."); |
michael@0 | 88 | isnot(secondDrawCallScreenshot.pixels, thirdDrawCallScreenshot.pixels, |
michael@0 | 89 | "The screenshots taken on consecutive draw calls are different (2)."); |
michael@0 | 90 | isnot(thirdDrawCallScreenshot.pixels, fourthDrawCallScreenshot.pixels, |
michael@0 | 91 | "The screenshots taken on consecutive draw calls are different (3)."); |
michael@0 | 92 | |
michael@0 | 93 | yield removeTab(target.tab); |
michael@0 | 94 | finish(); |
michael@0 | 95 | } |