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 non-draw calls can still be retrieved properly,
6 * by deferring the the most recent previous draw-call.
7 */
9 function ifTestingSupported() {
10 let [target, debuggee, front] = yield initCanavsDebuggerBackend(SIMPLE_CANVAS_URL);
12 let navigated = once(target, "navigate");
14 yield front.setup({ reload: true });
15 ok(true, "The front was setup up successfully.");
17 yield navigated;
18 ok(true, "Target automatically navigated when the front was set up.");
20 let snapshotActor = yield front.recordAnimationFrame();
21 let animationOverview = yield snapshotActor.getOverview();
23 let functionCalls = animationOverview.calls;
24 ok(functionCalls,
25 "An array of function call actors was sent after recording.");
26 is(functionCalls.length, 8,
27 "The number of function call actors is correct.");
29 let firstNonDrawCall = yield functionCalls[1].getDetails();
30 let secondNonDrawCall = yield functionCalls[3].getDetails();
31 let lastNonDrawCall = yield functionCalls[7].getDetails();
33 is(firstNonDrawCall.name, "fillStyle",
34 "The first non-draw function's name is correct.");
35 is(secondNonDrawCall.name, "fillStyle",
36 "The second non-draw function's name is correct.");
37 is(lastNonDrawCall.name, "requestAnimationFrame",
38 "The last non-draw function's name is correct.");
40 let firstScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[1]);
41 let secondScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[3]);
42 let lastScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[7]);
44 ok(firstScreenshot,
45 "A screenshot was successfully retrieved for the first non-draw function.");
46 ok(secondScreenshot,
47 "A screenshot was successfully retrieved for the second non-draw function.");
48 ok(lastScreenshot,
49 "A screenshot was successfully retrieved for the last non-draw function.");
51 let firstActualScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[0]);
52 ok(sameArray(firstScreenshot.pixels, firstActualScreenshot.pixels),
53 "The screenshot for the first non-draw function is correct.");
54 is(firstScreenshot.width, 128,
55 "The screenshot for the first non-draw function has the correct width.");
56 is(firstScreenshot.height, 128,
57 "The screenshot for the first non-draw function has the correct height.");
59 let secondActualScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[2]);
60 ok(sameArray(secondScreenshot.pixels, secondActualScreenshot.pixels),
61 "The screenshot for the second non-draw function is correct.");
62 is(secondScreenshot.width, 128,
63 "The screenshot for the second non-draw function has the correct width.");
64 is(secondScreenshot.height, 128,
65 "The screenshot for the second non-draw function has the correct height.");
67 let lastActualScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[6]);
68 ok(sameArray(lastScreenshot.pixels, lastActualScreenshot.pixels),
69 "The screenshot for the last non-draw function is correct.");
70 is(lastScreenshot.width, 128,
71 "The screenshot for the last non-draw function has the correct width.");
72 is(lastScreenshot.height, 128,
73 "The screenshot for the last non-draw function has the correct height.");
75 ok(!sameArray(firstScreenshot.pixels, secondScreenshot.pixels),
76 "The screenshots taken on consecutive draw calls are different (1).");
77 ok(!sameArray(secondScreenshot.pixels, lastScreenshot.pixels),
78 "The screenshots taken on consecutive draw calls are different (2).");
80 yield removeTab(target.tab);
81 finish();
82 }
84 function sameArray(a, b) {
85 if (a.length != b.length) {
86 return false;
87 }
88 for (let i = 0; i < a.length; i++) {
89 if (a[i] !== b[i]) {
90 return false;
91 }
92 }
93 return true;
94 }