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